Author is connecting to root\cimv2 namespace which is same as we used to query wmi on windows boxes. but I am unable to connect to wmi namespace on esxi box using the following code..sorry first time querying esxi using wmi
PS C:\HK-WorkArea\VmWare> Get-WmiObject cim_computersystem -ComputerName https://<myhostname.fqdn>
Get-WmiObject : Invalid parameter
At line:1 char:14
+ Get-WmiObject <<<< cim_computersystem -ComputerName https://<myhostname.fqdn>
I suspect you have to enable the CIM service first.
Perhaps have a look at Joep's article Enabling CIM on ESXi.Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
2 people found this helpful
use the below command for the same
esxcfg-info | grep "Serial Number"
Its ESXi with no console os.
I see vSphereCLI, but no corresponding scripts are there to esxcfg-info.
Getting serial number has become such a challenge.
We can only use PowerCLI for all VI purposes...i see CIM SDK to be complicated stuff..can someone guide from powershell perspective please..really important to get serial number
thanks a lot
A solution that uses the plink.exe command from the PuTTY suite.
$User = <ESX-account> $Pswd = <ESX-password> $hostName = <ESX-hostname> $plink = "<PuTTY-directory>\plink.exe" $plinkoptions = " -v -batch -pw $Pswd" $cmd1 = 'esxcfg-info' $remoteCommand = '"' + $cmd1 + '"' $command = $plink + " " + $plinkoptions + " " + $User + "@" + $hostName + " " + $remoteCommand $msg = Invoke-Expression -command $command $mask = [regex]"Serial Number\.*(\w+)" $result = $mask.Matches($msg) $serial = $result.Groups.Value Write-Host "Host:" $hostName Write-Host "Serial Number:" $serialBlog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
Plink.exe > ESXi ? it has no service console right ?
Can we use CIM somehow from PowerCLI ?
You don't logon to the COS, which is not there, but directly to the hypervisor (tech support mode).
When the ESXi is locked down this won't work of course.Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
Lockdown mode is disabled.
Under Host View > Configuration > Security Profile > Services > Vmware vCenter Agent and NTP deamon is running.
But i still get error using plink.exe..
Connecting to <hostIP> port 22
Failed to connect to <hostIP>: Network error: Connection refused
Network error: Connection refused
Any clues ?
We enabled indeed ssh on our ESXi servers.Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
Console says it is unsupported unless assisted by a vmware support professional.
Cannot justify to production guys. So much pain for a serial number .. LOL
Can you point me to CIM & PowerCLI marriage ?