简体   繁体   English

将 Powershell output 打印到 Csv

[英]Printing Powershell output into Csv

How to print powershell output into a csv file?如何将 powershell output 打印到 csv 文件中? My task is to connect Powershell to azure ad then get users with duplicate licenses and then print the user and all groups user is present in. The initial code I have prepared where I get user and the groups he is present in, but I dont know how to export this into a csv file.我的任务是将 Powershell 连接到 azure 广告,然后获取具有重复许可证的用户,然后打印用户和用户所在的所有组。我准备的初始代码在哪里获得用户和他所在的组,但我不知道如何将其导出到 csv 文件中。 Also the number of groups a user is present in varies so using the method where we specify column1=, colum2=... might not work.此外,用户所在的组数也各不相同,因此使用我们指定 column1=、colum2=... 的方法可能不起作用。 I want to show the result in csv with username and groups seperated by commas.我想在 csv 中显示结果,用户名和组以逗号分隔。 Want to know how to do that.想知道如何做到这一点。

You are probably looking for the Export-Csv cmdlet.您可能正在寻找Export-Csv cmdlet。

Here an example:这里有一个例子:

Get-Process | Export-Csv -Path .\Processes.csv -Delimiter ',' -NoTypeInformation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM