Page 1 of 1

script to output results

Posted: Wed Aug 09, 2017 6:17 am
by lonwitness
I've written a script to disable office 365 plans and to export any failures.
Attached is the readout 'test' with a weird message.
Attached is the script and sample csv file.

Re: script to output results

Posted: Wed Aug 09, 2017 6:57 am
by pdearmen
This line here:

Code: Select all

$users| foreach-object {Set-MsolUser -UserPrincipalName $_.O365_UPN -UsageLocation $UsageLocation;Set-MsolUserLicense -
UserPrincipalName $_.O365_UPN -AddLicenses $AccountSkuId -LicenseOptions $licenseoptions} -ErrorAction Stop
Just based on formatting that's probably where you are getting your error. You should do something like

Code: Select all

Set-MsolUser -UserPrincipalName $_.O365_UPN -UsageLocation $UsageLocation; Set-MsolUserLicense `
-UserPrincipalName $_.O365_UPN -AddLicenses $AccountSkuId -LicenseOptions $licenseoptions
Use of the ` acts like a word wrap so you can continue the code onto the second line.