I am using this powershell script below to license bulk users in office365 by .csv file. The script will only work if the .csv file header is:
UserPrincipalName
[email protected]
But our .csv is formatted: "Alias","UPN"
"myrobinson","[email protected]"
I want to know how to recode this script so it works with our .csv file?
$path= Import-Csv -Path "\\11.10.38.142\Users\myrobinson\NewUsers.csv"
foreach ($item in $path){
$MSOLUserName= $item.UserPrincipalName
$password = ConvertTo-SecureString "support@Jpsd" -AsPlainText –Force
$credential = New-Object System.Management.Automation.PsCredential("[email protected]",$password)
$cred = Get-Credential -cred $credential
Import-Module MSOnline
Connect-Msolservice -cred $cred
$AccountSkuId = "jpsd:STANDARDWOFFPACK_FACULTY"
$UsageLocation = "US"
$LicenseOptions = New-MsolLicenseOptions -AccountSkuId $AccountSkuId
Set-MsolUser -UserPrincipalName $MSOLUserName -UsageLocation $UsageLocation
Set-MsolUserLicense -UserPrincipalName $MSOLUserName -AddLicenses
$AccountSkuId -LicenseOptions $LicenseOptions
}