Get-Ryan

Disabled Users with forwarding addresses set

Sep 10th, 2015
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $Users = Get-ADUser -Filter {Enabled -ne $true} -Properties Name
  2. $Data = @()
  3.  
  4. ForEach($User in $Users){
  5.  
  6.     $mailbox = Get-Mailbox -Identity $User.Name | Where {$_.ForwardingAddress -ne $null}
  7.  
  8.     $Data += New-Object -TypeName PSObject -Property @{DisplayName = $mailbox.DisplayName;
  9.                                                        ForwardingAddress = $mailbox.ForwardingAddress}
  10.  
  11. }
  12.  
  13. $Data | Select DisplayName, ForwardingAddress | Export-Csv -LiteralPath C:/ForwadingDisabledUsers.csv -Append
Advertisement
Add Comment
Please, Sign In to add comment