Get installed software in VM with Invoke-VMScript

by Grzegorz Kulikowski

This post is about using Invoke-VMScript, in order to get software list inside windows virtual machine guest . I am using Chris Dent’s script to obtain all the software from Windows and some tiny tricks we will make it happen. His script :

Implementation with Invoke-VMScript

We will be using invoke-VMScript to call the script from inside the VM. What is also worth noticing is that we will be sending ourselves the json format as an output. The returned object contains property ScriptOutput, which be default is just text.

When the script is about to finish it converts the output to Json format so we can transform it easily from Json later on in our powershell session.

You will see inside the $o/$output ScriptOutput property showing what was on the screen.

ScriptOutput content from Invoke-VMScript
ScriptOutput content

At this moment this is Json string. Now we are converting it.

select-object from returned Json coming from Invoke-VMScript
select-object from returned Json

At this moment we can now filter , modify, select etc anything we want there.

Parsed Invoke-VMScript output as Json
Parsed output as Json

What is worth mentioning is that in order to run Invoke-VMScript you need to have the credentials to local account with administrator rights. You also might hit a problem where you need to adjust your InvalidCertificateAction using Set-PowerCLIConfiguration.


Since i am already here writing about Invoke-VMScript, today i finally understood, why i could not find most of the times cmdlets in VMware {code} documentation portal. Have a look at this 😉

Invoke-VMScript search comparison on {code} portal
Invoke-VMScript search comparison on {code} portal

It’s because of the text is case sensitive i believe. As you can see it is all case sensitive, one must have great memory in order to remember the exact words. invoke-vmscript is not correct, but Invoke-VMScript is. If i do not know exactly what i am looking for, then why would one assume that i know how to type it correctly. Well, another mystery i guess. I have submitted my feedback already, maybe this will get fixed. Maybe its just me, doing the search not in compatible way. No idea to be honest.


Yesterday i wrote about about the trick with ConvertTo-Json and Invoke-VMScript, if you are interested about about this have a look there. Chris did a really great job with the pulling software script, i just modified it a bit to have it working with Invoke-VMScript. Information like this can be really useful with CMDB systems, or ticketing, helpdesk software.


You may also like

Leave a Reply

Chinese (Simplified)DutchEnglishFrenchGermanHindiPolishRussianSpanish