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

Azure MFA with Azure AD and RDS

Failed to setup initiator portal. Error status is given in the dump data.

Invalid pointer on gpresult /h gpreport.html