Usefull Commands
Powershell

To see the specifications of the powershell window

$host.ui.rawui

To see the enviromental settings
$env:Path

To add a enviromental to your path
$env:path += ";C:\program files\winrar"

To allow ps1 scripts to run you first have to change the default setting

Set-ExecutionPolicy RemoteSigned

To change it back
Set-ExecutionPolicy Default

How to schedule a script on vista or windows server 2008
powershell -command "& 'D:\Tools\scripts\backupeventlog.ps1' " -Localhost

This commando will start the following script

When you want to run a script that is downloaded from the Internet (and you have looked at the code) and you trust it do as follows:
Right-click the script .ps1 and choose UNBLOCK. Now you can run it and leave your default setting okay!

When you want something to being shown in the console but NOT in your logs (output on screen and not redirected) use:

 Write-Host "Evaluation is concluded."

To see your enviromentals type
cd env:

When you need to find a serial number for a dell/compac/hp machine you could enter the following command:
Get-WMIObject -Class "Win32_BIOS" -Computer computername | select SerialNumber

To see the days before an event will happen type:
(New-Timespan -end 24/12/2009).Days

Remember to change the date according to your regional settings

When you want to know the InstallDate of the windows machine type:

([WMI]'').ConvertToDateTime((Get-WmiObject Win32_operatingSystem).InstallDate)

When you want to convert a serial time entry to a human readable format you would type e.g.
$os=get-wmiobject win32_operatingsystem 
$time = $os.lastbootuptime 
[System.Management.ManagementDateTimeconverter]::ToDateTime($time)

Here is a oneliner I wrote to see all disk information in your domain, it will produce errors of machine it can't reach but it is a very usefull script, butt ugly but it does what it does :)
Get-ADComputer -filter * -Properties * |Where {($_.OperatingSystem -notlike "Windows 7 Enterprise") -and ($_.Operatingsystem -notlike "Windows 7 Professional") -and ($_.Operatingsystem -notlike "Windows X
P Professional") }| Sort-Object Name | select Name | foreach {$_.Name.ToString()} | foreach {get-wmiobject -Class Win32_l
ogicaldisk -computername $_}

On Me
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License