Odedが言うように、を使用してリモートサーバーへの接続を開くには、ActiveDirectoryが必要ですServerManager。
管理者RDPアクセスサーバーがあると仮定すると、ビルドスクリプトでWinRMとリモートPowerShell(最新バージョンのWinRMに付属するPowerShell 2.0で最適に動作します)を使用するという代替手段があります。
Windowsリモート管理コマンドラインツール(Winrm.cmd)
ドメインにない2台のマシン用にWinRMをすばやく構成するには:
クライアント:
winrm quickconfig(「はい」とだけ言ってください)
winrm set winrm / config / Client / Auth'@ {Basic = "true"}'
:: HTTPSを使用していない場合にのみ、この次の行を実行します
winrm set winrm / config / Client'@ {AllowUnencrypted = "true"}'
winrm set winrm / config / Client'@ {TrustedHosts = "hostname_or_ip"}'
サーバ:
winrm quickconfig(「はい」とだけ言ってください)
winrm set winrm / config / Service / Auth'@ {Basic = "true"}'
::参照:httpsについてはhttp://support.microsoft.com/kb/2019527
winrm quickconfig -transport:https
:: HTTPSを使用しておらず、クレデンシャルの送信に満足している場合にのみこれを実行してください
::クリアテキストで。
winrm set winrm / config / Service'@ {AllowUnencrypted = "true"}'
ここで、いくつかの注意点があります。WinRMは、リスナーのポート5985および5986用にWindowsファイアウォールに穴を開けます(Windows Server 2003を実行している場合は、ポート80および443を使用します)。これはあなたの好みではないかもしれません、そしてあなたはおそらくそれを保護する方法についてあなたのネットワーク管理者に話すのが最善でしょう。
WinRMを構成したら、管理者グループのメンバーであるリモートサーバーでユーザーアカウントを構成する必要があります。完了したら、テストできます。ビルドサーバーの場合:
# the following line will prompt for a username and password, enter the name of the account
# you just configured on the IIS box
$cred = Get-Credential
# next test the connection
Test-WSMan -ComputerName <server_name_or_ip> -Authentication default `
-Credential $cred
すべてが良ければ、次の応答が表示されます。
wsmid:http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.x
SD
ProtocolVersion:http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
ProductVendor:Microsoft Corporation
ProductVersion:OS:6.1.7600 SP:0.0スタック:2.0
次に、リモートPowerShellセッションに接続します。
Enter-PSSession <server_name_or_ip_address> -Authentication default -Credential $cred
これが成功した場合は、リモートマシンにPowerShellプロンプトが表示されます。
次に、リモートPowerShellを使用して、PowerShell用のWebAdministration Providerをロードし、IISのさまざまな側面を心ゆくまで操作できます。
Windows PowerShell用のWeb管理(IIS)プロバイダー
リモートサーバーに接続するには、オブジェクトを提供する必要がありPSCredentialます。上記のように、これを使用して提供します。
$cred = Get-Credential
ただし、これには常に、ユーザー名とパスワードを提供するためにキーボードからの何らかの対話が必要です。明らかに、これは自動化されたCIには適していません。
ただし、パスワードはファイルに保存できます。これを行うには、以下を1回だけ(またはパスワードが変更されるたびに)実行します。
read-host -assecurestring | convertfrom-securestring | out-file C:\securestring.txt
PSCredential次に、リモートサーバーに対して認証するためにを作成する必要がある場合:
$username = "deployment_user"
$password = cat C:\securestring.txt | convertto-securestring
$cred = new-object -typename System.Management.Automation.PSCredential `
-argumentlist $username, $password
$serverNameOrIp = "192.168.1.1"
Enter-PSSession $serverNameOrIp -Authentication default -Credential $cred
上記のスクリプトは次のブログエントリから提供されていますが、記事が暗くなった場合に備えて、ここに保存するために複製しました。
プロンプトなしでPSCredentialsを使用する-GeeksWithBlogs(archive.org)
とにかく、リモートサーバーに接続したら、次のようなコマンドをさらに発行できます。
Import-Module WebAdministration
CD IIS:\Sites
等々。
このマシンがインターネットに面していて、アクセスする唯一の方法がインターネット経由である場合は、上記のほとんどに注意して取り組む必要があります。この場合は、WinRMポートをVPNのみに制限することを検討してください。