daily pastebin goal
42%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Global settings
  2. Set-ExecutionPolicy -ExecutionPolicy Bypass
  3. Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn;
  4.  
  5. #Selects input file
  6. $dataSource = import-csv "C:\scripts\users.csv"
  7.  
  8. #Assigns Mailbox for each AD user
  9. ForEach($dataRecord in $datasource){
  10.     $GeneratedUPN = "$($dataRecord.FirstInitial)$($dataRecord.LastName)@domain.com"
  11.     $UPN = (Get-ADUser -Filter {UserPrincipalName -eq $GeneratedUPN}).UserPrincipalName
  12.     IF($UPN){Enable-Mailbox $UserPrincipalName -Database $ExchangeDB}
RAW Paste Data
Top