A. A client asked me for a quick way to get physical processor and memory information about machines that are still active in AD. I decided on a quick PowerShell command that lists all computers in the AD that have logged in within 30 days. I then fetched information about the hardware using WMI, as shown below. If you want to base this on the last time the computer account password was changed instead of logon, use passwordLastSet in the command below instead of lastLogonTimestamp. Notice that there are two commands. The first just sets a variable equal to 30 days ago, and this variable is then used in the second query.

<p>lastLogon = (get-date).adddays(-30).ToFileTime() <br> Get-ADComputer -filter \\{lastLogonTimestamp -gt $lastLogon\\} | ForEach-Object \\{get-wmiobject Win32_ComputerSystem -computer$_.name | select Name, NumberOfProcessors,NumberofLogicalProcessors,TotalPhysicalMemory\\}<br><br> Below is example output on my network at home.<br><br> > lastLogon = (get-date).adddays(-30).ToFileTime() <br> > Get-ADComputer -filter \\{lastLogonTimestamp -gt $lastLogon\\} | ForEach-Object \\{get-wmiobject Win32_ComputerSystem -computer $_.name | select Name, NumberOfProcessors,NumberofLogicalProcessors,TotalPhysicalMemory\\}</p>
<p>Name NumberOfProcessors NumberofLogicalProc TotalPhysicalMemory</p><p>----                 ------------------ ------------------- -------------------</p>
<p>SAVDALDC10                            1                   2          2346246144</p>
<p>SAVDALWKS01                           1                   8         12883247104</p>
<p>SAVDALCLIENT                          1                   2          2612584448</p>
<p>SAVDALDC11                            1                   2          1230561280</p>
<p>SAVDALSCVMM                           1                   2          1203298304</p>
<p>SAVDALTS01                            1                   2          1022943232</p>
<p>SAVDALRODC01                          1                   1          1106829312</p>
<p>SAVDALEX10                            1                   2          4294500352</p>
<p>SAVDALCM01                            1                   2          1985536000</p>
<p>SAVDALOM01                            1                   2          6441984000</p>
<p>SAVDALAPPV01                          1                   2           708370432</p>
<p>SAVDALBFS01                           2                  16         51476549632</p>
<p>SAVDALFS01                            1                   1           557375488</p>
<p>SAVDALCLIENT2                         1                   1          1207492608</p>
<p>SAVDALCB01                            1                   2           773382144</p>
<p>SAVDALCLIENT4                         1                   1          1211686912</p>
<p>SAVDALCLIENT3                         1                   1          1228464128</p>

You can change what you list for anything in Win32_ComputerSystem class if you want different information, or even query other classes.

If you need to use different credentials for the WMI, also run the following command before the main Get-ADComputer command.

<p>$cred = Get-Credential</p>

To get the credentials from the user, add –Credential $cred to the Get-WmiObject command after the –computer $_.name. For example,

<p>lastLogon = (get-date).adddays(-30).ToFileTime()<br> $cred = Get-Credential <br> Get-ADComputer -filter \\{lastLogonTimestamp -gt $lastLogon\\} | ForEach-Object \\{get-wmiobject Win32_ComputerSystem -computer $_.name -credential $cred | select Name, NumberOfProcessors,NumberofLogicalProcessors,TotalPhysicalMemory\\}</p>