how to convert your Powershell output to HTML file

Powershell has ability to save a html file for your scripts output.This gives you more flexibility to read and modify data format.

example 1

get-process | convertTo-html | set-content c:\Get-process.htm

This command gives your get-process command output to c:\get-process.htm
______________________

example 2

get-process | convertto-html -title "Get-process for this machine" -body "You can see processes of this machine" | set-content c:\get-processWithbody.htm

We add a title text and a body text to our html.





you can change the format of the html page.
-body "

"
-body " "


http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/convertto-html.mspx

Ping a host address by using Powershell

#create a ping object

$ping=New-Object net.NetworkInformation.Ping

#we gonna ping 4 times.

for ($i=0;$i -lt 4;$i++)
{
$result=$ping.send("www.google.com")
#if clause will decide whether it is ok or not.

if ($result.status -eq "Success")
{
$result.Address.ToString() + " IP address has been responding."
$result.Status
}
else{
"Failed"
}
}

Powershell-Creating Local User

how to create a local user by using Powershell

$user="powershell"
$password="12345678"

#uses ADSI types and WinNT provider

$objou=[ADSI]"WinNT://erkan_sezgin"
$objuser=$objou.create("user",$user)
$objuser.setpassword($password)
$objuser.setinfo()
$objuser.description="test user"
$objuser.setinfo()

Powershell Net formları giriş

[void][reflection.assembly]::LoadWithPartialName(
"System.windows.forms"
$form=new-object windows.forms.form
$form.text="Form Başlık"
$button=new-object windows.forms.button
$button.text="Click"
$button.dock="Fill"
$button.add_click({$form.close()})
$form.controls.add($button)
$form.add_shown({$form.activate()})
$form.showdialog()