2016-07-28 68 views
0

使用Get-Content,我開發了我的PowerShell腳本,但後來覺得要使用存儲庫用於模板。Powershell:如何從URI而不是本地磁盤獲取JSON文件內容

$JsonContent = Get-Content $TFileUri | ConvertFrom-Json 

錯誤:

Get-Content : Cannot find drive. A drive with the name 'https' does not exist.

我試圖加入-raw參數,管道到ConvertFrom JSON的之前就幫我在其他場合,但它給了我下面的錯誤:

$JsonContent = Get-Content $TFileUri -Raw | ConvertFrom-Json 

Get-Content : A parameter cannot be found that matches parameter name 'Raw.

如何從遠程URI獲取文件並解決上述問題?

回答

0

下適應幫我往前走(不知道如何的標準分辨率,但共享有一定的幫助)

$JsonContent = Invoke-RestMethod -Uri $TFileUri 

注:我沒有覺得有必要轉換JSON爲對象,以及與上述線。

相關問題