VMware Cloud Community
ms5812
Enthusiast
Enthusiast

PowerCLI script to gather Virtual Machine installed software

All,

We have a requirement to gather the installed software on 17,000 Virtual Machines in our enterprise. In searching I've not been able to locate any PowerCLI script that gets inside the VM itself to pull the info. We have a PowerShell script but this requires logging into each and every VM. Is there a way to gather the data with PowerCLI? Is so how would we get SQL, McAfee, etc?

Mark

Reply
0 Kudos
7 Replies
LucD
Leadership
Leadership

There is the Invoke-VMScript cmdlet that allows you to run a script inside the guest OS.

This requires a credential for th guest OS, and also that VMware Tools are installed on the VMs.

Another alternative is to query the guest OS remotely (for example with WMI calls from a PowerShell script).

But this requires a connection to the guest OS over the network, and it requires that the remote session feature is enabled in the guest OS.

Would you mind sharing the SW inventory script you are using?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ms5812
Enthusiast
Enthusiast

#---------------------------------------------------------------------------------

 

Function Get-OSCInstalledApplication

   [CmdletBinding(DefaultParameterSetName='SinglePoint')]

   Param

   [Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, ParameterSetName="SinglePoint")]

   [Alias('CName')][String[]]$ComputerName,

   [Parameter(Mandatory=$true, Position=0, ParameterSetName="MultiplePoint")]

   [Alias('CNPath')][String]$ComputerFilePath

   If($ComputerName)

 

   Foreach($CN in $ComputerName)

 

   #test compter connectivity

   $PingResult = Test-Connection -ComputerName $CN -Count 1 -Quiet

   If($PingResult)

 

   FindInstalledApplicationInfo -ComputerName $CN

   Else

   Write-Warning "Failed to connect to computer '$ComputerName'."

 

   If($ComputerFilePath)

 

   $ComputerName = (Import-Csv -Path $ComputerFilePath).ComputerName

 

   Foreach($CN in $ComputerName)

 

   FindInstalledApplicationInfo -ComputerName $CN

 

Function FindInstalledApplicationInfo($ComputerName)

 

   $Objs = @()

   $RegKey = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"

   $InstalledAppsInfos = Get-ItemProperty -Path $RegKey

   Foreach($InstalledAppsInfo in $InstalledAppsInfos)

 

   $Obj = [PSCustomObject]@{Computer=$ComputerName;

  DisplayName = $InstalledAppsInfo.DisplayName;

  DisplayVersion = $InstalledAppsInfo.DisplayVersion;

  Publisher = $InstalledAppsInfo.Publisher}

   $Objs += $Obj

   $Objs | Where-Object { $_.DisplayName }

Reply
0 Kudos
LucD
Leadership
Leadership

That function seems to rely on network connectivity to the stations.

Are you using the script that way?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ms5812
Enthusiast
Enthusiast

Currently we are connecting directly to the VM and running the script to gather the data. Cumbersome and extremely time consuming to say the least. Is there a way to gather this with PowerCLI connected to the respective Datacenter? I have PowerCLI scripts that I have set as Templates to use the Task Scheduler, Cashed Administrator Creds, and send the output to me via e-mail. All I need it the meat and potatoes of the script to plug in the middle Smiley Happy

Reply
0 Kudos
LucD
Leadership
Leadership

Coming back to my first answer on this thread, is the Invoke-VMScript an option?

In other words, do you have the VMware Tools installed on each of these VM?

And do you have an common account with the required permissions to run the script on each of the guest OS of these VM?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ms5812
Enthusiast
Enthusiast

Luc

We have a shared account but different Passwords for the respective Customer VM's.

Mark

Reply
0 Kudos
LucD
Leadership
Leadership

Do you have system/method to correlate the VMs with the credentials?

A kind of lookup table, or a function you can call?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos