Solved

Enabling and configuring WinRM service on remote machine

Posted on 2014-02-21
4
261 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 28

Expert Comment

by:becraig
Comment Utility
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 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
powershell Enable-PSRemoting -Force

Open in new window


otherwise it will fail with unknown command
0
 
LVL 28

Expert Comment

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

Accepted Solution

by:
footech earned 500 total points
Comment Utility
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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…

771 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

15 Experts available now in Live!

Get 1:1 Help Now