script to output results

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.
User avatar
Posts: 1
Joined: Wed Aug 09, 2017 5:46 am

script to output results

Post by lonwitness » Wed Aug 09, 2017 6:17 am

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.
(317 Bytes) Downloaded 6 times
(136 Bytes) Downloaded 9 times
(1.73 KiB) Downloaded 9 times

User avatar
Posts: 53
Joined: Sun Mar 03, 2013 12:42 pm

Re: script to output results

Post by pdearmen » Wed Aug 09, 2017 6:57 am

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.