Last active
July 17, 2019 23:18
-
-
Save tostka/dae1a35c11409bf1f24a1758c8b7a880 to your computer and use it in GitHub Desktop.
Confirm No-Brain mbx status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# populate the DistName string below with a DN pointed at the target unreplicated OU | |
$tOU=get-adobject -Identity 'OU=Workspace,DC=global,DC=ad,DC=toro,DC=com' ; | |
# store the original ADUser object parentOU (split DN and build the parent OU) | |
$origOU=($adu.distinguishedname.split(",") | select -skip 1) -join "," ; | |
# move the ADUser object to the $tOU, note -whatif needs to be removed to execute | |
Move-ADObject -Identity $adu.ObjectGUID.guid -TargetPath $tOU.DistinguishedName -whatif ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NO WHATIF AVAILABLE for remove-msoluser! | |
remove-msoluser -userprincipalname $adu.userprincipalname ; | |
# run again to remove from dumpster | |
remove-msoluser -userprincipalname $adu.userprincipalname -removefromrecyclebin -force ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# note -whatif needs to be removed to execute | |
set-aduser -Identity $adu.samaccountname -clear msExchMailboxGuid, msexchrecipientdisplaytype, msexchrecipienttypedetails -whatif; | |
# confirm attributes cleared | |
get-aduser -Identity $adu.samaccountname -prop * | format-list msExchMailboxGuid, msexchrecipientdisplaytype, msexchrecipienttypedetails ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# confirm $origOU was properly configured up in step 1. | |
$origOU ; | |
# move the ADUser object to the $origOU, note -whatif needs to be removed to execute | |
Move-ADObject -Identity $adu.ObjectGUID.guid -TargetPath $origOU -whatif ; | |
# confirm current location | |
get-aduser $adu.samaccountname | format-list dist* ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# AAD replication dawdle loop: | |
# 1-line, note, the get-msoluser cmdlet lacks an erroraction param, which causes it to error every pass. But the code plows on until object is returned replicated | |
Do { write-host "." -NoNewLine; $msolu = get-MsolUser -UserPrincipalName $adu.userprincipalname ; start-sleep -s 30 ; } Until($msolu) ; write-host "`a" ; write-host "`a" ; write-host "`a" ; $msolu | format-list userprin*, *Error*, *status*, softdel*, lic*, islic* ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$msolu = get-MsolUser -UserPrincipalName $adu.userprincipalname ; $msolu | format-list userprin*, *Error*, *status*, softdel*, lic*, islic* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rxo ; get-exomailbox $tAddress ; rx10 ; get-recipient $tAddress | ft -a Name, RecipientT* ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$whatif = $true ; | |
$exombx = get-exomailbox $tAddress ; | |
$RemoteRoutingAddress = ($exombx.emailaddresses | ? { $_ -match '.*.mail\.onmicrosoft\.com' }).replace("smtp:", ""); | |
$pltEnable = [ordered]@{ | |
Identity = $exombx.alias ; | |
RemoteRoutingAddress = $RemoteRoutingAddress ; | |
whatif = $($whatif) ; | |
} ; | |
write-host -foregroundcolor green "$((get-date).ToString('HH:mm:ss')):Enable-RemoteMailbox w`n$(($pltEnable|out-string).trim())" ; | |
Enable-RemoteMailbox @pltEnable; | |
if (!$whatif) { | |
$pltSet = [ordered]@{ | |
Identity = $exombx.alias ; | |
ExchangeGuid = $exombx.ExchangeGuid ; | |
whatif = $($whatif) ; | |
} ; | |
write-host -foregroundcolor green "$((get-date).ToString('HH:mm:ss')):Set-RemoteMailbox w `n$(($pltSet|out-string).trim())" ; | |
Set-RemoteMailbox @pltSet ; | |
get-remotemailbox -id $exombx.alias | select userprin*, samac*, recipientt* ; | |
} ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$whatif=$true ;$exombx=get-exomailbox $tAddress ;$RemoteRoutingAddress=($exombx.emailaddresses |?{$_ -match '.*.mail\.onmicrosoft\.com'}).replace("smtp:","");$pltEnable=[ordered]@{ Identity=$exombx.alias ; RemoteRoutingAddress=$RemoteRoutingAddress ; whatif=$($whatif) ;} ;write-host -foregroundcolor green "$((get-date).ToString('HH:mm:ss')):Enable-RemoteMailbox w`n$(($pltEnable|out-string).trim())" ;Enable-RemoteMailbox @pltEnable;if(!$whatif){ $pltSet=[ordered]@{ Identity=$exombx.alias ; ExchangeGuid=$exombx.ExchangeGuid ; whatif=$($whatif) ; } ; write-host -foregroundcolor green "$((get-date).ToString('HH:mm:ss')):Set-RemoteMailbox w `n$(($pltSet|out-string).trim())" ; Set-RemoteMailbox @pltSet ; get-remotemailbox -id $exombx.alias | select userprin*,samac*,recipientt* ;} ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get-exomailbox $tAddress ; get-recipient $tAddress | ft -a Name, RecipientT* ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get-exomailbox $tAddress ; get-recipient $tAddress | ft -a Name, RecipientT* ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment