Quantcast
Viewing all articles
Browse latest Browse all 2

Schedule PowerShell scripts

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.


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 2

Trending Articles