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

Generating Event ID 91, 44 with CA (In Event Viewer with source as Certsvc)

Group policy default policy cannot be edited because network name not found

Problem when changing update source