tag:blogger.com,1999:blog-1117496458526737084.post2142241525047583765..comments2024-03-16T02:45:40.540+10:00Comments on AnonIT: List Workstations and Last Logon Time from AD using PowershellAnonIThttp://www.blogger.com/profile/06870397873107318020noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-1117496458526737084.post-11280688627639496652015-10-31T06:56:59.137+10:002015-10-31T06:56:59.137+10:00Hi Jon
I'm not sure why that would be the case...Hi Jon<br />I'm not sure why that would be the case. The query isn't optimized, so if you had lots of objects in AD, it may take some time to populate them all. You can separate the two parts into single lines and use measure-command to time how long it takes to run them. You will need to import-module activedirectory first:<br /><br />measure-command {$dcs = Get-ADComputer -Filter { OperatingSystem -NotLike '*Server*' } -Properties OperatingSystem}<br /><br />measure-command {foreach($dc in $dcs) {Get-ADComputer $dc.Name -Properties lastlogontimestamp | Select-Object @{n="Computer";e={$_.Name}}, @{Name="Lastlogon"; Expression={[DateTime]::FromFileTime($_.lastLogonTimestamp)}}}}AnonIThttps://www.blogger.com/profile/06870397873107318020noreply@blogger.comtag:blogger.com,1999:blog-1117496458526737084.post-30045411825571838722015-10-28T21:51:03.421+10:002015-10-28T21:51:03.421+10:00This doesn't seem to do anything...the PowerSh...This doesn't seem to do anything...the PowerShell window simply sits there.Jonhttps://www.blogger.com/profile/03460287230842268911noreply@blogger.com