There are many routes to go from point A to point B.
But capturing PowerShell output to parse it then in java is definitely not a straight line
You can use for example the following to get the PowerCLI modules and their version.
Get-Module -Name VMware* -ListAvailable | Select Name, Version
Whatever format you want for the output, you can most probably do that natively in PowerShell.
If you prefer a CSV format, just doGet-Module -Name VMware* -ListAvailable | Select Name, Version |
ConvertTo-Csv -NoTypeInformation -UseCulture
We even have to possibility to write to a file in PowerShell, and that in many formats.
Btw, your PowerCLI version is quite old, time to upgrade.
Thanks for quick jump, I have already installed PowerCLi in my windows machine, but when I execute using PowerShell (Not PowerCli), it says command is not recognized.
If I am able to execute PowerCli using PowerShell, then I can do something.
By the way could you tell me where the exe for PowerCLI is located in windows machine.
I am still in Route A, unable to move ahead .
I am getting the following error. Please help me.
get-powercliversion : The term 'get-powercliversion' is not recognized as the name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and
PowerCLI is a kind of layer on top of PowerShell.
Since quite some time that PowerCLI layer comes in the form of modules.
These modules are installed from the PowerShell Gallery.
See Welcome PowerCLI to the PowerShell Gallery – Install Process Updates on how to replace your older MSI-based installation with a recent version from the Gallery.
There is no EXE to "start" PowerCLI, the PowerShell exe loads the required PowerCLI modules for you.
If you are just starting your PowerShell and PowerCLI trip, I would advise to learn some basic concepts.
Slightly outdated, but some pages I still consider very valuable to get acquainted with PowerShell and PowerCLI are these 2 blog posts from CrazyConsultant:
Invest some time in exploring PowerShell/PowerCLI, it will be worth your while.
Heck, you might not even want to go back to java anymore
I have already followed the link and I am able to execute the command (get-powercliversion) in PowerShell (Not PowerCLI), I am getting the response. But I am unable to handle in Java.
I am not able to grab the output.
Besides, when I execute the command, I get the following output.
PS C:\Users\mishrd5> get-powercliversion
WARNING: The cmdlet "Get-PowerCLIVersion" is deprecated. Please use the 'Get-Module' cmdlet instead.
VMware PowerCLI 11.0.0 build 10380590
VMware Cis Core PowerCLI Component PowerCLI Component 11.0 build 10335701
VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 11.0 build 10336080
Could you please help me to get the actual command PowerCli version ?
My next task is to do something for java.
Try the line I gave earlier with the Get-Module cmdlet.