Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Enabling and configuring WinRM service on remote machine

Posted on 2014-02-21
4
Medium Priority
?
277 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 84

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 41

Accepted Solution

by:
footech earned 2000 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

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

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

There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

824 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