从 csv 文件,在 powershell 控制台中查看属性的值没有问题,但是当我想在 csv 文件中导出时,文件是空的,也许有人可以帮助我吗?
$adusers = Import-Csv "c:\temp\adusers.csv" -Delimiter ";"
foreach ($item in $adusers) {
# Map variables from CSV
$adusers = $item.'ADUsers'
$Servers = $item.'Domain'
Get-ADUser -identity $adusers -Properties flags -Server $Servers | Select-
Object -Property samaccountname, userprincipalname, flags | export-csv
c:\temp\fdfdrff.csv -Encoding Unicode
}
文件 adusers.csv:
ADUsers;Domain
account1;Domain1
account2;Domain2
account3;Domain3
account4;Domain4
account5;Domain5
account6;Domain6
account7;Domain7
account8;Domain8
account9;Domain9
输出文件:
"#TYPE Selected.Microsoft.ActiveDirectory.Management.ADUser"
"samaccountname","userprincipalname","flags"
"account9","account9@Domain9.local",