Archives for posts with tag: powershell

If you run into an issue where Exchange is running out of disk space on the C:\ drive, please check the logs in C:\InetPub , and C:\Program Files\Microsoft\Exchange Server\V15\Logging. If those directories are quite large you can run the following powershell script. It would also be a good idea to set it up as a scheduled task so the issue doesn’t reoccur.

 

gci ‘C:\Program Files\Microsoft\Exchange Server\V15\Logging’,’C:\inetpub\logs’ -Directory | gci -Include ‘*.log’,’*.blg’ -Recurse | ? LastWriteTime -lt (Get-Date).AddDays(-30) | Remove-Item

 

Advertisements

Change User Principal Name for Email Addresses

To fix E-mail authentication in situations where the domain name is test.com and the email account is testusers.com.

Create a new OU named test and new user named Joe User then place him in that new OU

Open Exchange management shell and follow the below steps

1)      Get-ADServersettings

2)      Change the Recipient view root to the New OU created above

3)      Set a variable for the users

  1. Get-mailbox
  2. $users = Get-Mailbox
  3. $users | ForEach {Set-User –Identity $_.Identity –UserPrincipalName $_.WindowsEmailAddress –Whatif}
  4. If all completes successfully then remove the –WhatIf statement and run again

4)      Check their AD account properties and click on account then see if it has been changed to their email address. If so then you are safe to do it to either more OU’s or then entire forest.

5)      To change the entire forest do the following

  1. Set-ADServersettings – RecipientViewRoot “test.com”
  2. Set-ADServersettings –ViewEntireForest $true
  3. Get-Mailbox
  4. $users = Get-Mailbox
  5. $users | ForEach {Set-User –Identity $_.Identity –UserPrincipalName $_.WindowsEmailAddress –Whatif}
  6. If all completes successfully then remove the –WhatIf statement and rerun

6)      Verify everything has been modified correctlyImageImageImage