我怎样才能让所有这些不仅在屏幕上输出,而且以CSV格式保存到文本文件中?
$OUs = Get-ADObject -LDAPFilter "(objectCategory=organizationalUnit)" `
-SearchBase "OU=GA,OU=EAST,DC=corp,DC=chm,DC=com" | Select distinguishedName
ForEach ($OU In $OUs)
{
$OU.distinguishedName
Get-ADComputer -SearchBase $OU.distinguishedName -SearchScope OneLevel `
-Filter * | Select Name
}
我试过了
$OUs = Get-ADObject -LDAPFilter "(objectCategory=organizationalUnit)" `
-SearchBase "OU=GA,OU=EAST,DC=corp,DC=chartercom,DC=com" | Select distinguishedName
ForEach ($OU In $OUs)
{
$OU.distinguishedName
Get-ADComputer -SearchBase $OU.distinguishedName -SearchScope OneLevel `
-Filter * | Select Name
} | | export-CSV c:\temp\outfile.csv –noType
和许多其他格式,但我总是得到错误:
不允许使用空的管道元素。