Powershell to Settup ManagedFolderAssistantSchedule in all Exchange 2007 Mailbox Servers

The managed folder assistant is a Microsoft Exchange Mailbox Assistant that creates managed folders in users’ mailboxes and applies managed content settings to them. When the managed folder assistant is running, it processes all of the mailboxes on a server. If the managed folder assistant does not finish processing the mailboxes on the server during the time that you have scheduled, it automatically resumes processing where it left off the next time it runs. There is one managed folder assistant for each server

Get-ExchangeServer | Where { $_.AdminDisplayVersion.ToString().SubString(0, 10) -eq “Version 8.” `

-and $_.ServerRole -eq “Mailbox” } |

ForEach { Set-MailboxServer -Identity $_.Identity `

-ManagedFolderAssistantSchedule “Sun.1:00 AM-Sun.3:00 AM”, `

“Mon.1:00 AM-Mon.3:00 AM”, “Tue.1:00 AM-Tue.3:00 AM”, `

“Wed.1:00 AM-Wed.3:00 AM”, “Thu.1:00 AM-Thu.3:00 AM”, `

“Fri.1:00 AM-Fri.3:00 AM”, “Sat.1:00 AM-Sat.3:00 AM” }

http://technet.microsoft.com/en-us/library/bb123958.aspx

Powershell Script to check Health Services running in all Exchange 2007 servers

Below power shell Command Gets Each of the Exchange 2007 Server in the Environment and Check the Health Services then display the status.  Exchange Services varies depend on the type of services installed. Mailbox Services , Hubtransport Servers, Client Access server has some common service and some unique services. Test-Serverhealth performs the health check only on required services depending on the type of server Installed.

$ExchServer=Get-ExchangeServer
foreach ($Server in $ExchServer)
{
echo $Server.name (Test-ServiceHealth $Server)
}

Powershell to Get Exchange mailbox Database and Public Backup Status Report

Below power shell help you to get backup status of all the Exchange Database in Exchange 2007 Servers

Get-MailboxDatabase `
| where {$_.Recovery -eq $False } `
| Select-Object -Property Server, StorageGroupName, Name , LastFullBackup, LastIncrementalBackup, BackupInProgess `
| Sort-Object -Property Server, StorageGroupName, Name `
| Format-Table -AutoSize

Get-PublicFolderDatabase `
| Select-Object -Property Server, Storagegroupname, Name , LastFullBackup, LastIncrementalBackup, BackupInProgess `
| Sort-Object -Property Server, StorageGroupName, Name `
| Format-Table -AutoSize

Enabeling and Disabiling Active Sync for the user

Windows Mobiles can be configured for Active Sync. Active Sync is enabled for all users by Default in Exchange 2007. For Security reasons its recommended to disabled all users and enable only for the required users

Below power shell enabled and disabled Active for all the users in the exchange Organization

get-Mailbox -resultsize unlimited | set-CASMailbox -ActiveSyncEnabled:$False

get-Mailbox -resultsize unlimited | set-CASMailbox -ActiveSyncEnabled:$True

Below powershell command to enable and disable active sync for given set of users in the text file

Get-content C:\users.txt | set-CASMailbox -ActiveSyncEnabled:$True

Get-content C:\users.txt| set-CASMailbox -ActiveSyncEnabled:$True

Below powershell command to get the list of users who ActiveSync is Enabled and Disabled

Get-CASMailbox -ActiveSyncEnabled:$True

Get-CASMailbox -ActiveSyncEnabled:$False

Add-ADPermission with Exchange 2007 databases

 

Add-ADPermission cmdlet is used to provide permission to Active directory object.  This article explains you how to provide Access Exchange 2007 Database .  Below command sets permission on the Exchange Mailbox Stores and enables the AdminAccount to access uses mailboxes to  view, move, and delete messages, etc 

Get-MailboxDatabase | Add-ADPermission -User domain\Adminaccount –ExtendedRights ms-Exch-Store-Admin

Above command should workd prefectly fine, If you get any errors in executing above command then you may have to do some work around solution to set this

Add-Adpermission -identity “CN=InformationStore,CN=Exchange2007name,CN=Servers,CN=Exchange Administrative Group,CN=Administrative Groups,CN=company,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=Domain,DC=com” -User “Domain\adminAccount” –ExtendedRights ms-Exch-Store-Admin

Above command helps you the fix the problem. you may have to provide AD Distinguished Name for the Informatio store of the specific server to provide Extended Rights on access to all the Database of the specific the Exchange server. To Provide access to Individual Storage gropue then you may have to try something link this

Add-Adpermission -identity “SG=StorageGroupname,CN=InformationStore,CN=Exchange2007,CN=Servers,CN=Exchange Administrative Group,CN=Administrative Groups,CN=Our Company,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=myDomain,DC=com” -User “Domain\adminAccount” –ExtendedRights ms-Exch-Store-Admin

 

Add-Adpermission -identity “CN=Databasename,CN=StorageGroupname,CN=InformationStore,CN=Exchange2007,CN=Servers,CN=Exchange Administrative Group,CN=Administrative Groups,CN=Our Company,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=myDomain,DC=com” -User “Domain\adminAccount” –ExtendedRights ms-Exch-Store-Admin

Powershell to pull Application Event logs with Event Id 1221

Application Event ID 1221 gives the details of the white space on the Exchange Database.  With the amount of white space we can determine if we wanted to do a defrag on the store or not. Below powershell helps you to pull all the application events with id 1221 from last 2 days

$2DaysAgo = [DateTime]::Now.AddDays(-2)
$Events = Get-Eventlog Application | Where {($2DaysAgo -le $_.TimeWritten)} | ?{$_.eventid -eq “1221”}
$Events

Powershell to set AD user password to never Expire

 Below powershell command to set AD user to password never expires

 Set-QADUser -Identity “domain\account” -ObjectAttributes @{useraccountcontrol=65536}

If you have list of users then you can put the file into the txt file and use powershell to set all the required user to password never expires

 get-content “c:\users.txt” | Set-QADUser -ObjectAttributes @{useraccountcontrol=65536}

Troubleshooting Exchange 2007 Store Log/Database growth issues

 

One of the Interesting Issue with Many Exchange administrator faces and finds it difficult to address is Store Log/Database growth issue. Below is the link which has step by step instruction help you to find case of Database growth and logs in Exchange 2007 Mailbox Server

 

http://blogs.technet.com/mikelag/archive/2009/07/12/troubleshooting-store-log-database-growth-issues.aspx