Short updates

I surrender. My life as it is now will not support the time to make beautiful posts. Like I would have bolder the word beautiful there and added a picture. Because marketing.

nope this sucker is being written on my phone in the morning as I sip coffee. I have 25 minutes before I need to leave for work and I’m not dressed yet. Evidence: (test phone camera):

Warming device

So this is how I’ll need to write posts in the future. And the purpose is: to be a testament to my future self that I DID do geeky things and find things interesting.

Yesterday … I found out the hard way that I had to ask ALL domain controllers about when people last logged in. Apparently we’ve had one controller be PDC for a very long time and machines remember their favorite DC for a long time.

Script modified from https://social.technet.microsoft.com/Forums/ie/en-US/d86b7495-729a-44e2-ad68-5e154ecbd6d7/getaduser-lastlogontimestamp-is-reporting-blank?forum=winserverpowershell
 
$( foreach ($dc in (Get-ADDomainController -Filter "domain -eq '$((Get-ADDomain).DnsRoot)'" | % {​​​​ $_.HostName}​​​​ ) ) {​​​​ Get-ADUser -Filter '*' -searchbase 'DC=******' -Server $dc -Properties LastLogon | Select SamAccountName, LastLogon, @{​​​​n='LastLogonDC'; e={​​​​ $dc }​​​​}​​​​ }​​​​ ) | Group SamAccountName | % {​​​​ ($_.Group | sort lastLogon -Descending)[0] }​​​​ | select SamAccountName, lastlogon,@{​​​​n='LastLogon1'; e={​​​​ (Get-Date $_.LastLogon).ToLocalTime() }​​​​}​​​​, LastLogonDC | export-csv -path "lastlogon.csv"

Chart: Maybe later

Result: I can figure approx how many CAL we need. Going to update DC to next server version.

Author: sunnywiz

Me.

Leave a Reply

Your email address will not be published. Required fields are marked *