Quantcast
Channel: Christopher Dargel's Exchange and Windows Blog » task
Viewing all articles
Browse latest Browse all 2

Schedule PowerShell scripts

$
0
0

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.



Viewing all articles
Browse latest Browse all 2

Trending Articles