Solved

Enabling and configuring WinRM service on remote machine

Posted on 2014-02-21
4
262 Views
Last Modified: 2014-02-26
Hello,

I want to be able to manage my machines remotely using powershell. I know that in order to do this, I will need the WinRM service running and configured on these machines.

How can I accomplish this without having to remote into every machine to configure it?

Thanks.
0
Comment
Question by:LuiLui77
  • 2
4 Comments
 
LVL 29

Expert Comment

by:becraig
ID: 39878192
Create a scheduled task on each server:

This is assuming you have Admin permissions on each server.

$servers = (gc $serverList.txt)
$file = c:\localfile.bat
foreach ($COMPUTER in $servers)
{
copy $file \\$Computer\c$\temp\
psexec -u user -p password \\$computer cmd /c schtasks /create /tn enableWS2 /RL Highest /tr c:\temp\enable-ws.bat /sc once  /ST $starttime /ru $Username /rp $usrpwd /F
}

Open in new window


You bat or cmd file only needs to be

Enable-PSRemoting -Force


You may want to restart the computers once you know the task has been run.

You can verify with:
test-wsman -computername $computer

 
Once you verify it is working you can run this to remove the task:
psexec -u user -p password  \\$computer cmd /c schtasks /delete /tn enablePS /F
0
 
LVL 79

Expert Comment

by:David Johnson, CD, MVP
ID: 39878272
powershell Enable-PSRemoting -Force

Open in new window


otherwise it will fail with unknown command
0
 
LVL 29

Expert Comment

by:becraig
ID: 39878279
Thanks David I forgot to add powershell in front for the batch file.
0
 
LVL 39

Accepted Solution

by:
footech earned 500 total points
ID: 39878410
If you're in a domain, use Group Policy.  All the settings are in this link.
http://blogs.technet.com/b/heyscriptingguy/archive/2012/07/24/an-introduction-to-powershell-remoting-part-two-configuring-powershell-remoting.aspx

You're just setting the service to run automatically, configuring the listeners, and enabling the firewall rule (as seen in the first three images).
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
A quick guide on how to use Group Policy to create a custom power plan and set it active on Windows 7.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now