VMware Cloud Community
mbegrow
Contributor
Contributor
Jump to solution

I'm trying to create a baseline following examples of get-help new-patchbaseline but I'm running into the below issue:

I'm trying to create a baseline following examples of get-help new-patchbaseline but I'm running into the below issue:

PS H:\> $Patches = get-patch -server $vc -searchphrase "ESXi600-201710301-BG"

PS H:\> new-patchbaseline -Name $baselinename -Description $description -static -server $vc -IncludePatch $Patches

new-patchbaseline : Unable to cast object of type 'VMware.VimAutomation.ViCore.Util10.Surrogate.DefaultValue.StringWrapperVIServer' to type

'VMware.VimAutomation.ViCore.Interop.V1.VIObjectCoreInterop'.

At line:1 char:1

+ new-patchbaseline -Name $baselinename -Description $description -stat ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [New-PatchBaseline], InvalidCastException

    + FullyQualifiedErrorId : System.InvalidCastException,VMware.VumAutomation.Commands.NewPatchBaseline

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Can you connect to only one vCenter, and then try to leave out the Server parameter on the cmdlets?
The error seems to indicate the cmdlet has a casting issue on that parameter


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

View solution in original post

0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

Seems to be working for me (vSphere 6.5U1 & PowerCLI 6.5.3).

Which versions are you using?

$baselineName = 'Test'

$patchName = 'ESXi600-201710301-BG'

$patches = Get-Patch -SearchPhrase $patchName

Get-PatchBaseline -Name $baselineName -ErrorAction SilentlyContinue | Remove-Baseline -Confirm:$false

New-PatchBaseline -Name $baselineName -TargetType Host -Description Test -IncludePatch $patches -Static

baseline.jpg


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

0 Kudos
mbegrow
Contributor
Contributor
Jump to solution

VCSA 6.5 u1, ESXi 6.0

PowerCLI Version

----------------

   VMware PowerCLI 6.5.1 build 5377412

---------------

Component Versions

---------------

   VMware Cis Core PowerCLI Component 6.5 build 6230110

   VMware VimAutomation Core PowerCLI Component 6.5 build 6234650

   VMware vSphere Update Manager PowerCLI 6.6 build 5301639

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Can you connect to only one vCenter, and then try to leave out the Server parameter on the cmdlets?
The error seems to indicate the cmdlet has a casting issue on that parameter


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

0 Kudos
mbegrow
Contributor
Contributor
Jump to solution

Not sure why being connected to multiple vCenters caused the issue but when I connect just to the vCenter I wanted to create the baseline on it worked

Thanks.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That definitely looks like a bug.
I would suggest to open a SR


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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

But wait a minute, how do you populate the $vc variable?

In other words, what is in there?


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

0 Kudos