We help IT Professionals succeed at work.

Powershell 2.0/3.0

sj77
sj77 asked
on
109 Views
Last Modified: 2017-05-02
Hi Experts,

I need help building a quick script that will engage a remote computers services to start and stop them.

I need it to work on both v 2.0 and 3.0.

EX:

RemotePCName =  DB1
ServiceName = FunGuy


Environments W7,8,10
Comment
Watch Question

K B

Commented:
$cred      = (Get-Credential)


Invoke-Command {start-service FunGuy –passthru} -Credential $cred –comp DB1,DB2

Open in new window



Enabling Remoting

Before a computer will accept remote PowerShell connections, the following list of items must be in place:

The WinRM service must be running.
There must be a WinRM listener that accepts connections from one or more IP addresses.
The Windows firewall must be configured to allow the WinRM connection.
There must be an enabled and properly configured PowerShell session.

source: http://windowsitpro.com/scripting/windows-powershell-20-remoting
"Batchelor", Developer and EE Topic Advisor
CERTIFIED EXPERT
Top Expert 2015
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.