首页 文章

PowerShell:Azure AD模块,批量启用O365命令错误

提问于
浏览
0

首先发布这里..我有一个PowerShell命令的小问题 . 我正在使用Azure AD模块并尝试使用CSV文件和本指南批量启用O365用户:http://www.powershellmagazine.com/2012/04/23/provisioning-and-licensing-office-365-accounts-with-powershell/

我已经完成了所有问题并且可以使用该文章中概述的方法启用单个用户,但在尝试批量启用时,我得到以下内容:

命令:

Import-CSV -Path sapusers_sample.csv | ForEach-Object {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses wcs1:STANDARDWOFFPACK -LicenseOptions $options}

错误:

Set-MsolUserLicense : You must provide a required property: Parameter name: UsageLocation

$options 只是一个包含已禁用计划的变量,我们不希望用户启用Exchange)

奇怪的是,在阅读 Set-MsolUserLicense 的帮助文本时,没有列出 UsageLocation 参数 . 当我尝试添加它时,例如 Set-MsolUserLicense -UsageLocation US ,PS返回以下内容:

Set-MsolUserLicense : A parameter cannot be found that matches parameter name 'UsageLocation'

所以...是PS要求 Set-MsolUserLicense 的参数不存在吗?或者我误解了这个......任何帮助都表示赞赏 - 谢谢!!!!

戴夫

1 回答

  • 0

    Office 365要求用户的使用位置确定可用的服务 . 因此, UsageLocation 是用户的属性,可以使用 Set-MsolUserNew-MsolUser-UsageLocation 参数进行设置:

    Set-MsolUser -UserPrincipalName bob@contoso.com -UsageLocation "US";
    

    一旦've set the user' s UserLocation ,您应该能够为该用户分配许可证 .

    如果所有用户的使用位置相同,则可以直接将其包含在__54444_循环中:

    Import-CSV -Path sapusers_sample.csv | ForEach-Object {
        Set-MsolUser -UserPrincipalName $_.UserPrincipalName `
            -UsageLocation "US";
        Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName `
            -AddLicenses wcs1:STANDARDWOFFPACK `
            -LicenseOptions $options;
    }
    

    您也可以轻松地将“UsageLocation”列添加到输入CSV:

    Import-CSV -Path sapusers_sample.csv | ForEach-Object {
        Set-MsolUser -UserPrincipalName $_.UserPrincipalName `
            -UsageLocation $_.UsageLocation;
        Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName `
            -AddLicenses wcs1:STANDARDWOFFPACK `
            -LicenseOptions $options;
    }
    

相关问题