WINRM

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