Powershell Office 365将txt文件中的用户转换为共享邮箱并删除许可证

Powershell Office 365将txt文件中的用户转换为共享邮箱并删除许可证,powershell,office365,Powershell,Office365,因此,我有一个连接到office 365的powershell脚本。这只是微软网站的标准 我可以运行这些命令中的任何一个来删除许可证并从powershell转换为共享邮箱 Get-Mailbox -identity engineering@domainname.com | set-mailbox -type “Shared” $MSOLSKU = (Get-MSOLUser -UserPrincipalName engineering@domainname.com).Licenses[0]

因此,我有一个连接到office 365的powershell脚本。这只是微软网站的标准

我可以运行这些命令中的任何一个来删除许可证并从powershell转换为共享邮箱

Get-Mailbox -identity engineering@domainname.com | set-mailbox -type   “Shared”

$MSOLSKU = (Get-MSOLUser -UserPrincipalName engineering@domainname.com).Licenses[0].AccountSkuId
Set-MsolUserLicense -UserPrincipalName engineering@domainname.com -RemoveLicenses $MSOLSKU
我曾尝试使用get content从txt文件中获取用户,但似乎无法实现。如有任何建议,我们将不胜感激,并提前表示衷心感谢

谢谢


SG

您正在询问如何使用foreach对象或foreach循环?这可以被认为是直截了当的。除了结束这个问题,你能告诉我们你尝试了什么吗?我们可以潜在地解释出错误的地方我尝试了第一个问题:ForEach($user in(get content“c:\test\users.txt”){get Mailbox-identity$user | set Mailbox-type“Shared”}