VMware Cloud Community
tdubb123
Expert
Expert

remediate inventory not working

I am trying to patch a esxi host with following script

connect-viserver sac-vc

$myhost = "host1"

#move vms off host manually

get-cluster | get-vmhost $myhost | get-vm | move-vm -location (get-vmhost host2)

get-baseline -baseline 'Baseline'  | attach-baseline -entity $myhost

Scan-Inventory -Entity $myhost

Remediate-Inventory -baseline 'BAseline' -Entity $myhost

but keep getting this error

PS C:\Windows\System32\WindowsPowerShell\v1.0> Remediate-Inventory -Baseline 'BAseline' -Entity host

Remediate-Inventory : Cannot bind parameter 'Baseline'. Cannot convert the "BAseline" value of type "System.String" to type "VMware.VumAutomation.Types.Baseline".

At line:1 char:31

+ Remediate-Inventory -Baseline 'BAseline' -Entity host

+                               ~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (:) [Remediate-Inventory], ParameterBindingException

    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VumAutomation.Commands.RemediateInventory

Reply
0 Kudos
1 Reply
RvdNieuwendijk
Leadership
Leadership

It looks like the Remediate-Inventory -baseline parameter doesn't do a conversion from string to baseline type. You can try the following:

$baseline = get-baseline -baseline 'Baseline'

attach-baseline -entity $myhost -Baseline $baseline

Scan-Inventory -Entity $myhost

Remediate-Inventory -baseline $baseline -Entity $myhost

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos