VMware Cloud Community
Rjaudon272
Contributor
Contributor
Jump to solution

Set NumCoresPerSocket and CPU - set-vm pipeline issue

All,

I am having some trouble passing in a VM name to Set-vm and running into error such as "Set-VM : Cannot process argument transformation on parameter 'VM'. Strings as pipeline input are not supported."

I've tried using set-vm -numcpu and it produces a similar error message "set-vm : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input"

I am missing something here and would love to get some pointer in the right direction to get the script to complete.

************************************

$VDIDevice = Get-Content C:\Temp\CPU\Testvdi.txt

foreach($vm in $VDIDevice){

###$VDIDevice= get-vm 'vdisal001'

$TotalvCPU=2

$Cores=1

Get-VM -Name $VDIDevice | Shutdown-VMGuest

start-sleep 10

$spec = New-Object -TypeName VMware.Vim.VirtualMAchineConfigSpec -Property @{'NumCoresPerSocket'=$Cores}

(get-vm -Name $VDIDevice).ExtensionData.ReconfigVM_Task($spec)

$VDIDevice | set-vm -Name $vm -numcpu $TotalvCPU

}

*************************************

SetVM_error.png

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

I think the error message is very clear, you can't provide a String as the value for the VM parameter on the Set-VM cmdlet.

The easiest solution is to do

Get-VM -Name $VDIDevice | Set-VM -NumCpu $TotalvCPU


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

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

I think the error message is very clear, you can't provide a String as the value for the VM parameter on the Set-VM cmdlet.

The easiest solution is to do

Get-VM -Name $VDIDevice | Set-VM -NumCpu $TotalvCPU


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

Reply
0 Kudos
Rjaudon272
Contributor
Contributor
Jump to solution

LucD,

Thank you sir.  That worked perfectly.

I appreciate the help.

Rob

Reply
0 Kudos