Remote Desktop Service は、非常に優れた機能です。
さて今回は、 以下のような状況の対処に関して PowerShell でズバッと解決してみましょう。
- WorkGroup環境に Remote Desktop License Server をインストールし、 Remote Desktop CAL を追加して動作も出来た!
- Server Managerを起動すると 「ライセンスモードは構成されていません」と表示される
- RD ライセンス診断機能でも同様に「ライセンスモードは構成されていません」
なんだか、 Domain が前提だから などという そういうことじゃないんだよ 回答もあるようですが、 WorkGroup でも問題ありません。
RDライセンス診断機能にて「ライセンスモードは構成されていません」との報告が出る
今回そのやり方を紹介します。
コード
まずは結論から。
- Remote Desktop License Manger など最低限必要なモジュールを入れて、 Remote Desktop CAL まで入力した状態とします。
- ここで、以下のコードを入力します。
(Get-WmiObject -Class Win32_TerminalServiceSetting -Namespace root\cimv2\TerminalServices) #モードが5
(Get-WmiObject -Class Win32_TerminalServiceSetting -Namespace root\cimv2\TerminalServices).ChangeMode(4)
(Get-WmiObject -Class Win32_TerminalServiceSetting -Namespace root\cimv2\TerminalServices) #モードが4
New-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\TermService\Parameters\LicenseServers" -Name SpecifiedLicenseServers -Value "localhost" -PropertyType MultiString #localhostをサーバーに指定
Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\TermService\Parameters\LicenseServers" -Name SpecifiedLicenseServers #サーバー設定の確認
- RD ライセンス診断機能 で確認
エラーが無くなっているのが確認できるはずです。
簡単に説明
コードのそれぞれを軽く説明します。
以下は現在の TerminalService のモードを表示します。
(Get-WmiObject -Class Win32_TerminalServiceSetting -Namespace root\cimv2\TerminalServices)
エラーが出ていた時は以下の結果のはずです。
__GENUS : 2
__CLASS : Win32_TerminalServiceSetting
__SUPERCLASS : CIM_Setting
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_TerminalServiceSetting.ServerName="SERVERNAME"
__PROPERTY_COUNT : 53
__DERIVATION : {CIM_Setting, CIM_ManagedSystemElement}
__SERVER : SERVERNAME
__NAMESPACE : root\cimv2\TerminalServices
__PATH : \\WHITE-DEPLOY-IP\root\cimv2\TerminalServices:Win32_TerminalServiceSetting.ServerName="SERVERNAME"
ActiveDesktop : 0
AllowTSConnections : 1
Caption :
DeleteTempFolders : 1
Description :
DirectConnectLicenseServers :
DisableForcibleLogoff : 1
EnableAutomaticReconnection : 1
EnableDFSS : 1
EnableDiskFSS : 1
EnableNetworkFSS :
EnableRemoteDesktopMSI : 1
FallbackPrintDriverType : 0
GetCapabilitiesID : 196608
HomeDirectory :
InstallDate :
LicensingDescription :
LicensingName :
LicensingType : 5
LimitedUserSessions : 0
Logons : 0
Name :
NetworkFSSCatchAllWeight :
NetworkFSSLocalSystemWeight :
NetworkFSSUserSessionWeight :
PolicySourceAllowTSConnections : 0
PolicySourceConfiguredLicenseServers : 0
PolicySourceDeleteTempFolders : 0
PolicySourceDirectConnectLicenseServers : 0
PolicySourceEnableAutomaticReconnection : 0
PolicySourceEnableDFSS : 0
PolicySourceEnableRemoteDesktopMSI : 0
PolicySourceFallbackPrintDriverType : 0
PolicySourceHomeDirectory : 0
PolicySourceLicensingType : 0
PolicySourceProfilePath : 0
PolicySourceRedirectSmartCards : 0
PolicySourceSingleSession : 0
PolicySourceTimeZoneRedirection : 0
PolicySourceUseRDEasyPrintDriver : 0
PolicySourceUseTempFolders : 0
PossibleLicensingTypes : 12
ProfilePath :
RedirectSmartCards : 1
ServerName : SERVERNAME
SessionBrokerDrainMode : 0
SingleSession : 1
Status :
TerminalServerMode : 1
TimeZoneRedirection : 0
UseRDEasyPrintDriver : 1
UserPermission : 0
UseTempFolders : 1
PSComputerName : SERVERNAME
これを、以下のコードで 4に変更します。
(Get-WmiObject -Class Win32_TerminalServiceSetting -Namespace root\cimv2\TerminalServices).ChangeMode(4)
このように表示されたかと思います。
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0
PSComputerName :
再度、現在の TerminalService のモードを表示します。
(Get-WmiObject -Class Win32_TerminalServiceSetting -Namespace root\cimv2\TerminalServices)
今度はこのように変わります。
__GENUS : 2
__CLASS : Win32_TerminalServiceSetting
__SUPERCLASS : CIM_Setting
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_TerminalServiceSetting.ServerName="SERVERNAME"
__PROPERTY_COUNT : 53
__DERIVATION : {CIM_Setting, CIM_ManagedSystemElement}
__SERVER : SERVERNAME
__NAMESPACE : root\cimv2\TerminalServices
__PATH : \\WHITE-DEPLOY-IP\root\cimv2\TerminalServices:Win32_TerminalServiceSetting.ServerName="SERVERNAME"
ActiveDesktop : 0
AllowTSConnections : 1
Caption :
DeleteTempFolders : 1
Description :
DirectConnectLicenseServers :
DisableForcibleLogoff : 1
EnableAutomaticReconnection : 1
EnableDFSS : 1
EnableDiskFSS : 1
EnableNetworkFSS :
EnableRemoteDesktopMSI : 1
FallbackPrintDriverType : 0
GetCapabilitiesID : 196608
HomeDirectory :
InstallDate :
LicensingDescription : このポリシーでは、リモート デスクトップ セッション ホスト サーバーに接続する
ユーザー 1 人につきライセンスが 1 つ発行される必要があります。ライセンスをユ
ーザーに割り当てることは、現在管理されていません。
LicensingName : 接続ユーザー数
LicensingType : 4
LimitedUserSessions : 0
Logons : 0
Name :
NetworkFSSCatchAllWeight :
NetworkFSSLocalSystemWeight :
NetworkFSSUserSessionWeight :
PolicySourceAllowTSConnections : 0
PolicySourceConfiguredLicenseServers : 0
PolicySourceDeleteTempFolders : 0
PolicySourceDirectConnectLicenseServers : 0
PolicySourceEnableAutomaticReconnection : 0
PolicySourceEnableDFSS : 0
PolicySourceEnableRemoteDesktopMSI : 0
PolicySourceFallbackPrintDriverType : 0
PolicySourceHomeDirectory : 0
PolicySourceLicensingType : 0
PolicySourceProfilePath : 0
PolicySourceRedirectSmartCards : 0
PolicySourceSingleSession : 0
PolicySourceTimeZoneRedirection : 0
PolicySourceUseRDEasyPrintDriver : 0
PolicySourceUseTempFolders : 0
PossibleLicensingTypes : 12
ProfilePath :
RedirectSmartCards : 1
ServerName : SERVERNAME
SessionBrokerDrainMode : 0
SingleSession : 1
Status :
TerminalServerMode : 1
TimeZoneRedirection : 0
UseRDEasyPrintDriver : 1
UserPermission : 0
UseTempFolders : 1
PSComputerName : SERVERNAME
レジストリにLicenseServer は localhost (つまり自分だよ)と 追加します。
New-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\TermService\Parameters\LicenseServers" -Name SpecifiedLicenseServers -Value "localhost" -PropertyType MultiString
実行後、このように表示されます。
SpecifiedLicenseServers : {localhost}
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TermService\Parameters\LicenseServers
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TermService\Parameters
PSChildName : LicenseServers
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
最後に現在のレジストリ値を確認します。
Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\TermService\Parameters\LicenseServers" -Name SpecifiedLicenseServers
出来てますね!
SpecifiedLicenseServers : {localhost}
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TermService\Parameters\LicenseServers
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TermService\Parameters
PSChildName : LicenseServers
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
まとめ
Remote Desktop Service が Domain 環境でないと追加できないとか謎回答は辞めましょう。
Windows に置いて、 Domain は色々な基盤となるのは周知の通りですが、出来るものもありますので。
そしてレジストリの操作は PowerShell で。以前のようなレジストリファイルを作るなど不要ですと言い切りたいです。