Using Powershell to enter results in a specific cell of a CSV -
i have csv file , last column (column j) has usernames in it. have script run down column j , display state pulling info active directory. want add information column k beside current username. below script. works fine information can’t add column k. placed count function (the line says $add1 = $add1 +1) hope find solution let me pipe results csv file in column k row $add1. assume there way cant figure out. thanks
enter code here import-module activedirectory $add1 = 1 import-csv c:\temp\newfile.csv | select -expand muid | foreach { $add1 = $add1 +1 get-aduser -identity $_ -properties st | select -expandproperty st }
you can this:
import-csv c:\temp\newfile.csv | %{ $k = get-aduser -identity $_.muid -properties st | select -expandproperty st $_ | add-member -membertype noteproperty -name k -value $k $_ } | export-csv -notypeinformation c:\temp\newfile2.csv
if csv had column k, have assign result want $_.k
Comments
Post a Comment