如何使用PowerShell将数据写入csv文件 [英] How to write data to a csv file using powershell

查看:1264
本文介绍了如何使用PowerShell将数据写入csv文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



以下是我正在做的代码以及如何在CSV文件中写入数据



 $ Obj = New-Object -TypeName PSObject -Property @ {ComputerName= $ ComputerName 
BelongsToOU= $ OUMainName}
Add-content $ OutPath -Value $ Obj





但是在CSV中我将数据汇总到一行。



请告诉我如何在ComputerName一列和BelongsToOU另一列中获取数据。



我尝试过:



 $ Obj = New-Object -TypeName PSObject -Property @ {ComputerName= $ ComputerName 
BelongsToOU= $ OUMainName}
添加内容$ OutPath -Value $ Obj

解决方案

Obj = New-Object -TypeName PSObject -Property @ {ComputerName=


ComputerName
BelongsToOU=


OUMainName}
添加内容


Hi All

Below is the code what i am doing how and writing the data in a CSV file

$Obj = New-Object -TypeName PSObject -Property @{"ComputerName" = $ComputerName
                                                     "BelongsToOU" = $OUMainName}
Add-content $OutPath -Value $Obj



But in the CSV i am getting the data in a single line.

Please tell me how to get the data in columns like ComputerName one column and BelongsToOU another.

What I have tried:

$Obj = New-Object -TypeName PSObject -Property @{"ComputerName" = $ComputerName
                                                     "BelongsToOU" = $OUMainName}
Add-content $OutPath -Value $Obj

解决方案

Obj = New-Object -TypeName PSObject -Property @{"ComputerName" =


ComputerName "BelongsToOU" =


OUMainName} Add-content


这篇关于如何使用PowerShell将数据写入csv文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆