无需 GUI 即可激活远程桌面许可证服务器

无需 GUI 即可激活远程桌面许可证服务器

尝试自动化 Windows Server 2012 R2 的服务和配置安装。

我能够通过 Powershell Add-WindowsFeature RDS-Licensing、Add-WindowsFeature RDS-Licensing-UI 安装 RDS 许可证服务器 Windows 功能,但是服务器需要通过 Microsoft 激活,但我能够激活服务器的唯一方法是使用活动服务器向导: 在此处输入图片描述

是否有人知道如何通过 Powershell 或注册表设置激活服务器,然后在不使用向导的情况下安装我拥有的许可证?

答案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 获得帮助。

https://technet.microsoft.com/en-us/library/jj574158.aspx

相关内容