LA_Admin
asked on
Powershell scripting in Office365
I have a list of users that I am attempting to reference so I can assign licenses. There is one variable that is throwing an error and I cant find the issue. Can anyone else take a whack at it and let me know what I am doing wrong?
$POWPPText = foreach ($user in $(Get-Content c:\users\user\desktop\test.txt)){Get-MsolUser $user.UserPrincipalName}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What is the error being thrown?
ASKER
The error being thrown was "Positional Parameters not found". I chose the above option as the answer because the last part of the script showed me that my thinking was flawed in how the script should use the variable.
I split my script up and used the above script as a guide, and I was able to run the script successfully.
Here is my sanitized script, to provide context.
Thanks everyone!
foreach($user in $users){
set-msoluserlicense -userprincipalname $user -addlicenses AccountSkuID:XXXXXXXXX
}
I split my script up and used the above script as a guide, and I was able to run the script successfully.
Here is my sanitized script, to provide context.
# Project Online with ProjectPro users
$POPPUsers = Get-Content c:\users\user\desktop\test.txt
# ProjectOnline with Project Pro Variable
$ProjOnProjPro = New-MsolLicenseOptions -AccountSkuId contoso:PROJECTONLINE_PLAN_2 -DisabledPlans SHAREPOINTWAC, SHAREPOINTENTERPRISE
# ProjectOnline With Project Pro users text file
Set-MsolUserLicense -UserPrincipalName $POPPUsers -RemoveLicenses contoso:projectonline_plan_1
foreach($user in $POPPUsers){
Set-MsolUserLicense -UserPrincipalName $POPPUsers -AddLicenses contoso:ProjectOnline_Plan_2 -LicenseOptions $ProjOnProjPro
}
Thanks everyone!