Welcome to MSDN Blogs Sign in | Join | Help

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

Published Tuesday, October 30, 2007 1:01 AM by PowerShellTeam

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# MSDN Blog Postings &raquo; WINRM.exe

Monday, October 29, 2007 9:00 PM by MSDN Blog Postings » WINRM.exe

# re: WINRM.exe

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... :-)

Monday, October 29, 2007 10:28 PM by jachymko

# re: WINRM

> 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

Monday, October 29, 2007 11:21 PM by PowerShellTeam

# WS-Management или WinRM

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

Tuesday, January 22, 2008 11:03 AM by Илья Сазонов

# limitations

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?

Wednesday, May 07, 2008 12:58 PM by not sure its enough

# re: WINRM

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.

Tuesday, July 21, 2009 5:21 PM by contriver

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker