構造化データをCLIXMLファイルにエクスポートするには、Export-Clixmlを使います。
例
PS C:\work\image1> Get-ChildItem | Select-Object Name, LastWriteTime, Length | Export-Clixml item.xml -Encoding Default
出力結果(item.xml)
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"> <Obj RefId="0"> <TN RefId="0"> <T>Selected.System.IO.FileInfo</T> <T>System.Management.Automation.PSCustomObject</T> <T>System.Object</T> </TN> <MS> <S N="Name">aaaa.jpg</S> <DT N="LastWriteTime">2016-10-15T00:20:20.9723728+09:00</DT> <I64 N="Length">425167</I64> </MS> </Obj> <Obj RefId="1"> <TNRef RefId="0" /> <MS> <S N="Name">bbbb.jpg</S> <DT N="LastWriteTime">2016-10-10T10:14:04.9771779+09:00</DT> <I64 N="Length">245901</I64> </MS> </Obj> <Obj RefId="2"> <TNRef RefId="0" /> <MS> <S N="Name">cccc.jpg</S> <DT N="LastWriteTime">2016-10-10T10:05:19.3677253+09:00</DT> <I64 N="Length">194315</I64> </MS> </Obj> <Obj RefId="3"> <TNRef RefId="0" /> <MS> <S N="Name">dddd.jpg</S> <DT N="LastWriteTime">2016-10-10T10:13:35.8531086+09:00</DT> <I64 N="Length">235320</I64> </MS> </Obj> <Obj RefId="4"> <TNRef RefId="0" /> <MS> <S N="Name">eeee.jpg</S> <DT N="LastWriteTime">2016-10-15T00:19:45.2356587+09:00</DT> <I64 N="Length">852563</I64> </MS> </Obj> <Obj RefId="5"> <TNRef RefId="0" /> <MS> <S N="Name">ffff.jpg</S> <DT N="LastWriteTime">2016-10-15T19:06:09.4974508+09:00</DT> <I64 N="Length">593126</I64> </MS> </Obj> <Obj RefId="6"> <TNRef RefId="0" /> <MS> <S N="Name">gggg.jpg</S> <DT N="LastWriteTime">2016-10-15T00:21:41.9347667+09:00</DT> <I64 N="Length">607218</I64> </MS> </Obj> </Objs>
スポンサーリンク