Does anyone know the powercli to check the vCPU of a VM and change the Core per socket to match the vCPU.
Ok, try like this.
Remember, the VM needs to be powered off to change this setting.
ForEach-Object -Process {
Set-VM -VM $_ -CoresPerSocket $_.NumCpu -Confirm:$false
}
---------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Move to PowerCLI
Yes I do.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this.
But be aware that this is not foo-proof.
You can't change the CoresPerSocket in all cases to NumCPU.
Set-VM -CoresPerSocket $vm.NumCpu -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Getting an error.
>Set-VM -PipelineVariable TEST1 | where{$_.NumCpu -ne $_.CoresPerSocket} |Set-VM -CoresPerSocket $vm.NumCpu -Confirm:$false
Set-VM : Cannot validate argument on parameter 'CoresPerSocket'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null
values and then try the command again.
At line:1 char:100
+ ... Cpu -ne $_.CoresPerSocket} |Set-VM -CoresPerSocket $vm.NumCpu -Confir ...
+ ~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-VM], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.SetVM
You changed the name of the PipelineVariable is used.
That's why you get the error.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Ohh i though that's the name of VM for which we want to change the config.
No, if you want to test with a specific VM, you can use the Name parameter.
Set-VM -CoresPerSocket $vm.NumCpu -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Tried this but still getting the error.
Get-VM -Name TEST1 -PipelineVariable vm | where { $_.NumCpu -ne $_.CoresPerSocket } |Set-VM -CoresPerSocket $vm.NumCpu -Confirm:$false
Set-VM : Cannot validate argument on parameter 'CoresPerSocket'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null
values and then try the command again.
At D:\Anoop\Scripts\Lab\Lab.ps1:3 char:24
+ Set-VM -CoresPerSocket $vm.NumCpu -Confirm:$false
+ ~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-VM], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.SetVM
Ok, try like this.
Remember, the VM needs to be powered off to change this setting.
ForEach-Object -Process {
Set-VM -VM $_ -CoresPerSocket $_.NumCpu -Confirm:$false
}
---------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It worked, thank you for all your help !!