powershell-remoting

Parameters with double quotes are not properly passed to Scriptblock by ArgumentList

ε祈祈猫儿з 提交于 2019-12-06 02:44:51
问题 I'm writing generic powershell script to perform deployments on remote machines. I have hit one problem I can not overrun, and this problem is with parameters with double quotes in Scriptblock passed by ArgumentList I have something like this: $remoteAddress = "some-pc" $deploymentCommand = "D:\some path\Command.exe" $deploymentPackages = @(`"“package - one - external"`", `"“package - two - external"`", `"“package - three - internal"`") foreach ($deploymentPackage in $deploymentPackages) {

Powershell logging from invoke-command

☆樱花仙子☆ 提交于 2019-12-05 17:25:33
I have a script that includes a function for logging. The function writes log to $msg variable then writes the message to the screen. i can redirect this output to a .txt file for logging. I need to run the script to multiple servers using invoke-command and write the log output to a txt file on the computer running the script. I am trying to figure out how to output $msg in the write-log function from the PSSession and return it so I can create a master log file for all the servers. Should I create and populate a custom object? Not sure how to do that and get the results back from the remote

PSRemoting performance overhead with get-childItem

南笙酒味 提交于 2019-12-05 17:16:56
This completes in 2.3 minutes on LOCALSERVER: A: measure-command {$x = invoke-command {gci -recurse "C:\"}} This completes in 38.4 minutes on LOCALSERVER: B: measure-command {$x = invoke-command -comp LOCALSERVER {gci -recurse "C:\"}} Why is B so much slower? Is it because the "output is being serialized to XML and then reconstituted into objects again", as explained here , with B but not A? Or is something else going on? LOCALSERVER runs Windows 2008R2 with PS v3. In both cases $x.count is 98973. I was wondering about changing an existing script to use PSRemoting for file searches on remote

Error PSRemoting using Session and CredSSP

不问归期 提交于 2019-12-05 14:37:48
I use Windows 8.1 Enterprise 64 bit and Powershell 4.0. I want execute powershell remoting and using authentication CredSSP. I open Console Powershell, run as Administrator, and execute Enter-PSSession command to connect to remote computer. But I get error about connection. PS C:\Documents and Settings\kiquenet> Enter-PSSession -ComputerName DC -credential devrsg.com\Administrator Anyways, I test command from Windows XP and Windows 7, and connection is OK. PS C:\Documents and Settings\kiquenet> Enter-PSSession -ComputerName DC -credential devrsg.com\Administrator [dc]: PS C:\Users

How to access NoteProperties on the InputObject to a remoting session

六眼飞鱼酱① 提交于 2019-12-05 11:27:29
I'm having difficulty accessing PSObject s with NoteProperties defined, that are being passed through to a remote session via Invoke-Command . The reason I am constructing an object for this purpose is that I need access to two separate pieces of information in the remote session, but PowerShell only provides for a single InputObject . My code looks something like this: $sessionInput = new-object -TypeName System.Object $sessionInput | Add-Member -MemberType NoteProperty -Name NoteProperty1 -Value @("some", "value") $sessionInput | Add-Member -MemberType NoteProperty -Name NoteProperty2 -Value

Powershell 2.0 Remoting loading a .Net 4.0 dll

非 Y 不嫁゛ 提交于 2019-12-05 04:54:10
I am trying to load a .Net 4.0 assembly, using [Reflection.Assembly]::LoadFrom, inside of a remote Powershell 2.0 session. It works locally, due to a change I made to the powershell.exe.config file, but fails with a "This assembly is built by a runtime newer ..." exception in a remote session. Both machines involved have .Net 2.0 and 4.0, and have the powershell.exe.config change for the x86 and x64 bit powershell executables. I've also tried changing the server powershell registry keys: HKLM:\Software\Microsoft\Powershell\1\PowerShellEngine\RuntimeVersion HKLM:\Software\Wow6432Node\Microsoft

How to execute a powershell script available in remote machine?

安稳与你 提交于 2019-12-04 22:22:20
I was trying to execute a script in remote computer. I did " Enable-PSremoting " in the remote machine. I placed a script hello.ps1 in remote machine. [My client machine is Windows XP and remote computer is Windows 2003 ] Then from my client computer i was trying to execute the script. invoke-command -computer $MachineName -filepath "C:\hello.ps1" I got the following error. Invoke-Command : Cannot find path 'C:\hello.ps1' because it does not exist. I think it tries to find script from client machine. If i try to run invoke-command -computer $MachineName -command { C:\hello.ps1 } , It executes

Stop Powershell from exiting

让人想犯罪 __ 提交于 2019-12-04 16:04:53
问题 I know that there is that little -noexit switch for PowerShell. Is there anyway of staying in the shell without using that switch? In other words, I want a script command(s) that executes then leaves the shell open. 回答1: This script will not exit if you run it without arguments, e.g. by double-clicking on it: param($Work) # restart PowerShell with -noexit, the same script, and 1 if (!$Work) { powershell -noexit -file $MyInvocation.MyCommand.Path 1 return } # now the script does something #

How to remote execute an ELEVATED remote script in PowerShell

微笑、不失礼 提交于 2019-12-04 11:23:36
问题 I have two servers: serverA (windows 2003 server) serverB (windows 7) ServerA contains a folder with a batch file (deploy.bat) that needs to be executed from an elevated powershell prompt. In ServerA , if I run it from a normal prompt or powershell prompt it fails. If I run it from an elevated prompt it works. (run as administrator). The problem I have is when I try to execute batch file from serverB using a remote powershell execution. I am able to execute with this command: Invoke-Command

Parameters with double quotes are not properly passed to Scriptblock by ArgumentList

让人想犯罪 __ 提交于 2019-12-04 07:09:29
I'm writing generic powershell script to perform deployments on remote machines. I have hit one problem I can not overrun, and this problem is with parameters with double quotes in Scriptblock passed by ArgumentList I have something like this: $remoteAddress = "some-pc" $deploymentCommand = "D:\some path\Command.exe" $deploymentPackages = @(`"“package - one - external"`", `"“package - two - external"`", `"“package - three - internal"`") foreach ($deploymentPackage in $deploymentPackages) { invoke-command -ComputerName $remoteAddress -ScriptBlock { param ($deployCmd, $deployPackage) &