Jak mogę to wszystko uzyskać, nie tylko wyświetlając obraz na ekranie, ale również zapisując plik tekstowy w formacie CSV?Pokaż dane wyjściowe na ekranie iw pliku w programie PowerShell
$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
}
Próbowałem
$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
I wiele innych formatów, ale zawsze pojawia się błąd:
An empty pipe element is not allowed.
że daje mi ten sam błąd – Ron
$ OU = Get-ADObject -LDAPFilter "(objectCategory = organizationalUnit)" ' -SearchBase„OU = GA, OU = EAST, DC = corp, DC = chm, DC = com "| Wybierz distinguishedName foreach ($ w $ OU OU) { $ OU.distinguishedName Get-ADComputer -SearchBase $ OU.distinguishedName -SearchScope OneLevel ' -Filter * | Wybierz nazwę } Tee-Object -File c: \ temp \ outfile.txt – Ron
Po prostu ** pipe ** to do polecenia 'Tee-Object'. Zobacz moją aktualizację. –