dhadhabeer
Contributor
Contributor

Need powerCLI script to change the #configured OS# matched the #Running guest OS#

Hello

​Could you please help to get the powerCLI script to modify the VMs Configured OS name matched with Guest running OS.

0 Kudos
5 Replies
LucD
Leadership
Leadership

I would advise you to first check if the discovered guest OS id and the discovered guest OS ID match in all cases.

You can do like this

Get-VM | Select Name,PowerState,

    @{N='Configured';E={$_.Guest.ConfiguredGuestId}},

    @{N='Runtime';E={$_.Guest.RuntimeGuestId}},

    @{N='GuestOS';E={$_.Guest.OSFullName}} | ft -AutoSize

Once you verified this, you can change the ones that do not correspond with something like this

Get-VM |

where{$_.Guest.ConfiguredGuestId -ne $_.Guest.RuntimeGuestId -and $_.Guest.RuntimeGuestId -ne $null} |

Set-VM -GuestId $_.Guest.RuntimeGuestId -Confirm:$false


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

dhadhabeer
Contributor
Contributor

Hello Luc,

I am trying to change the configuredGuestId for single VM, the script will work correct?

Get-VM -Name "vmname" | where{$_.Guest.ConfiguredGuestId -ne $_.Guest.RuntimeGuestId -and $_.Guest.RuntimeGuestId -ne $null} |

Set-VM -Name "vmname" -GuestId $_.Guest.RuntimeGuestId -Confirm:$false

seems the guestID value value is not changing..

0 Kudos
LucD
Leadership
Leadership

Is that VM powered off?


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

0 Kudos
dhadhabeer
Contributor
Contributor

Hello Luc,

No, the VM was running status while executing the script.

Does it require to be powered off to do the changes?

0 Kudos
LucD
Leadership
Leadership

Yes, the VM needs to be powered off to be able to make this change.


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

0 Kudos