VMware Cloud Community
TheVMinator
Expert
Expert
Jump to solution

How to Convert NumCPU to An int?

i need to get the number of vCPUs on a VM and then cast the value into an integer data type.

$cpus = [int]( get-vm sqlvm1 | select NumCPU)

However it is telling me it can’t convert the data type of NumCPU to an int.

any ideas?

0 Kudos
1 Solution

Accepted Solutions
kwhornlcs
Enthusiast
Enthusiast
Jump to solution

Can't convert because you're still pulling an object-type with the select. Try like this:

$cpus = (Get-VM sqlvm1).NumCPU

View solution in original post

0 Kudos
2 Replies
kwhornlcs
Enthusiast
Enthusiast
Jump to solution

Can't convert because you're still pulling an object-type with the select. Try like this:

$cpus = (Get-VM sqlvm1).NumCPU

0 Kudos
TheVMinator
Expert
Expert
Jump to solution

Thanks!

0 Kudos