Running PowerShell under Java

PowerShell script exchange

Running PowerShell under Java

Veeam Logoby sumwu » Mon Jun 30, 2014 2:22 am

Is there any suggestion for users who call Veeam's cmdlet from Java?
We found we can't get output on console because "Install-VeeamToolkit.ps1" uses "-noexit" parameter.
However, if we want to use Java to call Veeam's cmdlet, we need to call "Install-VeeamToolkit.ps1" and also need to know powershell finishes all cmdlets.
(Process proc = runtime.exec(command);
proc.getOutputStream().close(); => can't work with "install-VeeamToolkit.ps1")
sumwu
Veeam Software
 
Posts: 59
Liked: never
Joined: Tue Apr 02, 2013 7:55 am
Full Name: Sum Wu

Re: Running PowerShell under Java

Veeam Logoby v.Eremin » Mon Jun 30, 2014 9:57 am

However, if we want to use Java to call Veeam's cmdlet, we need to call "Install-VeeamToolkit.ps1" and also need to know powershell finishes all cmdlets.

Why do you need to install Veeam PS snap-in each time? May be, you can install it just once, and, then, just reference it in the script, using Add-PSSnapin commadlet. Thanks.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 974 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Running PowerShell under Java

Veeam Logoby sumwu » Wed Jul 02, 2014 5:29 am

I tried to use " Add-PSSnapin -name "VeeamPSSnapIn" but still can't use Veeam PowerSheel cmdlet.
I also try "powershell – import system modules". It imports Veeam-PSSnapIn. But it can't work.
any hits?
sumwu
Veeam Software
 
Posts: 59
Liked: never
Joined: Tue Apr 02, 2013 7:55 am
Full Name: Sum Wu

Re: Running PowerShell under Java

Veeam Logoby v.Eremin » Wed Jul 02, 2014 8:39 am

I'm not that familiar with Java and have no clues on what might be going wrong. As far as I know, if the our PS snap-in is installed on remote machine and the required script is stored nearby, it should be possible to [urlhttp://stackoverflow.com/questions/19152360/run-a-powershell-on-a-remote-machine-using-java ]use invoke expression inside Java code to make PS work remotely[/url]. Thanks.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 974 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 3 guests