Hi,
Is it possible to find through power cli that whether ESX3.5/ ESXi4.1 in vcenter environment require patch updates.If yes then what are the missing patches which need to update.Any help on this appreciated.
Thanks
vmk
Then I'm afraid you'll have to uninstall version 5 and install version 4.1
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Have a look at Obtaining "details url" for Patches
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Perfect but its shows error
[vSphere PowerCLI] C:\tmp> .\patch.ps1
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 i
f a path was included, verify that the path is correct and try again.
At C:\tmp\patch.ps1:2 char:41
+ foreach($baseline in (Get-Compliance <<<< -Entity $esxiHost -Detailed | where {$_.Status -eq "NotCompliant"})){
+ CategoryInfo : ObjectNotFound: (Get-Compliance:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
thanks
vmk
Looks like you don't have the Update Manager snapin loaded.
Do a
Get-PsSnapin
and check if you find VMware.VumAutomation in the list.
If not, install it.
If yes, do a
Add-PsSnapin VMware.VumAutomation
that should give you the Get-Compliance cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Its not installed.
[vSphere PowerCLI] C:\tmp> Get-PsSnapin
Name : Microsoft.PowerShell.Diagnostics
PSVersion : 2.0
Description : This Windows PowerShell snap-in contains Windows Eventing and Performance Counter cmdlets.
Name : Microsoft.WSMan.Management
PSVersion : 2.0
Description : This Windows PowerShell snap-in contains cmdlets (such as Get-WSManInstance and Set-WSManInstance) that are used by the
ell host to manage WSMan operations.
Name : Microsoft.PowerShell.Core
PSVersion : 2.0
Description : This Windows PowerShell snap-in contains cmdlets used to manage components of Windows PowerShell.
Name : Microsoft.PowerShell.Utility
PSVersion : 2.0
Description : This Windows PowerShell snap-in contains utility Cmdlets used to manipulate data.
Name : Microsoft.PowerShell.Host
PSVersion : 2.0
Description : This Windows PowerShell snap-in contains cmdlets (such as Start-Transcript and Stop-Transcript) that are provided for us
ows PowerShell console host.
Name : Microsoft.PowerShell.Management
PSVersion : 2.0
Description : This Windows PowerShell snap-in contains management cmdlets used to manage Windows components.
Name : Microsoft.PowerShell.Security
PSVersion : 2.0
Description : This Windows PowerShell snap-in contains cmdlets to manage Windows PowerShell security.
Name : VMware.VimAutomation.Core
PSVersion : 2.0
Description :
[vSphere PowerCLI] C:\tmp> Add-PsSnapin VMware.VumAutomation
Add-PSSnapin : The Windows PowerShell snap-in 'VMware.VumAutomation' is not installed on this machine.
At line:1 char:13
+ Add-PsSnapin <<<< VMware.VumAutomation
+ CategoryInfo : InvalidArgument: (VMware.VumAutomation:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
Can you tell me how to install it.
thanks
vmk
Use the first link in my previous answer.
Download the installation file and install it (just like you did with the PowerCLI package).
Once installed, in your PowerCLI session you execute the Add-PsSnapin.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Sorry its redirecting to same powercli forum
http://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli/updatemanager
thanks
vmk
It's not the same forum.
Read the title. it says "vCenter Update Manager PowerCLI", not "VMware vSphere™ PowerCLI"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
I installed the VUM but now its shows new error
Get-Compliance : Cannot validate argument on parameter 'Entity'. The argument is null. Supply a non-null argument and try the command again
At E:\script\patch.ps1:2 char:49
+ foreach($baseline in (Get-Compliance -Entity <<<< $esxiHost -Detailed | where {$_.Status -eq "NotCompliant"})){
+ CategoryInfo : InvalidData: (:) [Get-Compliance], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VumAutomation.Commands.GetCompliance
Get-Compliance : Cannot validate argument on parameter 'Entity'. The argument is null. Supply a non-null argument and try the command again
At E:\script\patch.ps1:2 char:49
+ foreach($baseline in (Get-Compliance -Entity <<<< $esxiHost -Detailed | where {$_.Status -eq "NotCompliant"})){
+ CategoryInfo : InvalidData: (:) [Get-Compliance], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VumAutomation.Commands.GetCompliance
Get-Compliance : Cannot validate argument on parameter 'Entity'. The argument is null. Supply a non-null argument and try the command again
At E:\script\patch.ps1:2 char:49
+ foreach($baseline in (Get-Compliance -Entity <<<< $esxiHost -Detailed | where {$_.Status -eq "NotCompliant"})){
+ CategoryInfo : InvalidData: (:) [Get-Compliance], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VumAutomation.Commands.GetCompliance
Get-Compliance : Cannot validate argument on parameter 'Entity'. The argument is null. Supply a non-null argument and try the command again
At E:\script\patch.ps1:2 char:49
+ foreach($baseline in (Get-Compliance -Entity <<<< $esxiHost -Detailed | where {$_.Status -eq "NotCompliant"})){
+ CategoryInfo : InvalidData: (:) [Get-Compliance], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VumAutomation.Commands.GetCompliance
thanks
vmk
That should be '-Entity $esx'.
This is the correct script
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}} } }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
This worked but now error like
Get-Compliance : 2/6/2012 5:08:49 PM Get-Compliance API version '4.1' for vCenter Server 'vc-ckt-prod1' is not supported.
At E:\script\patch.ps1:2 char:41
+ foreach($baseline in (Get-Compliance <<<< -Entity $esx -Detailed | where {$_.Status -eq "NotCompliant"})){
+ CategoryInfo : NotSpecified: (:) [Get-Compliance], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VumAutomation.Commands.GetCompliance
thanks
vmk
Did you install the Update Manager snapin version 5.0 ?
If you're still on vSphere 4.x and using Update Manager 4.x, you should use the Update Manager snapin version 4.1.
See the Release Notes.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes Installed version 5.0
vmk
Then I'm afraid you'll have to uninstall version 5 and install version 4.1
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
yes it worked for me.You are genious !!.One more request i want to pull this report in csv format.Please modify it.
Thanks
vmk
Capture the output in a variable and then export that variable to a CSV file
$report = 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}} } } $report | Export-Csv "C:\report.csv" -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
When i am trying to run the script for ESXi host, it throws error
+ FullyQualifiedErrorId : CommandNotFoundException
Get-Compliance : 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, verify that the path is correct and try again.
At C:\temp\ESXi-MissingPatches.ps1:6 char:27
+ foreach($baseline in (Get-Compliance -Entity $esx -Detailed | where
{$_.Stat ...
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-Compliance:String) [], Comm
andNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Get-Compliance : 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, verify that the path is correct and try again.
At C:\temp\ESXi-MissingPatches.ps1:6 char:27
+ foreach($baseline in (Get-Compliance -Entity $esx -Detailed | where
{$_.Stat ...
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-Compliance:String) [], Comm
andNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Get-Compliance : 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, verify that the path is correct and try again.
At C:\temp\ESXi-MissingPatches.ps1:6 char:27
+ foreach($baseline in (Get-Compliance -Entity $esx -Detailed | where
{$_.Stat ...
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-Compliance:String) [], Comm
andNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Get-Compliance : 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, verify that the path is correct and try again.
At C:\temp\ESXi-MissingPatches.ps1:6 char:27
+ foreach($baseline in (Get-Compliance -Entity $esx -Detailed | where
{$_.Stat ...
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-Compliance:String) [], Comm
andNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Could you,please advise me where i need to do correction.
Thanks
vm2014
Which PowerCLI version do you have installed ?
Do a Get-PowerCLIVersion.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Yes, i get the power Cli version. I am trying to pullout missing patches for ESXi5.5
PowerCLI C:\> Get-PowerCLIVersion
PowerCLI Version
----------------
VMware vSphere PowerCLI 6.0 Release 1 build 2548067
---------------
Component Versions
---------------
VMWare AutoDeploy PowerCLI Component 6.0 build 2358282
VMWare ImageBuilder PowerCLI Component 6.0 build 2358282
VMware License PowerCLI Component 6.0 build 2315846
VMware vSphere PowerCLI Component 6.0 build 2548068
VMware Cloud Infrastructure Suite PowerCLI Component 6.0 build 2548068
VMware HA PowerCLI Component 6.0 build 2510422
VMware PowerCLI Component for Storage Management 6.0 build 2522368
VMware VDS PowerCLI Component 6.0 build 2548068
thanks
vm2014