Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Yet one more attempt at automate licensing of Exchange

$
0
0

I've been trying to automate the licensing of Exchange 365 and Lync for the benefit of our sub-admins who aren't global admins.  Normally I manually run a script like:

$License =New-MsolLicenseOptions -AccountSkuId dcccd:STANDARDWOFFPACK_FACULTY -DisabledPlans:SHAREPOINTWAC_EDU,SHAREPOINTSTANDARD_EDU
Set-MsolUserLicense -UserPrincipalName newuser@dcccd.edu -addlicenses dcccd:STANDARDWOFFPACK_FACULTY -LicenseOptions $License

I'm wanting to use the automation.dll and have everything working up to the point of actually invoking the script.  Initially I tried working through AddCommand but the presence of the variable complicated it for me so I switched to "AddScript" with the following as the script:

script = "New-Variable -Name License\r\n" +
"Set-Variable -name License -Value \"New-MsolLicenseOptions -AccountSkuId dcccd:STANDARDWOFFPACK_FACULTY -DisabledPlans:SHAREPOINTWAC_EDU,SHAREPOINTSTANDARD_EDU\"\r\n" +
"Set-MsolUserLicense -UserprincipalName " + userName +
" -addLicenses dcccd:STANDARDWOFFPACK_FACULTY -LicenseOptions $License";

When invoked I get two errors, the first of which I can ignore.  The second one is:

Cannot bind parameter 'LicenseOptions'. Cannot convert the "New-MsolLicenseOptions -AccountSkuId dcccd:STANDARDWOFFPACK_FACULTY -DisabledPlans:SHAREPOINTWAC_EDU,SHAREPOINTSTANDARD_EDU" value of type "System.String" to type "Microsoft.Online.Administration.LicenseOption".

Any promising way to handle this?


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>