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

HP-UX, Linux, Tru64 UNIX, NonStop, OpenVMS, MS Windows Server, DataCenter and Virtualization Solutions, etc

Moderator: xyevolve

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

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

Post # 1 by MUDBOY » 2015-05-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.

Code: Select all
$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.
User avatar
MUDBOY
创始人
 
Posts: 3742
Joined: 2010-12-28

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

Post # 2 by tyfllb1979 » 2017-01-04 15:31

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

tyfllb1979
新注册用户
 
Posts: 13
Joined: 2017-01-04


Return to Software & Soluations

Who is online

Users browsing this forum: No registered users and 2 guests