powershell O365GroupLicencse.ps1

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell O365GroupLicencse.ps1相关的知识,希望对你有一定的参考价值。

#This script will assign a specified license to every user that is a part of a specified group.

#Connecting to Office 365
$usercredential = get-credential -credential "ENTER LOGIN HERE"
Connect-MsolService -Credential $usercredential 
#This is the license, Specify license from Get-MsolAccountSku 
$myAccountSKUID = "ENTER HERE"
#This sets the license to a variable
$licenseOptions = New-MsolLicenseOptions -AccountSkuId $myAccountSKUID
#This grabs the users in the specified group, Specify group ID from Get-MsolGroup
$users = Get-MsolGroupMember -GroupObjectId "ENTER GROUP ID HERE"

#Each listed user in the group
foreach($user in $users) 
{
#Since the username is essentially the user's email address in our O365, this sets a users license based on the user's 
#email address that is listed from the specified group to their principal name (which also happens to be their email) in O365
    Set-MsolUserLicense -UserPrincipalName $user.EmailAddress -AddLicenses $myAccountSKUID
}

以上是关于powershell O365GroupLicencse.ps1的主要内容,如果未能解决你的问题,请参考以下文章

使用PowerShell 批量修改O365 用户UPN

O365 PowerShell Script隔离邮件报告

O365 PowerShell Script邮件跟踪报告

使用PowerShell deprovision O365 资源

O365 PowerShell Script安全与合规中心审核日志

lduan office 365 Windows PowerShell管理O365平台 六