Powershell 버전 3을 사용하고 나머지는 Rest를 통해 개체로 데이터를 가져오고 싶습니다.PowerShell에서 Rest를 통해 사용자 지정 개체 가져 오기
id : http://services.odata.org/OData/OData.svc/Advertisements(guid'f89dee73-a
f9f-4cd4-b330-db93c25ff3c7')
category : category
link : {link, link, link}
title :
updated : 2013-10-29T09:06:33Z
author : author
content : content
하지만 ID는, 이름, 방송일이 같은 하나의 오브젝트 (2 객체)가있는 출력을 원하는 :
Invoke-RestMethod services.odata.org/OData/OData.svc/Advertisements?$format=json
내 출력은 다음과 같습니다
은 내가 CmdLedt 호출-RestMehtod을 사용Id Name Airdate
-- ---- -------
f89dee73-af9f-4cd4-b330-db93c25ff3c7 Old School Lemonade Store, Retro Style 2012-11-07T00:00:00
db2d2186-1c29-4d1e-88ef-a127f521b9c6 Early morning start, need coffee 2000-02-29T00:00:00
누군가가 JSON을 반환하는 URI에서 costum 개체를 통해 CmdLedt를 가져 오는 방법을 설명 할 수 있습니까?
나중에이 코드를 C# 코드로 사용하여 URI에서 동적 객체를 가져와야하며 항상 다른 구조로되어 있습니다. 일반적으로 동적 객체를 만들기 때문에이 CmdLet이 필요합니다. 지금까지 C#을 내 코드에서 는 :
var args = new string[] { "http://services.odata.org/OData/OData.svc/?$format=json" };
var command = string.Format("Invoke-RestMethod {0}", args[0]);
var results = InvokeCommand.InvokeScript(command);
당신에게 아주 모자의 일종 감사합니다! 완벽하게 작동했습니다 :) –