2013-01-21 83 views
0

我正在從名爲Insert的PowerShell腳本進行REST調用,並且它正在返回一個字節數組。我想知道如何將此字節數組轉換爲Object。如何將字節數組轉換爲.NET對象?

+0

什麼樣的對象?鍵入'[object]'還是'[object []]'? –

+0

其類型[對象] – user1358784

+0

我的REST插入方法返回下面的數據,我想將它轉換爲.NET對象,以便我可以使用腳本的其他部分[60,63,120,109,108,32,118,101,114,115,105,111,110,61,34,49, 46,48,34,32,101,110,99,111,100,105,110,103,61,34,117,116,102,45,56,34,32,115,116,97,110,100,97,108,111,110,101,61,34,121,101,115,34,63 ,62,13,10,60,101,110,116,114,121,32,120,109,108,58,98,97,115,101 ,61,34,104,116,116,112,58,47,47,108,111,99,97,108,104,111,115,116,47,82,101,112,111,115,105,116,111,114,121,47,100,97,116,97,47,7 0,108,101,120,105,98,108,101,67,111,109,112,117,116,105] – user1358784

回答

0

這是一個起點,轉換爲字符串的字節數組,但它似乎是不完整的:

$a = 60,63,120,109,108,32,118,101,114,115,105,111,110,61,34,49,46,48,34,32,101,110,99,111,100,105,110,103,61,34,117,11 
6,102,45,56,34,32,115,116,97,110,100,97,108,111,110,101,61,34,121,101,115,34,63 ,62,13,10,60,101,110,116,114,121,32,120, 
109,108,58,98,97,115,101,61,34,104,116,116,112,58,47,47,108,111,99,97,108,104,111,115,116,47,82,101,112,111,115,105,116, 
111,114,121,47,100,97,116,97,47,70,108,101,120,105,98,108,101,67,111,109,112,117,116,105 

($a | % { -join [char]$_ } ) -join '' 

<?xml version="1.0" encoding="utf-8" standalone="yes"?> 
<entry xml:base="http://localhost/Repository/data/FlexibleComputi 
+0

完美 - 我能夠看到完整的字符串使用上面的代碼行。是的,我粘貼了原始Byte數組的簡短版本。我應該如何訪問結果字符串的內容屬性? <內容類型= 「application/xml進行」> 35 SystemProvisioned 初始化 user1358784

+0

轉換爲[xml],然後使用select-xml cmdlet進行查詢。 –

+0

謝謝C.B.你確實節省了我很多時間! – user1358784

相關問題