Introduction to WinRM

Sharing is caring!

<div dir&equals;"ltr" style&equals;"text-align&colon; left&semi;"><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">WinRM provides a command line interface that can be used to perform common management tasks&comma; and also provides a scripting API so you can write your own Windows Scripting Host based scripts&period; In the background&comma; WinRM relies on management data provided by WMI&semi; however it makes the exchange of data much easier by utilizing the HTTP protocol&period; It uses SOAP &lpar;Simple Object Access Protocol&rpar; over HTTP and HTTPS&comma; and thus is considered a firewall-friendly protocol<&sol;span><&sol;p>&NewLine;<p><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">You must modify the WinRM configuration by running commands on the WinRM host machine&period; You can use the same machine as both the WinRM service and WinRM client&period;<&sol;span><br &sol;><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;"><&sol;span><&sol;p>&NewLine;<p><strong><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">Procedure<&sol;span><&sol;strong><br &sol;><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;"><&sol;span><br &sol;><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;"><br &sol;><&sol;span><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">1&period; Run the following command to set the default WinRM configuration values&period;<&sol;span><br &sol;><span style&equals;"background-color&colon; orange&semi; font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">&nbsp&semi;&nbsp&semi;&nbsp&semi; c&colon;&gt&semi; winrm quickconfig<&sol;span><&sol;p>&NewLine;<p><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">2&period; &lpar;Optional&rpar; Run the following command to check whether a listener is running&comma; and verify the default ports&period;<&sol;span><br &sol;><span style&equals;"background-color&colon; orange&semi; font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">&nbsp&semi;&nbsp&semi;&nbsp&semi; c&colon;&gt&semi; winrm e winrm&sol;config&sol;listener<&sol;span><br &sol;><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">The default ports are <span style&equals;"color&colon; red&semi;">5985<&sol;span> for HTTP&comma; and <span style&equals;"color&colon; red&semi;">5986<&sol;span> for HTTPS&period;<&sol;span><&sol;p>&NewLine;<p><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">3&period; Enable basic authentication on the WinRM service&period;<&sol;span><br &sol;><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">&nbsp&semi;&nbsp&semi;&nbsp&semi; a&period; Run the following command to check whether basic authentication is allowed&period;<&sol;span><br &sol;><span style&equals;"background-color&colon; orange&semi; font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi; &nbsp&semi; c&colon;&gt&semi; winrm get winrm&sol;config<&sol;span><br &sol;><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">&nbsp&semi; &nbsp&semi; b&period; Run the following command to enable basic authentication&period;<&sol;span><br &sol;><span style&equals;"background-color&colon; orange&semi; font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi; c&colon;&gt&semi; winrm set winrm&sol;config&sol;service&sol;auth &commat;&lbrace;Basic&equals;&&num;8221&semi;true&&num;8221&semi;&rcub;<&sol;span><&sol;p>&NewLine;<p><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">4&period; Run the following command to allow transfer of unencrypted data on the WinRM service&period;<&sol;span><br &sol;><span style&equals;"background-color&colon; orange&semi; font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">&nbsp&semi;&nbsp&semi;&nbsp&semi; c&colon;&gt&semi; winrm set winrm&sol;config&sol;service &commat;&lbrace;AllowUnencrypted&equals;&&num;8221&semi;true&&num;8221&semi;&rcub;<&sol;span><br &sol;><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;"><br &sol;><&sol;span><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">5&period; Enable basic authentication on the WinRM client&period;<&sol;span><br &sol;><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">&nbsp&semi;&nbsp&semi;&nbsp&semi; a&period; Run the following command to check whether basic authentication is allowed&period;<&sol;span><br &sol;><span style&equals;"background-color&colon; orange&semi; font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi; c&colon;&gt&semi; winrm get winrm&sol;config<&sol;span><br &sol;><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">&nbsp&semi;&nbsp&semi;&nbsp&semi; b&period; Run the following command to enable basic authentication&period;<&sol;span><br &sol;><span style&equals;"background-color&colon; orange&semi; font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi; c&colon;&gt&semi; winrm set winrm&sol;config&sol;client&sol;auth &commat;&lbrace;Basic&equals;&&num;8221&semi;true&&num;8221&semi;&rcub;<&sol;span><&sol;p>&NewLine;<p><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">6&period; Run the following command to allow transfer of unencrypted data on the WinRM client&period;<&sol;span><br &sol;><span style&equals;"background-color&colon; orange&semi; font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">&nbsp&semi;&nbsp&semi;&nbsp&semi; c&colon;&gt&semi; winrm set winrm&sol;config&sol;client &commat;&lbrace;AllowUnencrypted&equals;&&num;8221&semi;true&&num;8221&semi;&rcub;<&sol;span><br &sol;><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;"><br &sol;><&sol;span><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">7&period; If the WinRM host machine is in an external domain&comma; run the following command to specify the trusted hosts&period;<&sol;span><br &sol;><span style&equals;"background-color&colon; orange&semi; font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi; c&colon;&gt&semi; winrm set winrm&sol;config&sol;client &commat;&lbrace;TrustedHosts&equals;&&num;8221&semi;host1&comma; host2&comma; host3&&num;8243&semi;&rcub;<&sol;span><&sol;p>&NewLine;<p><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">8&period; Run the following command to test the connection to the WinRM service&period;<&sol;span><br &sol;><span style&equals;"background-color&colon; orange&semi; font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">&nbsp&semi;&nbsp&semi;&nbsp&semi; c&colon;&gt&semi; winrm identify -r&colon;http&colon;&sol;&sol;winrm&lowbar;server&colon;5985 -auth&colon;basic -u&colon;user&lowbar;name -p&colon;password -encoding&colon;utf-8<&sol;span><&sol;p>&NewLine;<p><strong><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">You might need to install WinRM depending on the operating system as listed in the following table&colon;<&sol;span><&sol;strong><br &sol;><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;"><&sol;span><br &sol;><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;"><br &sol;><&sol;span><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">Operating System&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi; WinRM<&sol;span><br &sol;><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">Windows 7&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi; WinRM 2&period;0 installed by default&period;<&sol;span><br &sol;><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">Vista&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi; WinRM 1&period;1 installed by default&period;<&sol;span><br &sol;><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;">Windows XP&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;WinRM not installed by default<&sol;span><br &sol;><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;"><br &sol;><&sol;span><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;"><br &sol;><&sol;span><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;"><br &sol;><&sol;span><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;"><br &sol;><&sol;span><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;"><br &sol;><&sol;span><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;"><br &sol;><&sol;span><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;"><br &sol;><&sol;span><span style&equals;"font-family&colon; Times&comma; &quot&semi;Times New Roman&quot&semi;&comma; serif&semi;"><&sol;span><&sol;div>&NewLine;

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.