Hot wo automate a Powershell on Windows Server:
Free ActiveRoles Management Shell for Active Directory 32/64-bit from Quest:
http://www.quest.com/powershell/activeroles-server.aspx
http://ss64.com/ps/quest.html
How to load the Powershell Plugins into the Shell (As example Exchange and the Quest)
http://technet.microsoft.com/en-us/library/bb963745.aspx
Add-PSSnapIn -Name Microsoft.Exchange.Management.PowerShell.Admin,Quest.ActiveRoles.ADManagement
Here is how to skip/catch the error if the SNAP in has laready been registered.
-
#Load Exchange PS Snapin
-
If (@(Get-PSSnapin -Registered | Where–Object {$_.Name –eq “Microsoft.Exchange.Management.PowerShell.E2010”} ).count –eq 1) {
-
If (@(Get-PSSnapin | Where–Object {$_.Name –eq “Microsoft.Exchange.Management.PowerShell.E2010”} ).count –eq 0) {
-
Write-Host “Loading Exchange Snapin Please Wait….”; Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010}
-
}
-
-
#Load Exchange PS Snapin
-
If (@(Get-PSSnapin -Registered | Where–Object {$_.Name –eq “Microsoft.Exchange.Management.PowerShell.Admin”} ).count –eq 1){
-
If (@(Get-PSSnapin | Where–Object {$_.Name –eq “Microsoft.Exchange.Management.PowerShell.Admin”} ).count –eq 0) {
-
Write-Host “Loading Exchange Snapin Please Wait….”; Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin}
-
}
Removing mailbox export and import requests from command New-MailboxExportRequest -Mailbox $Identity -FilePath $pstshare$user”.pst”
http://thoughtsofanidlemind.wordpress.com/2010/12/21/removing-mailbox-export-and-import-requests/