PowerShell使用Get-WSManInstance查询ESXi主机硬件信息的方法

HP-UX、Linux、Tru64 UNIX、NonStop、OpenVMS、Windows Server等,数据中心、虚拟化方案等

版主: xyevolve

版面规则
1. 本版是定位于惠普软件系统及解决方案的技术讨论区。
2. 本版鼓励发帖共同讨论技术问题,不鼓励站内信件私下交流,独知知不如众知知。
3. 本版允许转贴或引用他人的作品,但必须声明原作者信息。
4. 本版禁止发表出售、求购、或其他非技术讨论等帖子。
5. 本版禁止灌水,包括但不限于任何与所讨论主题无关的回复,无意义字符,直接复制其他回复等。
6. 本站附件禁止用于商业目的,请在下载后24小时内删除,本站不对其造成的结果负任何责任。
回复
头像
MUDBOY
创始人
帖子: 3877
注册时间: 2010年 12月 28日 21:17 星期二

PowerShell使用Get-WSManInstance查询ESXi主机硬件信息的方法

帖子 MUDBOY » 2015年 5月 28日 21:00 星期四

WS-MAN is a management standard developed by the DTMF. it provides the ability to access and manipulate CIM providers via HTTP calls.

代码: 全选

$user = "root"
$password = "<plaintext_password>"
$host = "hostname.example.com"
#密码转换
$securepwd = ConvertTo-SecureString $password -AsPlainText -Force
#$creds = new-object System.Management.Automation.PSCredential ($user, $pass)
#生成cred
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user,$securepwd

#$report = Get-WSManInstance 'cimv2/root/dcim/CIM_SoftwareIdentity' -Enumerate -ConnectionURI https://$host/wsman -SessionOption (New-WSManSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck)  -Authentication basic -Credential $cred
#使用Get-WSManInstance获取信息
$report = Get-WSManInstance 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/dcim/CIM_SoftwareIdentity' -Enumerate -ConnectionURI https://$host/wsman -SessionOption (New-WSManSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck)  -Authentication basic -Credential $cred

#取得细节
$iloinfo = $report| Where {$_.Name -eq "Baseboard Management Controller"}
$biosinfo  = $report| Where {$_.Name -eq "System BIOS"}
$iLOFirmwareVersion = $iloinfo.VersionString
$BIOSVersion = $biosinfo.VersionString
$BIOSReleaseDate = ($biosinfo.ReleaseDate).substring(0,8)
提倡分享之精神, 技术问题请在相关版面直接发帖, 站内短信恕不答复.
I don't answer private messages on topics of public interest, because it defeats the whole purpose of a message board.

tyfllb1979
注册用户
帖子: 13
注册时间: 2017年 1月 4日 11:49 星期三

Re: PowerShell使用Get-WSManInstance查询ESXi主机硬件信息的方法

帖子 tyfllb1979 » 2017年 1月 4日 15:31 星期三

好专业的说,谢谢楼主分享

回复