答案1
此代码应该可以处理您的问题中通过 PowerShell 激活许可证服务器的部分,并可能为其余部分提供思路。
# ----------------------------------------------------------------------------------------------------------------
function log-info($data)
{
#$data = "$([DateTime]::Now):$($data)"
write-host ($data | out-string)
}
function main()
{
$licenseServer='localhost'
$companyInformation = @{}
$companyInformation.FirstName="Suzy"
$companyInformation.LastName="Sample"
$companyInformation.Company="Independent Consolidators"
$companyInformation.CountryRegion="United States"
activate-licenseServer $licenseServer $companyInformation
}
# ----------------------------------------------------------------------------------------------------------------
function activate-licenseServer($licServer, $companyInfo)
{
$licServerResult = @{}
$licServerResult.LicenseServerActivated = $Null
$wmiClass = ([wmiclass]"\\$($licServer)\root\cimv2:Win32_TSLicenseServer")
$wmiTSLicenseObject = Get-WMIObject Win32_TSLicenseServer -computername $licServer
$wmiTSLicenseObject.FirstName=$companyInfo.FirstName
$wmiTSLicenseObject.LastName=$companyInfo.LastName
$wmiTSLicenseObject.Company=$companyInfo.Company
$wmiTSLicenseObject.CountryRegion=$companyInfo.CountryRegion
$wmiTSLicenseObject.Put()
$wmiClass.ActivateServerAutomatic()
$licServerResult.LicenseServerActivated = $wmiClass.GetActivationStatus().ActivationStatus
log-info "activation status: $($licServerResult.LicenseServerActivated) (0 = activated, 1 = not activated)"
}
# ----------------------------------------------------------------------------------------------------------------
function deactivate-licenseServer($licServer)
{
$wmiClass = ([wmiclass]"\\$($licServer)\root\cimv2:Win32_TSLicenseServer")
$wmiClass.DeactivateServerAutomatic()
}
# ----------------------------------------------------------------------------------------------------------------
main
答案2
从下面的链接可以看出,服务器核心安装支持的与 RDP 相关的唯一角色是远程桌面服务连接代理,通常不受支持并不意味着它将不起作用,但可能更难做到,最后如果您遇到任何问题,您可能无法从 Microsoft 获得帮助。