我需要从Power BI Admin门户导出一些数据。
Get-PowerBiWorkspace | Format-Table | Export-Csv "MyFile.csv"现在,人们可以期望将数据放在csv中。但是Get-PowerBiWorkspace | Format-Table的结果不在csv中,只有一列和许多空列。
我做错了什么?
发布于 2020-08-16 21:51:23
当您发送到csv时,您不希望首先通过format-table发送它。直接从get-powerbiworkspace转到output-csv:
Get-PowerBiWorkspace | Export-Csv "MyFile.csv"发布于 2020-08-16 21:44:29
去掉Format-Table。它正在销毁您想要输出到CSV文件的对象,并将它们转换为其他对象。
C:\> Get-Process | Select -First 2
NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName
------ ----- ----- ------ -- -- -----------
25 30,54 32,29 0,16 3168 1 ApplicationFrameHost
9 1,82 6,34 0,00 3832 0 armsvc
C:\> (Get-Process | Select -First 2)[0].GetType().FullName
System.Diagnostics.Process
C:\> Get-Process | Select -First 2 | Format-Table
NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName
------ ----- ----- ------ -- -- -----------
25 30,54 32,29 0,16 3168 1 ApplicationFrameHost
9 1,82 6,34 0,00 3832 0 armsvc
C:\> (Get-Process | Select -First 2 | Format-Table)[0].GetType().FullName
Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
C:\> (Get-Process | Select -First 2 | Format-Table)[0] | Get-Member
TypeName: Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
autosizeInfo Property Microsoft.PowerShell.Commands.Internal.Format.AutosizeInfo, System.Management.Automation, Version=7.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 autosizeInfo {get;set;}
ClassId2e4f51ef21dd47e99d3c952918aff9cd Property string ClassId2e4f51ef21dd47e99d3c952918aff9cd {get;}
groupingEntry Property Microsoft.PowerShell.Commands.Internal.Format.GroupingEntry, System.Management.Automation, Version=7.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 groupingEntry {get;set;}
pageFooterEntry Property Microsoft.PowerShell.Commands.Internal.Format.PageFooterEntry, System.Management.Automation, Version=7.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 pageFooterEntry {get;set;}
pageHeaderEntry Property Microsoft.PowerShell.Commands.Internal.Format.PageHeaderEntry, System.Management.Automation, Version=7.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 pageHeaderEntry {get;set;}
shapeInfo Property Microsoft.PowerShell.Commands.Internal.Format.ShapeInfo, System.Management.Automation, Version=7.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 shapeInfo {get;set;}没有Format-Table你应该会过得很好。
https://stackoverflow.com/questions/63437503
复制相似问题