powershell-remoting

How to Write-Verbose from Invoke-Command?

ε祈祈猫儿з 提交于 2019-11-28 13:17:57
In powershell Write-Verbose and the -Verbose flag are used to provide verbose information when commands are run in verbose mode. I am running some scripts remotely and would like to capture the verbose output output. However, Invoke-Command seems to not capture the verbose channel. PS:> Invoke-Command -ComputerName MY-COMPUTERNAME -Verbose { Write-Verbose "blah" } PS:> How do I capture verbose output when running remote scripts? Try it this way: Invoke-Command -ComputerName MY-COMPUTERNAME {$VerbosePreference='Continue'; Write-Verbose "blah" } Best thing I think you could do is create a

How do I host a Powershell script or app so it's accessible via WSManConnectionInfo? (like Office 365)

对着背影说爱祢 提交于 2019-11-28 06:53:59
The only ways I know to connect to a remote runspace include the following parameters WSManConnectionInfo connectionInfo = new WSManConnectionInfo(false, "localhost", 80, "/Powershell", "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential); or WSManConnectionInfo connectionInfo = new WSManConnectionInfo(false, "localhost", 5985, "/wsman", "http://schemas.microsoft.com/powershell/Microsoft.Powershell", credential); How do I set up my own custom Powershell object so I can expose it through HTTP? What are the correct parameters to use and how do I set them up? There are

Running remote GUI app in Powershell

眉间皱痕 提交于 2019-11-28 05:59:20
We have a custom comonent that wraps some of the functionality of powershell so it can be used frim BizTalk 2006. For most operations (checking a file path, copy or move a file) this works fine. However we have the need to fire up a GUI app remotely to do some processing. The component itself handles the connection to the remote box, all we have to do is set some parameters and then tell it to execute a command Start-Process -FilePath "path to exe" -ArgumentList "arguments for exe" -WorkingDirectory "workingdir for exe" The issue is this: If we run this from a powershell command line on the

Issues with Invoke-Command while installing softwares in remote server

六月ゝ 毕业季﹏ 提交于 2019-11-28 05:22:52
问题 I need to install an application in several remote servers in quiet mode. I have created a script (Installer.ps1) like below using Powershell v3.0: param( [String] $ServerNameFilePath = $(throw "Provide the path of text file which contains the server names"), [String] $InstallerFolderPath = $(throw "Provide the Installer Folder Path. This should be a network location"), [String] $UserName = $(throw "Provide the User Name"), [String] $Password= $(throw "Provide the Password") ) Function

How to check if a Powershell script is running remotely

瘦欲@ 提交于 2019-11-28 04:06:03
问题 I have a script that can be run either locally or remotely (via WinRM), however I would like it to behave slightly differently when run on a remote machine. I realise that I can pass in a switch to the script to identify whether it is running locally or remotely, but I want to know if it is possible for the script itself to detect whether it is running remotely? 回答1: Get-Host returns, amongst other information a Name : PS> (Get-Host).Name ConsoleHost PS> (Invoke-Command -ComputerName dev2

Launching background tasks in a remote session that don't get killed when the session is removed

寵の児 提交于 2019-11-27 23:52:44
问题 I have been using PsExec -d to launch console applications in a remote powershell session because I want these apps to run in the background while I perform some task. The problem is that I want the background applications to continue running even if I kill the remote powershell session with Remove-PSSession . What happens currently is once the remote powershell session is killed so are all the processes that were started with the help of PsExec -d . I'm guessing it has something to do with

“get-wmiobject win32_process -computername” gets error “Access denied , code 0x80070005”

天大地大妈咪最大 提交于 2019-11-27 15:11:32
问题 i'm trying to find processes on 3 terminal servers which have certain words in its $_.commandline property. Under my domain admin account, it worked OK. But I want this script to be usable for domain users, and doamin users get an error when runing this script. What should i do, so that domain users can run this script just like domain admins? Thanks in advance! Error: Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESS DENIED)) At N:\FindWhoIsUsing\FindWhoIsUsing

How to import custom PowerShell module into the remote session?

折月煮酒 提交于 2019-11-27 10:17:48
问题 I'm developing a custom PowerShell module, which I'd like to use in context of a remote session to a different computer. The following code (which obviously doesn't work) explains what I'm trying to achieve: import-module .\MyCustomModule.psm1 $session = new-pssession -computerName server01 invoke-command -session $session -scriptblock { <# use function defined in MyCustomModule here #> } The first question is whether it is at all possible to achieve this scenario? I mean I would only like my

Powershell, remote script access denied to network resources

核能气质少年 提交于 2019-11-27 07:55:05
问题 I am trying to execute powershell script remotely using invoke-command. The script relies on a configuration file which is available over the local network. The script is called in a following way: Invoke-Command -ComputerName 192.168.137.181 -FilePath c:\scripts\script.ps1 -ArgumentList \\192.168.137.1\share\config.xml The configuration as you can see is an xml file and it's loaded using: $xml = New-Object XML $xml.Load(args[0]) When the script is called locally on the machine then it runs

How to Write-Verbose from Invoke-Command?

末鹿安然 提交于 2019-11-27 07:35:50
问题 In powershell Write-Verbose and the -Verbose flag are used to provide verbose information when commands are run in verbose mode. I am running some scripts remotely and would like to capture the verbose output output. However, Invoke-Command seems to not capture the verbose channel. PS:> Invoke-Command -ComputerName MY-COMPUTERNAME -Verbose { Write-Verbose "blah" } PS:> How do I capture verbose output when running remote scripts? 回答1: Try it this way: Invoke-Command -ComputerName MY