AD LastLogon format date


i have powershell script extracts lastlogon across domain.

the relevant portion of script is:-

 $time=$currentuser.lastlogon

$dt=[datetime]::fromfiletime($time)

the output in format think (eg

12/15/2011 16:08:20

however, date in uk format.

i understand the culture can help, i've not been able work above.

any help, appreciated.

regards

ian

i sort of stumbled across answer although not 1 expected.

i changed script be:-

$dt=[datetime]::fromfiletime($time).tostring('g')

this gave me desired format, in uk time.  surprised when converted.

regards

ian



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

WIMMount (HSM) causing cluster storage to go redirected (2012r2 DC)

Failed to delete the test record dcdiag-test-record in zone test.com

Azure MFA with Azure AD and RDS