-
Notifications
You must be signed in to change notification settings - Fork 0
PaulNiklausPraveen/Microsoft-365-PowerShell
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
#This Script will install Msonline powershell module and remove license from deleted users #Installs Microsoft Azure Active Directory Module for Windows PowerShell Install-Module Msonline #Imports the module Import-Module Msonline #Initiates a connection to Azure Active Directory connect-Msolservice $DeletedUsers=@() $DeletedUSers=(Get-MsolUser –ReturnDeletedUsers | Where-Object { $_.isLicensed -eq $True}).UserPrincipalName Foreach($DeletedUser in $DeletedUsers) { Restore-MsolUser -UserPrincipalName $DeletedUser Sleep 5 $License=(get-MsolUser -UserPrincipalName $DeletedUser).licenses.AccountSkuId Write-Host "Removing the License : $License for $DeletedUser" -ForegroundColor Yellow Set-MsolUserLicense -UserPrincipalName $DeletedUser -RemoveLicenses $License Remove-MsolUser -UserPrincipalName $DeletedUser -Force }
About
PowerShell for Microsoft 365 enables you to manage your Microsoft 365 settings from the command line.
Topics
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published