使用PowerShell为单个用户分配多个o365许可证
我正在使用一个简单的Powershell脚本向O365添加新用户并分配许可证。然而,我试图一次向一个用户添加多个许可证 Powershell使用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
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