The following is a list of Office 365 commands you can use with Powershell. Ironically, I chose Powershell as my scripting language of choice for everything except this, but the general public chooses to learn powershell because it’s the primary way to interact with Office 365. I have a team that does this so I get little interaction though I will be happy to update this with anything I do use! The general connection setup is like:
$a = get-msoluser -UserPrincipalName "firstname.lastname@example.org"
$a | select *
$d = Get-AzureADUser -ObjectId "email@example.com"
$d | select *
Get-AzureADUser -ObjectId $d | Select -ExpandProperty ExtensionProperty
Although this is all supposed to be moving to MS Graph soon. Hopefully by the time I will be using this, everything will be done with a single module!
To Delete A User Permanently
Remove-MsolUser -UserPrincipalName 'firstname.lastname@example.org' -RemoveFromRecycleBin
Get-MsolUser -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin -Force
To add application as global administrator
$ClientWebApp = Get-MsolServicePrincipal -AppPrincipalId $someAppID
Add-MsolRoleMember -RoleName "Company Administrator" -RoleMemberType ServicePrincipal -RoleMemberObjectId $ClientWebApp.objectID