I am trying to find out the last time machines rebooted by reading the local WMI of machines in select OUs. I have this code:
$machine = (Get-ADComputer -Filter * -SearchBase "OU=24 Carrol,dc=Acme,dc=org").Name
foreach($pc in $machine) {
Get-WmiObject win32_operatingsystem -ComputerName $pc | select csname, @{LABEL='LastBootUpTime';EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}
}
24 Carrol is a sub-OU under Acme_Workstations. There are many other sub-OUs under Acme_Workstations as well. OU-24 Carrol has 7 machines within it. When I run the above code it returns information about computers in a totally different OU and in fact does not return any data about machines in 24 Carrol. Why on earth would it do that?
I then tried just this code
$machine = (Get-ADComputer -Filter * -SearchBase "OU=24 Carrol,dc=Acme,dc=org").Name
$machine
and it also fails. it is reading an OU called '1355 Rowland" so I thought it had something to do with 1 coming before 2 (1355 vs 24) but we have other OUs with lower numbers like 1100 Rowland and it is not reading those.
Is our AD jacked up?