在这里,我想在同一CSV文件的下一行中$newdata
数据,但结果如下:
NewManager ---------- Sathiya Priya Naveen Kumar Sathiya Priya Naveen Kumar Sathiya Priya Naveen Kumar Sathiya Priya Naveen Kumar Sathiya Priya Naveen Kumar Sathiya Priya Naveen Kumar Sathiya Priya Naveen Kumar Sathiya Priya Naveen Kumar
但是实际上数据是:
NewManager ---------- Karthikeyan Deenadhayalan Karthikeyan Deenadhayalan Sathiya Priya Naveen Kumar Karthikeyan Deenadhayalan Karthikeyan Deenadhayalan Sathiya Priya Naveen Kumar Karthikeyan Deenadhayalan Sathiya Priya Naveen Kumar
我的代码:
cls
$NewData = $Olddata |
Select @{n="NewManager";e={(Get-ADUser $_.Manager -Properties *).DisplayName}} |
%{$_.NewManager} |
Out-File C:\Users\Administrator.ROOTDC1\Desktop\test1.txt -Force
$import = Import-Csv $path
$print = gc C:\Users\Administrator.ROOTDC1\Desktop\test1.txt
foreach ($prints in $print) {
#I want to add new manager list on the same file in the next row.
foreach ($imp in $import) {
Add-Member -InputObject $imp -MemberType NoteProperty -Name NewManager -Value $prints -Force
}
}
$import