如何使用PowerShell将数据写入csv文件 [英] How to write data to a csv file using powershell
问题描述
大家好
以下是我正在做的代码以及如何在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=
Hi All 这篇关于如何使用PowerShell将数据写入csv文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
BelongsToOU=
OUMainName}
添加内容
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