Skip to content

Instantly share code, notes, and snippets.

View tostka's full-sized avatar

Todd Kadrie tostka

View GitHub Profile
@tostka
tostka / 20190715-1216PMH.ps1
Created July 17, 2019 23:09
Purge AzureAD User completely
# NO WHATIF AVAILABLE for remove-msoluser!
remove-msoluser -userprincipalname $adu.userprincipalname ;
# run again to remove from dumpster
remove-msoluser -userprincipalname $adu.userprincipalname -removefromrecyclebin -force ;
@tostka
tostka / 20190715-1216PMG.ps1
Created July 17, 2019 23:08
Move ADUser to non-replicated OU
# populate the DistName string below with a DN pointed at the target unreplicated OU
$tOU=get-adobject -Identity 'OU=Workspace,DC=SUBDOMAIN,DC=ad,DC=DOMAIN,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 ;
@tostka
tostka / 20190715-1216PMF.ps1
Last active July 17, 2019 23:18
Confirm No-Brain mbx status
# 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 ;
@tostka
tostka / 20190715-1216PME.ps1
Created July 17, 2019 23:01
Compare OPX & EXO recipienttypes
$rcp.recipienttype ;
$exorcp.recipienttype ;
@tostka
tostka / 20190715-1216PMD.ps1
Created July 17, 2019 22:57
Confirm MSol Licensing & status
Connect-MsolService ;
$msolu = Get-MsolUser -userp $rmbx.userprincipalname ;
$msolu | select userprin*, *Error*, *status*, softdel*, lic*, islic* ;
@tostka
tostka / 20190715-1216PMC.ps1
Last active July 17, 2019 23:02
Confirm EXO Recipient
$exorcp = get-exorecipient $rcp.PrimarySmtpAddress ;
$exorcp | select recipientt* ;
@tostka
tostka / 20190715-1216PMB.ps1
Created July 17, 2019 22:38
Confirm No EXO Mbx
$exombx = get-exomailbox -id $rmbx.userprincipalname ;
@tostka
tostka / 20190715-1216PMA.ps1
Last active July 17, 2019 22:36
Confirm :User has RemoteMailbox in OnPrem mail system
# Confirm User has RemoteMailbox in OnPrem mail system
# Note: Preconnect to onprem EX remote ps & EXO
# To differentiate targets, I prefix _EXO_ cmdlets with [verb]-exo[noun])
# on-prem cmdlets are _un-prefixed_
$tAddress = "UserUPN@DOMAIN.com" ;
# pull local recipient type
$rcp = get-recipient $tAddress ;
$rcp | ft -a alias, primar*, recipientt* ;
$rmbx = get-remotemailbox -id $rcp.PrimarySmtpAddress ;
$rmbx | format-table -auto Name, RecipientTypeD*, userprin* ;
# Confirm User has RemoteMailbox in OnPrem mail system
# Note: Preconnect to onprem EX remote ps & EXO
# To differentiate targets, I prefix _EXO_ cmdlets with [verb]-exo[noun])
# on-prem cmdlets are _un-prefixed_
$tAddress = "UserUPN@DOMAIN.com" ;
# pull local recipient type
$rcp = get-recipient $tAddress ;
$rcp | ft -a alias, primar*, recipientt* ;
$rmbx = get-remotemailbox -id $rcp.PrimarySmtpAddress ;
$rmbx | format-table -auto Name, RecipientTypeD*, userprin* ;
@tostka
tostka / verb-o365.ps1
Created July 10, 2018 18:41
verb-o365.ps1
## ======== V O365 EXO ETC FUNCS() V ===
# stuff your Office 365 admin account credentials into variables for unprompted reuse
<# the following are Admin (UID) and non-admin (LUA) credential objects for different tenants and logons
I keep their definitions in another profile-level pre-loaded module.
$o365AdmUid = "logon@domain.com" ; # Tenant 1 primary admin logon UPN
$o365LabAdmUid = "logon@domainlab.com" ; # # Tenant 2 primary admin logon UPN
$o365COAdmUid="logon@tenant1.onmicrosoft.com" ; # Tenant 1 optional cloud-only admin acct (for backup in case of loss of federated access)
$o365LabCOAdmUid="logon@tenant2.onmicrosoft.com" ; Tenant 2 cloud-only admin acct
# flag that switches from federated/broken SID acct to cloud only $o365COAdmUid