Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

MenuStrip and a Question about Class win32_product

$
0
0

Hello,

I have a bunch of questions I'm hoping someone can answer.

1.) I would like to add a menu separator and a checkbox under a dropdownitem for a toolstripmenuitem

     Similar to what you would see in ISE or Internet Explorer.

     I then need to pass the state of this checkbox into a function

2.) I have created a file menu item and would like to create a separator and then add a list of MRU items restricted to only displaying the five previous opened config files.

3.) Can someone propose an alternative to using the get-wmiobject win32_Product class

The below function I wrote to get the Product Version for some VMware products, but it is slow making the initial connection.   Looking at the Uninstall registry key won't work because it doesn't contain the product version.

I know it looks odd.  I could not find a good way to detect which servers the products were installed on.   So instead I pass the servers that would host these products based on our build standards.

Function get-version($vcenter,$sso,$vum,$credentials) {

    Write-Host "Getting Version information. This usually takes awhile. Be Patient  " -NoNewline
    $Roles  = "VMware vCenter Server","VMware vCenter Inventory Service","VMware vSphere Web Client","vCenter Single Sign On","VMware vSphere Update Manager","vSphere Syslog Collector"

    $i = 0
    $output = @()
    $Servers = "$vcenter","$vcenter","$vcenter","$sso","$vum","$vum"
    $ErrorActionPreference = 'silentlycontinue'

    ForEach ($input in $Servers) {

        IF ($psversiontable.psversion.major -ge 3) { Write-Progress -activity "Getting Version Information - Takes awhile.  Be Patient." -status $Roles[$i] -PercentComplete (($i / $roles.Length)  * 100) } Else { ticker }
        $object = New-Object PSObject
        $object | Add-Member NoteProperty "Role"       $Roles[$i]
        $object | Add-Member NoteProperty "Hostname"   $Servers[$i]
        $object | Add-Member NoteProperty "IP Address" (Get-WmiObject Win32_networkadapterconfiguration -ComputerName $Servers[$i] -Credential $credentials | ? {$_.IPEnabled} | Select-Object IPaddress).IPaddress[0]
        $object | Add-Member NoteProperty "Version"    (Get-WmiObject win32_Product -ComputerName $Servers[$i] -Credential $credentials | Where-Object {$_.Name -eq $Roles[$i]}).version

        $output += $object
        $i++
    }

    IF ($PSVersionTable.PSVersion.Major -ge 3) { Write-Progress -activity "Completed Getting Version Information" -Completed } Else { write-host "...Done!" -NoNewline }
    write-host ""
    $output

} # End Function get-Version


Walter


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>