Powershell/office365 AAD_basic 没有可用的许可证

Powershell/office365 No more licenses available for AAD_basic

我有一个 powershell 脚本,允许我们将人员添加到我们的 AD。我们有 200 个有效的 Azure Active Directory 基本许可证,分配了 169 个。然而现在它告诉它的许可证何时应该有另外 31 个可用

没有更多许可证可用:Company:AAD_BASIC

你们中有人可以帮助我吗?

很可能已删除的用户仍然要求您认为您已经离开的许可证。

为了收回这些许可,您需要重新激活它们,移除它们的许可并再次删除它们。

Get-MsolUser -ReturnDeletedUsers | 
    Where-Object {$_.IsLicensed -eq $true} |
    ForEach-Object {
        $upn = $_.UserPrincipalName  # store in a variable for convenience
        # temporarily re-activate the deleted user so we can remove the license
        $upn | Restore-MsolUser
        # get the list of licenses for this user and remove them
        $licenses = ($upn | Get-MsolUser).licenses.AccountSkuId
        $upn | Set-MsolUserLicense -RemoveLicenses $licenses
        # remove the user again
        $upn | Remove-MsolUser -Force
    }