powershell-remoting

Extremely slow Powershell remote execution?

坚强是说给别人听的谎言 提交于 2019-12-22 12:31:07
问题 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 execution, I don't get any delay. However, if I wait 3-4 minutes I see a big spike in delay again (30-90 seconds). I've also tried using Enter-PSSession and the same thing happens (for the initial command it's slow, then fast, until I don't issue

PSRemoting performance overhead with get-childItem

老子叫甜甜 提交于 2019-12-22 08:25:23
问题 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

How to execute a powershell script available in remote machine?

妖精的绣舞 提交于 2019-12-22 01:37:30
问题 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

How to use PowerShell and PowerShell modules in the enterprise

感情迁移 提交于 2019-12-20 10:45:24
问题 Recently, I've joined the Windows team in my enterprise and with my developer background (Java, .NET and Web in general), I was pretty quickly interested in PowerShell. I can see its value over plain old batch files, VB, ... which is why I'd like to promote its usage and, little by little, push people to favor it over the rest unless there's a reason not to do so. Deploying PowerShell seems pretty straightforward since we can easily approve the relevant patches in WSUS and configure the

Remote PowerShell, find last 5 user logins

半世苍凉 提交于 2019-12-20 07:33:53
问题 I am attempting to view the last 5 login events on an Enterprise machine as an Admin after a security event. I do initial investigations and am trying to find a way to quickly spit out a list of potential, 'suspects'. I have been able to generate output that lists the logfile but under account name where you would generally see \Domain\username I only get the output, "SYSTEM" or similar. If I had recently remoted into the machine it will pull my \Domain\Username and display it no problem.

Get-Content and foreach in two files

自作多情 提交于 2019-12-20 06:08:45
问题 I have two files. The first with contains hostnames (Computers.txt) and the second one contains SID (SID.txt). I want to use Get-Content and foreach to execute a command on each computer with the corresponding SID to modify registry. Let's take for example PC 1 (first line Computers.txt with first line SID.txt) and PC 2 (second line Computers.txt with second line SID.txt). $Computer = Get-Content D:\Downloads\computers.txt $SID = Get-Content D:\Downloads\SID.txt foreach ($pc in $Computer) {

Get-Process to remote computer doesn't work but Invoke-Command does

99封情书 提交于 2019-12-19 04:35:27
问题 I have a 2 servers running Windows Server 2012 R2. One of them is hosting a virtual machine running Windows 7 32-bit, and I am trying to use the other server to view the currently running processes of the virtual machine. I had to use Enable-PSRemoting -SkipNetworkProfileCheck for anything to work. I also had to add the computers to each others TrustedHosts lists. Get-Process -ComputerName VM01 will return a "Couldn't connect to remote machine". However, Invoke-Command -ComputerName VM01

Powershell remoting with ip-address as target

馋奶兔 提交于 2019-12-17 04:49:18
问题 I successfully enabled PSRemoting on my Server 2008 R2. I'm able to do a remote-pssession from within the same network using the hostname as target. I'm failing when I try to use the IP-Address as target from any computer (within the network or from another network (for example via VPN)). I want to be able to use remoting through my VPN connection where I have to use the IP-Address since the hostname can't be resolved. I don't want to add names into my hosts-file because there are a few other

Using Powershell RunspacePool multithreaded to remote server from C#

眉间皱痕 提交于 2019-12-14 03:53:19
问题 I am trying to create some C# code using a Powershell RunspacePool to a remote server. All is working well when maxRunspaces is set to 1, but setting it to 2 gives troubles. var connectionInfo = new WSManConnectionInfo(target, shellUri, credential); using (RunspacePool pool = RunspaceFactory.CreateRunspacePool(1, 2, connectionInfo)) { pool.ApartmentState = System.Threading.ApartmentState.STA; pool.ThreadOptions = PSThreadOptions.UseNewThread; pool.Open(); var tasks = new List<Task>(); for

Serializing PsObject for Invoke-Command

[亡魂溺海] 提交于 2019-12-13 17:08:04
问题 I'm looking for the best or proper way to pass a PsObject to a remote function with Invoke-Command. ConvertTo-Xml is good for serializing but there is no built-in reverse cmdlet. The solutions I've found online are all content specific. I implemented the following functions which works with the few objects I tested but seems rather hacky. Is this going to bite me? Is there a better, yet still simple solution? function Get-TmpFileName () {...} function Serialize-PsObject($obj) { $tmpFile = Get