PowerShell script exchange
Post Reply
sumwu
Expert
Posts: 109
Liked: never
Joined: Apr 02, 2013 7:55 am
Full Name: Sum Wu
Contact:

Running PowerShell under Java

Post by sumwu » 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")

veremin
Product Manager
Posts: 16789
Liked: 1410 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Running PowerShell under Java

Post by veremin » 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.

sumwu
Expert
Posts: 109
Liked: never
Joined: Apr 02, 2013 7:55 am
Full Name: Sum Wu
Contact:

Re: Running PowerShell under Java

Post by sumwu » 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?

veremin
Product Manager
Posts: 16789
Liked: 1410 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Running PowerShell under Java

Post by veremin » 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.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests