Need some help with my output

by notarat at 2013-02-27 10:53:43

DISCLAIMER: I’m still a n00b. I know that may send some scurrying away, but I could use a little assistance with the output of my script. I’m pulling some basic information for the computer accounts in my OU and, although I get the information I need (on the screen) I cannot seem to pipe it to a file for use later

My code is:
$computers = Get-Content c:\inputfiles\computerlist.txt
Foreach($computer in $computers) {
Get-QADComputer $computer -IncludeAllProperties | select cn,AccountIsDisabled,operatingsystem,operatingsystemversion,operatingSystemServicePack,lastLogon}

It displays the information I need, but I cannot pipe it to a file or save it.

Could someone show me how to format it as a table and pipe the data to a file?
by notarat at 2013-02-27 11:30:28
Bah…did I say I learn fast?

Get-ADComputer -f * -searchbase ‘OU=COMPUTERS,OU=AAAA,OU=AAAAA,DC=AAAAA,DC=AAAAAAA,DC=AAAA,DC=COM’-Properties * | select cn,AccountIsDisabled,operatingsystem,operatingsystemversion,operatingSystemServicePack,lastLogontimestamp | Export-CSV c:\outputfiles\BasicComputerInfo.txt -notype

So I decided to go with the code above, instead, and I get (most) the information I want in the CSV file.

For some reason, the values for the property “AccountIsDisabled” show as “Microsoft.ActiveDirectory.Management.ADPropertyValueCollection” instead of the value that is displayed on the console screen when I run the command.

Why will it not display the value?

It’d be easier for me if I could find a way to modify the code above to retrieve only the active computer accounts, but I am not that far along yet.

by DonJ at 2013-02-27 11:52:48
See forum rules, #3, right above your first post :).

AccountIsDisabled isn’t actually a single property, which is why you get it as a Property Value Collection. See viewtopic.php?f=9&t=1382 - seems to be the day for that question to come up.

The way to only retrieve active accounts depends on what you mean by “active,” but the key is either the -filter or -ldapfilter parameters.
by ArtB0514 at 2013-02-27 11:58:50
"AccountIsDisabled" is not a property of a computer account returned by Get-ADComputer (although it IS a property returned by Get-QADComputer). Perhaps you mean to use the “Enabled” property.
by notarat at 2013-02-27 13:32:27
I took Don’s and Art’s advice and did some more research on the Tech Net site and found a way to pull the information I need. Thanks~