URL을 사용하여 HP ILO에 연결하면 http://ilo-ip/xmldata?item=All은 XML 파일을 아래 형식으로 반환합니다.powershell을 사용하여 웹에서 XML 파일을 읽는 방법
<?xml version="1.0" ?>
- <RIMP>
- <HSI>
<SPN>ProLiant DL385 G1</SPN>
<SBSN>ABCDEFG</SBSN>
<UUID>123456789</UUID>
</HSI>
- <MP>
<ST>1</ST>
<PN>Integrated Lights-Out (iLO)</PN>
<FWRI>1.82</FWRI>
<HWRI>ASIC: 2</HWRI>
<SN>ILOABCDEFG</SN>
<UUID>ILO1234545</UUID>
</MP>
</RIMP>
웹 URL에서 XML 데이터를 읽는 데 필요한 powershell 명령/스크립트가 있습니까? 그것은이되면 XML 작업에 더 많은 정보를 찾는 경우
#Option 1
$doc = New-Object System.Xml.XmlDocument
$doc.Load("http://ilo-ip/xmldata?item=All")
#Option 2
[xml]$doc = (New-Object System.Net.WebClient).DownloadString("http://ilo-ip/xmldata?item=All")
# Your XML will then be in the $doc and the names of the XML nodes can be used as
# properties to access the values they hold. This short example shows how you would
# access the value held in the SPN nodes from your sample XML
Write-Host $doc.RIMP.HSI.SPN
:이 같은 XMLDocument 객체로 XML을로드로드 메서드를 호출 할 수 있도록
답장을 보내 주셔서 감사합니다. 로드 된 코드는 어떻게 읽습니까? 나는 인터넷에서 많은 도움을 찾을 수 없었다. –
XML은 $ doc 객체에 보관되어 있으므로 속성 표기법을 통해 XML에 액세스 할 수 있습니다. 예 : 쓰기 호스트 $ doc.RIMP.HSI.SPN 이렇게하면 "ProLiant DL385 G1"이 콘솔에 쓰여집니다. 할 수있는 일은 $ doc를 Get-Member에 파이프하여 속성 목록을 얻는 것입니다. $ doc | Get-Member –
안녕하세요 Alan, 예외가 발생했습니다 설명대로 두 가지 방법으로 XML을로드 할 때. 예외는 서버가 프로토콜 위반을 저질렀습니다. Section = ResponseStatusLine " –