locked
Setting WinRM Remotely RRS feed

  • Question

  • Hi All,

    First time user of this forum, so please don't hate me if I've posted this in the wrong place or missed something.

    We've just reinstalled a bunch of PCs with Windows XP Pro using RIS/WDS and included the WinRM installation in the image build.  I'm aware that you then have to run "WinRM Quickconfig" and hit "y" twice to set up the WinRM service.  However, we've not run that command on the vast majority of our PCs, so I want to run it remotely across a number of machines.

    I've wrote a quick batch file (included below), which uses PsExec to push the commands using my admin credentials.  Each of the commands works - apart from the line "winrm create winrm/config/listener?Address=*+Transport=HTTP".  As soon as my script gets to this line, the batch file starts to loop and never completes.

    If I run these commands sat directly at the local PC, it works without fail.  Only seems to be a problem running remotely.

    set LISTFILE11=c:\PSScripts\Replies.txt
    for /F %%a in ('type "%LISTFILE11%"') do (psexec \\%%a -u <user> -p <password> -n 20 -c c:\Deploy\WinRM.cmd)
    set LISTFILE11=

    WinRM.cmd below:

    sc config "WinRM" start= auto
    net start WinRM
    winrm create winrm/config/listener?Address=*+Transport=HTTP
    netsh firewall add portopening TCP 80 "Windows Remote Management"

    Unfortunately, I'm unable to set a GPO to switch on the listener on the PCs (our parent company won't allow us to change/manage our own GPOs outside of their security policies).  I've tried running these commands from a telnet console too, but face similar problems.

    There must be an easier way to do this, but I've been unable to find an answer.  If anyone can help, it would be vastly appreciated.

    Thanks

    Thursday, August 12, 2010 4:26 PM

Answers

  • It's a classical case of the dog biting its own tail. The batch file invokes winrm.exe but the batch file is also called "winrm". You must give it a different name, e.g. winrmbat.bat. You should also add a full path specification for winrm.exe in order to make sure that Windows can find it.
    • Proposed as answer by hoeyshane Friday, August 13, 2010 1:35 AM
    • Marked as answer by IamMred Tuesday, August 17, 2010 10:35 PM
    Thursday, August 12, 2010 4:37 PM