Solved

Enabling and configuring WinRM service on remote machine

Posted on 2014-02-21
4
266 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 80

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 40

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article will help you understand what HashTables are and how to use them in PowerShell.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.

820 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