Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PowerShell为单个用户分配多个o365许可证_Powershell_Office365 - Fatal编程技术网

使用PowerShell为单个用户分配多个o365许可证

使用PowerShell为单个用户分配多个o365许可证,powershell,office365,Powershell,Office365,我正在使用一个简单的Powershell脚本向O365添加新用户并分配许可证。然而,我试图一次向一个用户添加多个许可证 Powershell Connect-MsolService -Credential $UserCredential Import-Csv -Path "C:\Users\Jesse\Documents\Powershell\NewAccounts.csv" | foreach {New-MsolUser -DisplayName $_.DisplayName -FirstN

我正在使用一个简单的Powershell脚本向O365添加新用户并分配许可证。然而,我试图一次向一个用户添加多个许可证

Powershell

Connect-MsolService -Credential $UserCredential

Import-Csv -Path "C:\Users\Jesse\Documents\Powershell\NewAccounts.csv" | foreach {New-MsolUser -DisplayName $_.DisplayName -FirstName $_.FirstName -LastName $_.LastName -UserPrincipalName $_.UserPrincipalName -UsageLocation $_.UsageLocation -LicenseAssignment $_.AccountSkuId} | Export-Csv -Path "C:\Users\Jesse\Documents\Powershell\NewAccountResults.csv" -Verbose
.CSV

DisplayName,FirstName,LastName,UserPrincipalName,Usagelocation,AccountSkuId
Test Jesse,Tes,Jesse,test.jesse@(tenant).nl,NL,(tenant):EMS


对于本例,我想向测试用户添加EMS&ENTERPRISEPACK许可证。

您可以向CSV添加另一个文件:

DisplayName,FirstName,LastName,UserPrincipalName,Usagelocation,AccountSkuIdEMS, AccountSkuIdENTERPRISEPACK
Test Jesse,Tes,Jesse,test.jesse@(tenant).nl,NL,(tenant):EMS,(tenant):ENTERPRISEPACK
并调整脚本:

Import-Csv -Path "C:\Users\Jesse\Documents\Powershell\NewAccounts.csv" | foreach {New-MsolUser -DisplayName $_.DisplayName -FirstName $_.FirstName -LastName $_.LastName -UserPrincipalName $_.UserPrincipalName -UsageLocation $_.UsageLocation -LicenseAssignment $_.AccountSkuIdEMS,$_.AccountSkuIdENTERPRISEPACK} | Export-Csv -Path "C:\Users\Jesse\Documents\Powershell\NewAccountResults.csv" -Verbose