Questions tagged [powershell-remoting]

The ability to create a remote connection, in an other way than using WMI, is the most important difference between PowerShell v 1.0 and 2.0.

Host applications can use a PowerShell object to run commands that use WS-Management-based Windows PowerShell remoting to create a temporary or persistent connection to the remote computer. This includes establishing an interactive session with a single remote computer.

1238 questions
4
votes
2 answers

Prevent Password getting exposed (GetNetworkCredential method)

I am executing my PowerShell scripts in c# through PowerShell runspace. We wrap our credentials in the credential object. However, the password gets exposed when we write the below statement. $Credential = Get-Credential $Password =…
4
votes
1 answer

Import-Module in Invoke-Command

I'm trying to automate the setup of a domain controller with a DHCP server in a Hyper-V environment. Things go wrong when I try to install the DHCP server. Actually when I try to import the DhcpServer powershell module. This is the relevant code,…
Chumpy
  • 43
  • 1
  • 7
4
votes
1 answer

Runspace broke. (Remoting, WinRM, and Sharepoint )

So first, the following worked fine 3 days ago against the same sharepoint server, works fine against other sharepoint servers in the farm, and after I did something I’ll elaborate on later works fine again. But for 3 days, I could constantly break…
klumsy
  • 4,081
  • 5
  • 32
  • 42
4
votes
3 answers

Running winrs command from Team Build Hangs

I have a step in my TFS build workflow which attempts to invoke a command on a remote machine using winrs. I use an invoke process task and give it powershell as the command then pass in a script which contains something like winrs…
stimms
  • 42,945
  • 30
  • 96
  • 149
4
votes
0 answers

PowerShell incorrectly reports failure when running docker-compose in a remote session

I have this simple Docker Compose manifest version: '2' services: dummy: image: hello-world When I run it locally, I get the expected behavior / output. PS> docker-compose up -d; $?; $LASTEXITCODE Creating network "temp_default" with the…
Anthony Mastrean
  • 21,850
  • 21
  • 110
  • 188
4
votes
2 answers

unexpected token in expression or statement - powershell

## To run the script # .\get_status.ps1 -Hostname -Service_Action -Service_Name #$Hostname = "hostname" #$Service_Action = "Get-Service" #$Service_Name = "service_name" param( [string]$Hostname, …
4
votes
1 answer

register environment variables on remote computers in powershell

I am just trying to learn powershell and through some examples I found came up with the following script. I'm attempting to register some environment variables on the different servers. When I run it I get the error - Invoke-Command : A positional…
geoff swartz
  • 5,437
  • 11
  • 51
  • 75
4
votes
3 answers

How to run multiple commands via Invoke-Command on remote server

In the below example, only the Get-Process in my scriptblock is being executed. "deh" does not print for some reason Invoke-Command -ComputerName mycomputer -Credential $mycreds -ScriptBlock { Get-Process Write-Host "deh" } If I remove…
Eric Furspan
  • 742
  • 3
  • 15
  • 36
4
votes
3 answers

Starting a .exe file on a remote computer using powershell

Hey everyone I'm attempting to start a exe file on remote systems, we have an agent that runs to connect our website to our database and printers. It hangs occasionally, and requires us to remote in and/or go to the station and restart the…
4
votes
2 answers

Setting machine wide environment variable in Nano server

I started a remote session from VM host(desktop) to the guest VM having a Nano server(preview 5). I would like to update the PATH variable and make it effect machine wide(example: to put dotnet.exe in PATH to enable running portable apps). What I am…
Kiran
  • 56,921
  • 15
  • 176
  • 161
4
votes
2 answers

Functions & powershell remoting

I have a script that works fine but I want to improve my powershell knowledge and would like to know if there is an easier way to do this..... Part of my script connects to a sever and pulls bak a list of files and sizes on it and exports it to a…
andyw
  • 43
  • 2
4
votes
0 answers

Invoking remote command synchronously hangs

I am using the System.Management.Automation library to invoke PowerShell commands using a remote Runspace. So I create a PowerShell object and invoke a script as such: var remoteRunspace =…
4
votes
1 answer

Extremely slow Powershell remote execution?

Is there any way to speed up powershell remoting? Right now, to execute a "remote" command on my VM, it takes about 30-90 seconds just do do a simple hello world using Invoke-Command with credentials. If I run commands right after that initial…
droptic
  • 117
  • 2
  • 8
4
votes
3 answers

Run powershell script as local script if ComputerName is localhost or '.'

I have this script that should be able to run on both remote and localhost. It accepts -ComputerName as parameter with '.' (localhost) as default. Currently I am testing how to validate a new remote session and wrote a little cmdlet for it. Problem…
Oskar Emil
  • 356
  • 1
  • 6
  • 17
4
votes
1 answer

Using Connect-WSMan gives error: It cannot determine the content type of the HTTP response from the destination computer

I am trying to connect to an Exchange server via a wsman connection using PowerShell. The client server in question is in a Workgroup, while the Exchange server is in its own domain. I use the following command to try to connect to the…