Quantcast
Channel: Email and calendar - Recent Threads
Viewing all articles
Browse latest Browse all 12880

new-msollicenseoptions is not recognized as a name of command on powershell version 3

$
0
0

Hi,

My system has been installed with new powershell version 3. The below script i can ran in powershell version 2 installed on other system. But after googling i have find the command to switchover to version 2 from version 3. i.e. powershell -version 2. after running this command my powershell is running in versioin 2. But i cannot run the script.


###############################################################################

#***********************************************************************************
#|FILE NAME
#|Activate-MSOlUserLicense.ps1

param(
[Parameter(ValueFromPipelineByPropertyName=$true, Mandatory=$true)]
[System.String]$UserUPN,
[Parameter(ValueFromPipelineByPropertyName=$true, Mandatory=$false)]
[bool]$LyncEnabled = $True,
[Parameter(ValueFromPipelineByPropertyName=$true, Mandatory=$false)]
[bool]$SharePointEnabled = $True,
[Parameter(ValueFromPipelineByPropertyName=$true, Mandatory=$False)]
[Bool]$ExchangeEnabled = $True,
[Parameter(ValueFromPipelineByPropertyName=$true, Mandatory=$False)]
[System.String]$UsageLocation = "IN"
)


# Change SKUID with the proper value
# You could use Get-MsolAccountSku to get SKU names
$AccountSkuId = "axa365:STANDARDPACK"
# ServicePlan
# -----------
# MCOSTANDARD
# SHAREPOINTSTANDARD
# EXCHANGE_S_STANDARD
$DisabledPlans = @()
if (!$LyncEnabled){$DisabledPlans += "MCOSTANDARD"}
if (!$SharePointEnabled){$DisabledPlans += "SHAREPOINTSTANDARD"}
if (!$ExchangeEnabled){$DisabledPlans += "EXCHANGE_S_STANDARD"}


$LicenseOptions = New-MsolLicenseOptions -AccountSkuId $AccountSkuId -DisabledPlans $DisabledPlans


If (((!$LyncEnabled) -and (!$SharePointEnabled) -and (!$ExchangeEnabled)) -and (Get-MsolUser -UserPrincipalName $UserUPN).IsLicensed){
# No services are assigned for user: Disable License
#Out-Log ("Removing License from user: " + $UserUPN) 3
# Commented to avoid license removal
# Set-MsolUserLicense -UserPrincipalName $UserUPN -RemoveLicenses $AccountSkuId
} else {
If ((Get-MsolUser -UserPrincipalName $UserUPN).IsLicensed){
# User is already licensed, Apply Services changes
#Out-Log ("Applying License changes to user: " + $UserUPN) 3
Set-MsolUserLicense -UserPrincipalName $UserUPN -LicenseOptions $LicenseOptions
} else {
# User is NOT already licensed, Activate license
#Out-Log ("Assigning new License to user: " + $UserUPN) 3
Set-MsolUser -UserPrincipalName $UserUPN -UsageLocation $UsageLocation
Set-MsolUserLicense -UserPrincipalName $UserUPN -AddLicenses $AccountSkuId -LicenseOptions $LicenseOptions
}
}











Viewing all articles
Browse latest Browse all 12880

Trending Articles



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