Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

"Cannot bind parameter 'ProductVersion'" error when you run New-Item cmdlet to install CAL in Windows Server 2016


View products that this article applies to.

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 AgreementNumber -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 

↑ Back to the top


Cause

This error is due to a parameter check issue in the New-Item cmdlet. Installing with New-Item is no longer supported.

↑ Back to the top


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)

 

↑ Back to the top


Keywords: cannot bind parameter new-item

↑ Back to the top

Article Info
Article ID : 4051997
Revision : 10
Created on : 2/5/2018
Published on : 2/5/2018
Exists online : False
Views : 705