Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2314

Executing a remote command using powershell

$
0
0

Hi!


I'd like to run a command on a remote computer using Windows 7. So far I've come to the conclusion, that powershell should be the way to go. As a first example, I'd simply like to start the file manager "Explorer" on the remote machine. After setting permissions, I'm able to run somehting like the following successfully:

PS C:\Users\hans> Invoke-Command -computername 192.168.123.227 -Credential wurst {Get-UICulture}

LCID             Name             DisplayName                                PSComputerName
----             ----             -----------                                --------------
1031             de-DE            Deutsch (Deutschland)                      192.168.123.227

So far - ok. Permissions seem to be correct and I am able to exectue remote commands. But I can't get the explorer to run. I've tried several different methods, for example by using a script, that I run remotely. The content of my powershell-script is the following:

Invoke-Expression -Command:"C:\Windows\explorer.exe"
I am calling this script using the following command line:

Invoke-Command -computername 192.168.123.227 -Credential wurst -FilePath c:\test.ps1
test.ps1 is saved on my local machine in C:\

Calling the command mentioned simply returns, but there is nothing to see on the remote machine. If I call a script with the same content on the remote machine with no remote administration - meaning sitting in front of it and using its own powershell - i get an explorer opened.

What am I doing wrong? Is there a final step I need to do in order to start a program remotely? All the examples found on http://technet.microsoft.com/en-us/library/hh849719.aspx did not help me.

Any help would be appreciated.

Best regards,

Dennis


Viewing all articles
Browse latest Browse all 2314

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>