Thursday, June 8, 2017

Tips of the day #1706

Tip of the day #1706-1

Use Windows PowerShell to change the UPN suffix for all users
Change all company.local suffixes to company.com

Import-Module ActiveDirectory

Example 1.
$LocalUsers = Get-ADUser -Filter {UserPrincipalName -like '*company.local'} -Properties userPrincipalName -ResultSetSize $null

$LocalUsers | foreach {$newUpn = $_.UserPrincipalName.Replace("company.local","company.com"); $_ | Set-ADUser -UserPrincipalName $newUpn}




Example 2.
Get-ADUser -Filter * -SearchBase ‘OU=All Users,DC=company,DC=local’ -Properties userPrincipalName

Get-ADUser -Filter * -SearchBase ‘OU=All Users,DC=company,DC=local’ -Properties userPrincipalName | foreach { Set-ADUser $_ -UserPrincipalName $($_.samaccountname)@company.com”}
 

Tip of the day #1706-2

Checking Database size using some Powershell commands – Exchange 2010, 2013 & 2016

Get-MailboxDatabase -Status | ft name,databasesize, availablenewmailboxspace -auto


Tip of the day #1706-3

Remove E-Mail Addresses for a Specific Domain - Exchange 2010, 2013 & 2016

 
foreach($i in Get-Mailbox -ResultSize Unlimited) {
   $i.EmailAddresses |
     ?{$_.AddressString -like '*@mycompany.lviv.ua'} | %{
     Set-Mailbox $i -EmailAddresses @{remove=$_}
   }
}
 


No comments:

Post a Comment