Skip navigation
VMware

This Question is Answered

1 "correct" answer available (10 pts) 1 "helpful" answer available (6 pts)
242 Views 7 Replies Last post: Feb 6, 2012 3:58 PM by CRad14 RSS
sastre Novice 14 posts since
Mar 25, 2010
Currently Being Moderated

Feb 3, 2012 10:14 AM

Obtaining "details url" for Patches

Hi,

 

I'm writing a script to remediate clusters in our vSphere environment. I quite like the idea of outputting a KB link for each patches that will be applied to each host. The snippet that will do this looks like:

 

Write-Output "3. Checking host compliance:"
foreach($esxiHost in $clusterHosts)
{
         $complianceCheck = Get-Compliance -Entity $esxiHost -Detailed
         if(($complianceCheck.Status) -eq "NotCompliant")
         {
             Write-Output "$($esxiHost) state: NOT compliant. Needs the following patches:"
             [array]$remediateArray = $remediateArray + $esxiHost
            
             foreach($patch in $complianceCheck.NotCompliantPatches)
             {
                 Write-Output "- $($patch.IdByVendor)"

                 # Write-Output "- KB Lookup: ......................."
             }           

}

 

The problem I have with the code above is that $patch only seems to have the following properties (example):

 

Name               : Updates ESXi 4.1 VMware Tools
Id                 : 8491
Description        : For more information, see http://kb.vmware.com/kb/2002341
Product            : {embeddedEsx 4.1.0}
ReleaseDate        : 27/10/2011 09:00:00
Severity           : Critical
IdByVendor         : ESXi410-201110202-UG
Vendor             : VMware, Inc.
Language           : INTL
TargetType         : HOST
BundleType         : Update
InstallationImpact :
LastUpdateTime     : 30/10/2011 13:05:08
IsRecalled         : False

 

I initially thought I could use some regex/string manipulation on the "Description" property but I checked other patches and they don't all have "For more information, see <URL>". Some say "...see the KB article".

 

When looking at patches needed via the vSphere client / GUI window there appears to be a  "property" called "Details URL" containing a nice clean URL! I realise this appears not to be a property of the above $patch object but I was wondering if it is located anywhere obtainable with PowerCLI?

 

http://dl.dropbox.com/u/273709/forums/vmware/patch_details.png

 

Any help much appreciated

CRad14 Hot Shot 161 posts since
Dec 19, 2010
Currently Being Moderated
1. Feb 4, 2012 12:53 PM in response to: sastre
Re: Obtaining "details url" for Patches

Why not just do a regex, looking for http, and when it finds it grabbing that until the end of the line....and maybe taking a period off of the end?

Conrad www.vnoob.com | VCP 4, 5 | @vNoob | If I or anyone else is helpful to you make sure you mark their posts as such! :)
LucD Guru User Moderators vExpert 8,994 posts since
Oct 31, 2005
Currently Being Moderated
3. Feb 6, 2012 2:04 PM in response to: sastre
Re: Obtaining "details url" for Patches

The script I use to list missing patches seems to always find a KB article in the description.

 

foreach($esx in Get-VMHost){
    foreach($baseline in (Get-Compliance -Entity $esx -Detailed | where {$_.Status -eq "NotCompliant"})){
        $baseline.NotCompliantPatches |
        select @{N="Host";E={$esx.Name}},
        @{N="Baseline";E={$baseline.Baseline.Name}},Name,ReleaseDate,IdByVendor,
        @{N="KB";E={(Select-String "(?<url>http://[\w|\.|/]*\w{1})" -InputObject $_.Description).Matches[0].Groups['url'].Value}}
    }
}

 

Which patches do you see that do not have a KB link ?

 

Update: or do you perhaps mean Update bundles ? They don't have a KB URL afaik.

Blog: http://lucd.info | Twitter: @LucD22 | Book co-author: http://powerclibook.com
LucD Guru User Moderators vExpert 8,994 posts since
Oct 31, 2005
Currently Being Moderated
5. Feb 6, 2012 6:11 AM in response to: sastre
Re: Obtaining "details url" for Patches

Thanks

 

I can't change the Helpfull to Correct, but no problem.

Blog: http://lucd.info | Twitter: @LucD22 | Book co-author: http://powerclibook.com
AlbertWT Master 1,103 posts since
Apr 7, 2009
Currently Being Moderated
6. Feb 6, 2012 3:18 PM in response to: LucD
Re: Obtaining "details url" for Patches

Hi,

 

why the Get-Compliance is not recognized in PowerGUI and PowerCLI 4.1u2 ?

 

here's the error message that I mean:

The term 'Get-Compliance' 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, veri
fy that the path is correct and try again.
At C:\Temp\28ef26ef-3385-4ca3-8273-1ea67e7f9ba1.ps1:3 char:41
+     foreach($baseline in (Get-Compliance <<<<  -Entity $esxiHost -Detailed | where {$_.Status -eq "NotCompliant"})){
    + CategoryInfo          : ObjectNotFound: (Get-Compliance:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

 

Kind Regards, AWT
CRad14 Hot Shot 161 posts since
Dec 19, 2010
Currently Being Moderated
7. Feb 6, 2012 3:58 PM in response to: AlbertWT
Re: Obtaining "details url" for Patches

Albert,

 

Do  get-pssnapin and make sure you have the vmware.VUMautomation  snapin loaded.

 

If you don't...you can download it here

http://www.vmware.com/support/developer/ps-libs/vumps/

Conrad www.vnoob.com | VCP 4, 5 | @vNoob | If I or anyone else is helpful to you make sure you mark their posts as such! :)

Bookmarked By (0)

Share This Page

Communities