Microsoft KB Archive/4051997: Difference between revisions
From BetaArchive Wiki
(Created page with "== "Cannot bind parameter 'ProductVersion'" error when you run New-Item cmdlet to install CAL in Windows Server 2016 == ''Windows Server 2016'' === Sympto...") |
(No difference)
|
Latest revision as of 14:04, 2 December 2020
"Cannot bind parameter 'ProductVersion'" error when you run New-Item cmdlet to install CAL in Windows Server 2016
Windows Server 2016
Symptom
When you try to install Client Access Licenses (CAL) for Windows Server 2016 by using the New-Item cmdlet and specify 5 as the ProductVersion parameter, the following error occurs:
PS > New-Item -path RDS:\LicenseServer\LicenseKeyPacks -InstallOption INSTALL -ConnectionMethod AUTO -L
icenseType agreement -ProductVersion 5 -AgreementNumber <i>AgreementNumber</i> -AgreementType X -ProductType X -LicenseCount x
New-Item : Cannot bind parameter 'ProductVersion'. Cannot validate argument "5" because it does not belong to the set
"0, 1, 2, 3, 4".
At line:1 char:1
+ New-Item -path RDS:\LicenseServer\LicenseKeyPacks -InstallOption INST ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (RDS:\LicenseSer...LicenseKeyPack>:String) [New-Item], ParameterBindingExce
ption
+ FullyQualifiedErrorId : ArgumentError,Microsoft.PowerShell.Commands.NewItemCommand
Cause
This error is due to a parameter check issue in the New-Item cmdlet. Installing with New-Item is no longer supported.
Resolution
To resolve this issue, use the InstallAgreementLicenseKeyPack method instead of New-Item. For example:
$KeyPack = Get-WMI Win32_TSLicenseKeyPack
$KPParameter = $KeyPack.GetMethodParameters("InstallAgreementLicenseKeyPack")
# AgreementType:
# SELECT=0, ENTERPRISE=1, CAMPUS=2, SCHOOL=3, SERVICE_PROVIDER=4, OTHER=5
$KPParameter["AgreementType"] = X
$KPParameter["sAgreementNumber"] = X
# ProductVersion:
# Win2000=0, Win2003=1, Win2008/2008R2=2, Win2012/2012R2=4, Win2016=5
$KPParameter["ProductVersion"] = X
# ProductType:
# Per Device=0, Per User=1, Internet=2, FREE=3, VDI=4, VDIP=5, VDI Suite=6
$KPParameter["ProductType"] = X
# LicenseCount
$KPParameter["LicenseCount"] = X
# Call InstallAgreementLicenseKeyPack().
$KeyPack.InvokeMethod("InstallAgreementLicenseKeyPack", $KPParameter, $null)