WINRM

WINRM

  • Comments 10

WINRM is the CLI interface to our WS-MGMT protocol. The neat thing about this is that you can call it from PowerShell to manage remote systems that don't have PowerShell installed on them (including Server Core systems and Raw hardware). I was trying some things out and encountered the following error:

PS> winrm
C:\Windows\System32\winrm.vbs(1034, 1) Microsoft VBScript runtime error: ActiveX component can't create object: 'WSMAN.InternalAutomation'

This is the second time that I've done something that made this problem come up. I'm working on a system that changes constantly so it is probably some side effect of something you'll never encounter. That said, I've run into it twice so I thought I would share the fix. This also documents the fix so if it happens to me again, I'll just use LiveSearch to find the solution J.

Run a PowerShell session with Admin Privs (I'm doing this on Vista):

PS> cd ${env:windir}/system32
PS> Regsvr32 WsmAuto.dll
PS> Regsvr32 WSManMigrationPlugin.dll

Do that and Bob's your Uncle.

BTW - you can do cool stuff with WINRM from PowerShell if you remember 2 things:

  1. You have to quote native code command switches that use ":"s
  2. You can cast XML to [XML] and then party

PS> winrm e wmi/root/cimv2/win32_service
Win32_Service
AcceptPause = false
AcceptStop = true
Caption = Application Experience
CheckPoint = 0
CreationClassName = Win32_Service
Description = Processes application compatibility cache requests for applications as
they are launched
DesktopInteract = false
DisplayName = Application Experience
ErrorControl = Normal
ExitCode = 0
InstallDate = null
Name = AeLookupSvc
PathName = C:\Windows\system32\svchost.exe -k netsvcs
ProcessId = 1108
ServiceSpecificExitCode = 0
ServiceType = Share Process
Started = true
StartMode = Auto
StartName = localSystem
State = Running
Status = OK
SystemCreationClassName = Win32_ComputerSystem
SystemName = JPSLAP11
TagId = 0
WaitHint = 0
<TOO MUCH STUFF>
PS>
# Apparently the WINRM folks think XML is "Pretty"
PS> winrm e wmi/root/cimv2/win32_service "-format:pretty"
<wsman:Results xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman/results">
<p:Win32_Service xsi:type="p:Win32_Service_Type" xmlns:xsi="http://www.w3.org/2001/XMLSch
ema-instance" xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Ser
vice" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common">
<p:AcceptPause>false</p:AcceptPause>
<p:AcceptStop>true</p:AcceptStop>
<p:Caption>Application Experience</p:Caption>
<p:CheckPoint>0</p:CheckPoint>
<p:CreationClassName>Win32_Service</p:CreationClassName>
<p:Description>Processes application compatibility cache requests for applications as
they are launched</p:Description>
<p:DesktopInteract>false</p:DesktopInteract>
<p:DisplayName>Application Experience</p:DisplayName>
<p:ErrorControl>Normal</p:ErrorControl>
<p:ExitCode>0</p:ExitCode>
<p:InstallDate xsi:nil="true"></p:InstallDate>
<p:Name>AeLookupSvc</p:Name>
<p:PathName>C:\Windows\system32\svchost.exe -k netsvcs</p:PathName>
<p:ProcessId>1108</p:ProcessId>
<p:ServiceSpecificExitCode>0</p:ServiceSpecificExitCode>
<MORE AND MORE>
PS>
$x=[xml](winrm e wmi/root/cimv2/win32_service "-format:pretty")
PS>
$x

Results
-------
Results


PS>
$x.results

wsman Win32_Service
----- -------------
http://schemas.dmtf.org/wbem/wsman... {AeLookupSvc, ALG, Appinfo, AppMgm...


PS>
$x.results.Win32_service |sort State,Name |ft -group State name,Caption
-auto



State: Running

Name Caption
---- -------
AeLookupSvc Application Experience
Appinfo Application Information
AppMgmt Application Management
ASFIPmon Broadcom ASF IP and SMBIOS Mailbox Monitor
<MORE AND MORE>


State: Stopped

Name Caption
---- -------
ALG Application Layer Gateway Service
aspnet_state ASP.NET State Service
clr_optimization_v2.0.50727_32 Microsoft .NET Framework NGEN v2.0...
<MORE AND MORE>

PS>

Cheers!

Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

Leave a Comment
  • Please add 8 and 4 and type the answer here:
  • Post
  • PingBack from http://msdnrss.thecoderblogs.com/2007/10/29/winrmexe/

  • Except that the WinRM executable is not an exe, but a HUGE (3270 line)VBScript :-)

    Just wondering how many lines would a WinRM.ps1 take... :-)

  • > Except that the WinRM executable is not an exe, but a HUGE (3270 line)VBScript :-)

    You are quite correct.  My error.

    I've updated the posting.

    Thanks for setting me straight!

    Jeffrey Snover [MSFT]

    Windows Management Partner Architect

  • Введение в WS-Management или WinRM

  • In order to use the results, you still need a priori knowledge of the key properties so you can extract the values and create the EPR.

    How do you avoid having to know the concrete sub-class that will be returned in order to walk-through the returned instances in a loop?

  • this is also handy (needed) for running winrm on a system that a) doesnt have it and b) you dont have install privileges on, or alternately, a portable winrm on usb.

  • WINRM - I seem to be in a loop. When I click Apply in System Startup, when it is set (checked) the Program stops - implying uncheck it and vice-versa. It (WINRM)always seems to be associated with local drive K which is my 'C' drive from my previous computer - which is a Rocket Fish cabinet, which I maintain to not lose old data. But it can't be checked and unchechecked at the same time, and that seems to be the loop I am in. Help

  • Since I am in this check - uncheck WINRM loop this is maybe not important yet - but how do I exit the Start Up Command module?

  • 2 options were checked when I enyered this Module I checked 3 others - results areDisable Net Logon; Disable Smart Card; Memory dispaly Option; Increase Ocon Cache size; and Disable  Low Disk Space Warning WERE checked. I ran the module, which ran very long, infact I went to bed. I have second thoughts about. I now have 2nd thoughts about disabling the Low disk warning message, but when I check only this one option it says that no options will be changed. How do I leave the other 4 options as they now are and only enable the Low Disk Warning Message?

  • Ha ha, I was once faced with what to call a formatting function in a python script I had years ago.

    The only thing I could think of was "PrettyPrint" :)

Page 1 of 1 (10 items)