invoke-command

How to start remotely process in PowerShell

前提是你 提交于 2019-11-29 10:21:21
I have a problem, I have a script which: Connect with PSSession (I use PSSession with admin account) Stop 2 process Do change on them files Start the 2 process (Problem here) I want to start process on server, so i'm connect with PSSession (No problem) I do Invoke-Command : # $pathProg path to my program Invoke-Command -session $mySession -command {Start-Process $($args[0])} -ArgumentList $pathProg But it does nothing (I verify with VNC) I do Invoke-Command too : # $pathProg path to my program Invoke-Command -session $mySession -command {&$($args[0])} -ArgumentList $pathProg It lauch the

How to prevent InvokeCommandAction from propagating event to parent elements?

守給你的承諾、 提交于 2019-11-29 06:45:45
问题 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

Invoke-Command faster than the command itself?

有些话、适合烂在心里 提交于 2019-11-29 04:34:01
I was trying to measure some ways to write to files in PowerShell. No question about that but I don't understand why the first Measure-Command statement below takes longer to be executed than the 2nd statement. They are the same but in the second one I write a scriptblock to send to Invoke-Command and in the 1st one I only run the command. All informations about Invoke-Command speed I can find are about remoting. This block takes about 4 seconds: Measure-Command { $stream = [System.IO.StreamWriter] "$PSScriptRoot\t.txt" $i = 0 while ($i -le 1000000) { $stream.WriteLine("This is the line number

Invoking a Java Method in JSP

半世苍凉 提交于 2019-11-29 02:02:07
Setup Mac OSX 10.6.8, Apache Tomcat 6.0.16, Java1.6.0_29, Eclipse IDE Indigo. I asked a similar question to this before at How to execute and include a Java API from a Web App project but the set up has since changed in that i now have the Java code in the WebAp I am trying to invoke a Java Method from a JSP page and return the results. I have looked at a lot of posts but I’m afraid my lack of experience with either language is the main problem. I have a JSP WebAp that searches an XML database and returns content to the user. I have been asked to integrate additional java code that searches

Invoke Command When “ENTER” Key Is Pressed In XAML

↘锁芯ラ 提交于 2019-11-28 20:32:59
问题 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

How to capture the Return Value of a ScriptBlock invoked with Powershell's Invoke-Command

浪尽此生 提交于 2019-11-28 18:39:00
My question is very similar to this one , except I'm trying to capture the return code of a ScriptBlock using Invoke-Command (so I can't use the -FilePath option). Here's my code: Invoke-Command -computername $server {\\fileserver\script.cmd $args} -ArgumentList $args exit $LASTEXITCODE The problem is that Invoke-Command doesn't capture the return code of script.cmd, so I have no way of knowing if it failed or not. I need to be able to know if script.cmd failed. I tried using a New-PSSession as well (which lets me see script.cmd's return code on the remote server) but I can't find any way to

Powershell passing variables to remote script

时间秒杀一切 提交于 2019-11-28 09:50:00
问题 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 }

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

断了今生、忘了曾经 提交于 2019-11-28 06:06:25
问题 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." } }

How to start remotely process in PowerShell

☆樱花仙子☆ 提交于 2019-11-28 03:42:54
问题 I have a problem, I have a script which: Connect with PSSession (I use PSSession with admin account) Stop 2 process Do change on them files Start the 2 process (Problem here) I want to start process on server, so i'm connect with PSSession (No problem) I do Invoke-Command : # $pathProg path to my program Invoke-Command -session $mySession -command {Start-Process $($args[0])} -ArgumentList $pathProg But it does nothing (I verify with VNC) I do Invoke-Command too : # $pathProg path to my

Handle errors in ScriptBlock in Invoke-Command Cmdlet

这一生的挚爱 提交于 2019-11-28 00:58:32
I am trying to install a service on a remote machine using the powershell. So far I have the following: Invoke-Command -ComputerName $remoteComputerName -ScriptBlock { param($password=$password,$username=$username) $secpasswd = ConvertTo-SecureString $password -AsPlainText -Force $credentials = New-Object System.Management.Automation.PSCredential ($username, $secpasswd) New-Service -Name "XXX" -BinaryPathName "c:\XXX.exe" -DisplayName "XXX XXX XXX" -Description "XXXXXX." -Credential $credentials -ErrorVariable errortext Write-Host("Error in: " + $errortext) } -ArgumentList $password,$username