Come posso ottenere tutto questo non solo per l'output sullo schermo, ma per salvare in un file di testo nel formato CSV?Mostra output su schermo e file in 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
}
ho cercato
$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
e molti altri formati, ma ho sempre ottenere l'errore:
An empty pipe element is not allowed.
che mi dà lo stesso errore – Ron
$ OU = Get-ADObject -LDAPFilter "(objectCategory = organizationalUnit)" ' -SearchBase "OU = GA, OU = EAST, DC = corp, DC = chm, DC = com "| Selezionare distinguishedName foreach ($ OU In $ OU) { $ OU.distinguishedName Get-ADComputer -SearchBase $ OU.distinguishedName -SearchScope OneLevel ' -Filter * | Selezionare Nome } Tee-Object -file c: \ temp \ outfile.txt – Ron
Solo ** pipe ** su un comando 'Tee-Object'. Vedi il mio aggiornamento. –