invoke-command

OutOfMemory Exception on remote execution using Powershell Invoke-Command

隐身守侯 提交于 2019-12-01 03:16:54
I am trying to execute an exe on a remote computer using invoke-command. Executing the exe on the remote machine after logging into the machine using remote desktop takes 1GB of memory and executes to completion after a minute. Whereas when I execute the same exe using Invoke-Command on the same machine, the process returns an OutOfMemoryException and ends suddenly. My invoke command is as simple as Invoke-Command -Session $someSessionVariable -ScriptBlock {Invoke-Expression "abc.exe --arg arg"} -AsJob . Am I missing something regarding the restrictions on remote invocation? Thanks in Advance.

How can I get 7za.exe to run via Powershell Remoting?

 ̄綄美尐妖づ 提交于 2019-11-30 12:56:26
问题 I've tried a number of different ways to do this, they all result in the same error. Here is one set of commands: $s = New-PSsession -ComputerName ServerA $job = Invoke-Command -Session $s -Scriptblock { Start-Process -FilePath "C:\Scripts\ArchiveEventLogs\ver4.5\7za.exe" -ArgumentList "a", "C:\Scripts\Eventlogs.bak\ServerA-20101111.7z", "C:\Scripts\Eventlogs.bak\*.evt*", "-mx7", "-oC:\Scripts\Eventlogs.bak", "-wC:\Scripts\Eventlogs.bak", "-t7z" -Wait } -AsJob Get-Job | Wait-Job Receive-Job

enter-pssession invoke-command, when to use?

限于喜欢 提交于 2019-11-30 09:58:47
I am writing a script to stop and start services in two remote servers. Here's my question, in my script I did new-pssession and used invoke-command to stop and start services. Do I need to use enter-pssession? Updates: Here's what my script needs to do. on server1, I need to stop and start two services. on server2, I need to stop and start just one service. # foreach for server 1 since I need to stop and start two services. created a session for server 1 foreach($service in $services){ $session = New-PSSession -ComputerName $serverName -Credential $cred Invoke-Command -Session $session

How to prevent InvokeCommandAction from propagating event to parent elements?

陌路散爱 提交于 2019-11-30 06:58:15
I realised that when using an InvokeCommandAcction associated to an EventTrigger, the original event was still routing up to the parent elements until it is handled. Well, I guess it is an expected behavior. But my question is how I can mark the event as Handled so it does not propagate up through the whole UI tree? Actually, as you handle this event in a command, everything will be handled in this command, therefore it does not need to propagate. And in one corner case I found, it causes some unwanted behavior. For example, I open a new window when a user double click an element

How can I get 7za.exe to run via Powershell Remoting?

我们两清 提交于 2019-11-30 03:52:23
I've tried a number of different ways to do this, they all result in the same error. Here is one set of commands: $s = New-PSsession -ComputerName ServerA $job = Invoke-Command -Session $s -Scriptblock { Start-Process -FilePath "C:\Scripts\ArchiveEventLogs\ver4.5\7za.exe" -ArgumentList "a", "C:\Scripts\Eventlogs.bak\ServerA-20101111.7z", "C:\Scripts\Eventlogs.bak\*.evt*", "-mx7", "-oC:\Scripts\Eventlogs.bak", "-wC:\Scripts\Eventlogs.bak", "-t7z" -Wait } -AsJob Get-Job | Wait-Job Receive-Job Job$ The output I get is this: 7-Zip (A) 9.17 beta Copyright (c) 1999-2010 Igor Pavlov 2010-10-04

Invoke Command When “ENTER” Key Is Pressed In XAML

拈花ヽ惹草 提交于 2019-11-29 23:13:14
I want to invoke a command when ENTER is pressed in a TextBox . Consider the following XAML: <UserControl ... xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" ...> ... <TextBox> <i:Interaction.Triggers> <i:EventTrigger EventName="KeyUp"> <i:InvokeCommandAction Command="{Binding MyCommand}" CommandParameter="{Binding Text}" /> </i:EventTrigger> </i:Interaction.Triggers> </TextBox> ... </UserControl> and that MyCommand is as follows: public ICommand MyCommand { get { return new DelegateCommand<string>(MyCommandExecute); } } private void MyCommandExecute

Invoke a second script with arguments from a script

浪尽此生 提交于 2019-11-29 20:24:00
I have a script that reads a configuration file that results in a set of name value pairs that I would like to pass as arguments to a function in a second PowerShell script. I do not know what parameters will be placed in this configuration file at design time, so right at the point where I need to invoke this second PowerShell script, I basically just have one variable that has the path to this second script, and a second variable that is an array of arguments to pass to the script identified in the path variable. So the variable containing the path to the second script ($scriptPath), might

Powershell passing variables to remote script

空扰寡人 提交于 2019-11-29 15:41:06
I have the following cmd file:- PowerShell.exe -noexit E:\wwwroot\domains\processes\AddDirectory.ps1 -Param testdomain.co.uk which goes through to:- $Session = New-PSSession -ComputerName 192.168.0.25 $script = { Param($Param1) set-executionpolicy unrestricted -force # Set Variables $domain = $Param1 $sitepath = "e:\domains\" + $domain # Check for physical path if (-not (Test-Path -path $sitePath)) { New-Item -Path $sitepath -type directory New-Item -Path $sitepath\wwwroot -type directory } set-executionpolicy restricted -force } Invoke-Command -Session $Session -ScriptBlock $script But it

enter-pssession invoke-command, when to use?

安稳与你 提交于 2019-11-29 15:04:46
问题 I am writing a script to stop and start services in two remote servers. Here's my question, in my script I did new-pssession and used invoke-command to stop and start services. Do I need to use enter-pssession? Updates: Here's what my script needs to do. on server1, I need to stop and start two services. on server2, I need to stop and start just one service. # foreach for server 1 since I need to stop and start two services. created a session for server 1 foreach($service in $services){

How to pass local variable to Invoke-Command's -ScriptBlock

孤街浪徒 提交于 2019-11-29 12:34:50
I am trying to execute following PowerShell script from Server-2 against Server-1 (i.e. Remote server): $DBServer = 'Server1' Invoke-Command -ComputerName $DBServer -ScriptBlock { $status = Start-Process "C:\Program Files\iQ4bis\HaloSource\HaloSource.Run.exe" '"D:\Test\UsageTracking.iqp" /wf "Default Workflow" /e "Dev" ' -Wait -PassThru $test2 = $status.ExitCode if ($test2 -ne 0) { Throw "The command exited with error code: $test2" } else { Write-host "Workflow executed successfully." } } Question: Code part "C:\Program Files\iQ4bis\HaloSource\HaloSource.Run.exe" '"D:\Test\UsageTracking.iqp"