spassen
spassen

Reputation: 1580

Powershell remote access denied

I am trying to start a service on a remote computer using the following command on the cmdlet:

(Get-WmiObject -computer atl-fs-01 Win32_Service -Filter "Name='Alerter'").InvokeMethod("StartService",$null)

When I run the command I get the error Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)). After some research it appears I need to set my username and password, but I cannot find anything that allows me to set these prior to accessing the remote computer. I also plan on making a script for this so I don't have to type out everything on the command line. PowerShell code for setting user and password would be helpful as well. Thanks.

Upvotes: 3

Views: 7846

Answers (2)

Rich Turner
Rich Turner

Reputation: 11014

Chapter 13 (page 502) of Bruce Payette's (UTTERLY AWESOME) "Windows Powershell in Action, Second Edition" comprehensively covers configuration of remote Powershell admin. If you've not already asked Santa for a copy of this wonderful book, DO SO NOW! :)

In case you are in a hurry:

MSDN (and other sources) have some good documentation on how to

  1. Enable remoting to a remote server
  2. Connect from your local server to your remote server & execute commands

HTH.

Upvotes: 5

supermem613
supermem613

Reputation: 606

You need to pass in the credential object (created with Get-Credential) using the "-Credential" switch.

See this MSDN article for more information and an example.

Upvotes: 5

Related Questions