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
3
votes
3 answers

Powershell bug where external commands silently fail

I have a complex powershell script that uses remoting and does a lot of file copying and loading and unloading of powershell modules. Within the script I use robocopy to move only changes files and anything works OK. However, every now and then the…
TheCodeKing
  • 19,064
  • 3
  • 47
  • 70
3
votes
2 answers

Modifying remote variables inside ScriptBlock using Invoke-Command

Is it possible to modify remote variables? I am trying to do something like the following: $var1 = "" $var2 = "" Invoke-Command -ComputerName Server1 -ScriptBlock{ $using:var1 = "Hello World" $using:var2 = "Goodbye World" } When I try this I get…
3
votes
0 answers

Invoke-SqlCmd2 in New-PSSession using 'NT AUTHORITY\ANONYMOUS LOGON' instead of Windows account (no remoting)

I am attempting to run a powershell script utilizing Invoke-SqlCmd2. For various reasons, I need to execute the sql as a specific Windows account which I have the credentials for. The initial process that executes is not running as the domain…
reidLinden
  • 4,020
  • 4
  • 31
  • 46
3
votes
1 answer

Local New-PSSession fails in official powershell linux based docker images

Running powershell core using docker (official microsoft images), I am trying to set up a local session in my script so I can later execute code in that session. I have tried using the following Linux…
3
votes
2 answers

Terraform azurerm_virtual_machine_extension error "extension operations are disallowed"

I have written a Terraform template that creates an Azure Windows VM. I need to configure the VM to Enable PowerShell Remoting for the release pipeline to be able to execute Powershell scripts. After the VM is created I can RDP to the VM and do…
Dar
  • 383
  • 1
  • 5
  • 16
3
votes
1 answer

Using Invoke-Command to run Start-Process in an elevated session

As a precursor to running an installation file on several remote servers, I need to update the Powershell setting MaxMemoryPerShellMB. This requires running a PS session as Administrator on the remote server. I have been trying to run Invoke-Command…
3
votes
1 answer

PowerShell RemoteException incosistency when run via remote runspace

I've got this demo-script, which I put into a Jenkins job: Write-Host "##############################################" $ErrorActionPreference = "Stop" Write-Host "ErrorActionPreference: $ErrorActionPreference" Write-Host "whoami:…
mwallner
  • 985
  • 11
  • 23
3
votes
0 answers

Join Docker swarm manager

I user docker for Windows 10 and I try to use swarm, but I can't add a worker to the sarm. I manage to create a manager like this : docker swarm init --advertise-addr my-ip-addr:2377 Then I have this answer : Swarm initialized: current node…
Camilledhn
  • 33
  • 3
3
votes
2 answers

Powershell restrict Remote access on Host

I have three windows 2008 R2 servers; DEV, UAT and Live. I am deploying web apps between these servers, including IIS setup and config and database backup and restore via a PowerShell script. I use a powershell remote session. I would like to…
Dave Blue
  • 33
  • 1
  • 3
3
votes
2 answers

Android Client for Powershell remote scripting?

Anyone know of a good client for Powershell remote scripting on a local network? I understand WinRM is required on the client to enable remote scripting. WinRM is "The Windows Remote Management (WinRM) is the Microsoft implementation of…
dr3x
  • 917
  • 2
  • 14
  • 26
3
votes
1 answer

Capture Write-Host output and exit code from Invoke-Command on a Remote System

I have a script located on a remote system. On the server "web12" under C:\tmp\hgttg.ps1: Write-Host "Don't Panic" exit 42 I invoke this script from my local box (both systems running v4.0) using Invoke-Command: $svr = "web12" $cmd =…
3
votes
1 answer

Access denied while running Windows Update using Powershell's Invoke-Command

I've been trying to setup a Powershell module that would remotely call Windows/Microsoft update on a server using Invoke-Command, then process the updates, and send everything back to the calling server so it can send an email report. My issue comes…
3
votes
2 answers

Azure Custom Script Extension. Execute script as another user

I'm using command1.ps1 script to install Azure Custom Script Extension on the target VM and execute command2.ps1. command2.ps1 is supposed to run a script (that is inside ScriptBlock) as domain administrator (hence -Credential $Credentials). When I…
3
votes
1 answer

Import-PSSession Error when called in a function

I have encountered some interesting behavior with Import-PSSession. I am trying to establish a PSSession to an Exchange 2013 server and import all the cmdlets. This works fine when ran manually: $session = New-PSSession -ConfigurationName…
RJ DeVries
  • 158
  • 1
  • 1
  • 7
3
votes
1 answer

Getting Enter-PSHostProcess behavior via PSSessionConfiguration file

Scenario: Windows service with Powershell host embedded into it. Single runspace is allocated at startup. Multi-dll solution. Requirement: Need to access .NET classes inside running service. From a local Powershell instance using…