使用 Office 365 PowerShell 管理用户帐户和许可证(七) Office 365 许可和 Windows PowerShell:删除许可证
来源:互联网 发布:淘宝店铺扣48考试 编辑:程序博客网 时间:2024/05/16 06:53
Office 365 许可和 Windows PowerShell:删除许可证
上一次修改主题:2016-12-21
介绍如何使用 Office 365 PowerShell 删除先前已分配给用户的 Office 365 许可证。
开始之前
本主题中的步骤需要您连接到 Office 365 PowerShell。有关说明,请参阅连接到 Office 365 PowerShell。
要查看组织中的许可计划 (AccountSkuID) 信息,请参阅下列主题:
使用 Office 365 PowerShell 查看许可证和服务
查看服务的许可信息
如果您使用 Get-MsolUser cmdlet 而无需使用 All 参数,仅可返回前 500 个帐户。
简版(说明不含解释)
此部分介绍的步骤未经任何渲染或过多解释。如果您有任何疑问或想了解更多信息,可以阅读本主题的其余部分。
要从现有的用户帐户中删除许可证,请使用以下语法:
Set-MsolUserLicense -UserPrincipalName <Account> -RemoveLicenses "<AccountSkuId1>", "<AccountSkuId2>"...
本示例从用户帐户 BelindaN@litwareinc.com 中删除 litwareinc:ENTERPRISEPACK
(Office 365 企业版 E3) 许可证。
Set-MsolUserLicense -UserPrincipalName belindan@litwareinc.com -RemoveLicenses "litwareinc:ENTERPRISEPACK"
要从一组现有的授权用户中删除许可证,请使用下列方法之一:
基于现有帐户属性筛选帐户 若要执行此操作,请使用以下语法:
$x = Get-MsolUser -All <FilterableAttributes> | where {$_.isLicensed -eq $true}; $x | foreach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "<AccountSkuId1>", "<AccountSkuId2>"...}
本示例从美国销售部门的所有帐户中删除
litwareinc:ENTERPRISEPACK
(Office 365 企业版 E3) 许可证。$USSales = Get-MsolUser -All -Department "Sales" -UsageLocation "US" | where {$_.isLicensed -eq $true}; $USSales | foreach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "litwareinc:ENTERPRISEPACK"}
使用特定帐户列表 若要完成此操作,请执行以下步骤:
创建并保存一个文本文件,其中每一行都有一个帐户,如下所示:
akol@contoso.comtjohnston@contoso.comkakers@contoso.com
使用以下语法:
Get-Content "<FileNameAndPath>" | Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "<AccountSkuId1>", "<AccountSkuId2>"...
本示例从文本文件 C:\My Documents\Accounts.txt 中定义的用户帐户删除
litwareinc:ENTERPRISEPACK
(Office 365 企业版 E3) 许可证。Get-Content "C:\My Documents\Accounts.txt" | Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "litwareinc:ENTERPRISEPACK"
要从所有现有的用户帐户中删除许可证,请使用以下语法:
$x = Get-MsolUser -All | where {$_.isLicensed -eq $true}; $x | foreach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "<AccountSkuId1>", "<AccountSkuId2>"...}
本示例从所有现有的授权用户帐户中删除 litwareinc:ENTERPRISEPACK
(Office 365 企业版 E3) 许可证。
$x = Get-MsolUser -All | where {$_.isLicensed -eq $true}; $x | foreach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "litwareinc:ENTERPRISEPACK"}
长版(说明附有详细解释)
没有什么是永恒的,Office 365 许可证也是如此:您总有一天会需要从用户帐户删除许可证。也许用户正在休假,也许用户不再需要许可证,显然有多种原因让您希望删除用户许可证。
在进行下一步操作之前,请注意重要的一点,删除许可证还需要删除许可证本身:禁用许可证上的所有服务并不等同于删除许可证。例如,假设我们已经用完所有的 Office 365 许可证;换句话说,我们已没有任何可用的许可证。您决定按照使用 Office 365 PowerShell 禁止访问服务中的步骤禁用所有服务,即 Belinda Newman 帐户上的所有服务。这样操作之后,我们将有多少可用的许可证?没错:一个也没有了。是的,该主题中的步骤将禁用 Belinda 的许可证的所有服务,但不会禁用(即删除)许可证本身。许可证仍然有效,并且仍将分配给 Belinda Newman。她只是无法使用该许可证访问任何 Office 365 服务。
这很重要:如果您想删除某个用户的许可证,您必须真正删除此许可证。禁用所有服务将使用户无法登录到 Office 365,但并不会释放他/她的许可证。如果您想收回当前分配给某个用户的许可证,您需要运行与以下类似的命令,此命令将使用 RemoveLicenses 参数真正删除之前分配给 Belinda 的许可证:
Set-MsolUserLicense -UserPrincipalName BelindaN@litwareinc.com -RemoveLicenses "litwareinc:ENTERPRISEPACK"
运行该命令,Belinda Newman 将不再被许可使用 Office 365。
Get-MsolUser -UserPrincipalName BelindaN@litwareinc.com | Format-List DisplayName,Licenses
若要确定许可证确实已删除,可使用 Get-MsolUser 检查提及的用户帐户:
Get-MsolUser -UserPrincipalName BelindaN@litwareinc.com
如果一切按计划进行,现在 Belinda 的 isLicensed 属性将设置为 False
:
UserPrincipalName DisplayName isLicensed----------------- ----------- ----------BelindaN@litwareinc.com Newman, Belinda False
释放许可证的另一种方法是删除用户帐户。有关详细信息,请参阅使用 Office 365 PowerShell 删除和还原用户账户。
- 使用 Office 365 PowerShell 管理用户帐户和许可证(七) Office 365 许可和 Windows PowerShell:删除许可证
- 使用 Office 365 PowerShell 管理用户帐户和许可证(四)查看服务的许可信息
- 使用 Office 365 PowerShell 管理用户帐户和许可证(三)使用 Office 365 PowerShell 向用户帐户分配许可证
- 使用 Office 365 PowerShell 管理用户帐户和许可证(九)使用 Office 365 PowerShell 删除和还原用户账户
- 使用 Office 365 PowerShell 管理用户帐户和许可证
- 使用 Office 365 PowerShell 管理用户帐户和许可证(一)使用 Office 365 PowerShell 查看许可证和服务
- 使用 Office 365 PowerShell 管理用户帐户和许可证(十)使用 Office 365 PowerShell 创建用户帐户
- 使用 Office 365 PowerShell 管理用户帐户和许可证(八)使用 Office 365 PowerShell 冻结用户账户
- 使用 Office 365 PowerShell 管理用户帐户和许可证(五)Assign roles to user accounts with Office 365 PowerShell
- 使用 Office 365 PowerShell 管理用户帐户和许可证(十一)View user accounts with Office 365 PowerShell
- 使用 Office 365 PowerShell 管理用户帐户和许可证(六)
- 使用 Office 365 PowerShell 管理用户帐户和许可证(十二)Configure user account properties with Office 365 PowerShel
- 使用 Office 365 PowerShell 管理用户帐户和许可证(二)使用 Office 365 PowerShell 查看授权和未授权的用户
- Windows PowerShell 管理 Office 365
- Office 365 – SharePoint 2013 Online 中使用Windows PowerShell
- Office 365系列之十一:使用Windows PowerShell 批量导入用户
- Office 365系列之九:使用Windows PowerShell管理O365平台
- Office 365 Powershell 连接命令
- 一步一步玩控件:自定义TabControl——从山寨Safari开始
- 自动打包的流程
- java 简单版贪吃蛇小游戏
- postman 使用
- Doom4技术采访
- 使用 Office 365 PowerShell 管理用户帐户和许可证(七) Office 365 许可和 Windows PowerShell:删除许可证
- 微信小程序的条件、遍历、网络请求、获取本地图片
- linux下sqlite数据库用c语言sqlite3_get_table查询数据
- 深入php内核,从底层c语言剖析php实现原理
- 关于并查集
- Ubuntu安装python3 搭建 scrapy框架(哇,不知道怎么写,就这样吧)
- hashCode和identityHashCode的区别
- 什么叫做过拟合
- 个性化order排序字段