Posts Tagged ‘schedule’

You can start PowerShell scripts via taskplaner using a batch file
startscript.bat ->

Powershell.exe -command “.’C:\Scripts\script.ps1′”

script.ps1 ->

$localhost    = $env:COMPUTERNAME
#load exchange ps snapin if necessary
If ((Get-PSSnapin  | Where-Object {$_.Name -eq “Microsoft.Exchange.Management.PowerShell.E2010”} ).name -eq ‘Microsoft.Exchange.Management.PowerShell.E2010’)
{
Write-Host “Exchange Snapin loaded”
}

else
{
Write-Host “Loading Exchange Snapin”; Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
}
Write-Host “running”

After this you can insert your script code.