To clarify, what property did you change in Windows - did you set the Short 
Date to display "yyyy-MM-dd" and the Short Time to display "H:mm"?  If so, you 
can use the following to get the desired result:



get-date ((get-aduser -id 'userid' -properties 
accountexpirationdate).accountexpirationdate) -f g



Or, if you want Short date and Long time, use "-f G"



Note that the above format commands will display the results as set on the 
computer.



If you want to force it to display a specific way regardless of computer 
settings, use this:



get-date ((get-aduser -id 'userid' -properties 
accountexpirationdate).accountexpirationdate) -f 'yyyy-mm-dd HH:mm:ss'



More information about the format command at:

https://technet.microsoft.com/en-us/library/ee692801.aspx



-Aakash Shah



-----Original Message-----
From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On 
Behalf Of Kurt Buff
Sent: Monday, March 2, 2015 5:17 PM
To: powershell@lists.myITforum.com
Subject: Re: [powershell] Date output format



That returns the date as is displayed originally: 2/27/2015



Kurt



On Mon, Mar 2, 2015 at 5:00 PM, Webster 
<webs...@carlwebster.com<mailto:webs...@carlwebster.com>> wrote:

> Try:

>

> $user = get-aduser -id userid -properties accountexpirationdate

>

> (get-date $user. Accountexpirationdate -f d)

>

> Webster

>

> -----Original Message-----

> From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
> [mailto:listsad...@lists.myitforum.com] On Behalf Of Kurt Buff

> Sent: Monday, March 02, 2015 7:49 PM

> To: powershell@lists.myitforum.com<mailto:powershell@lists.myitforum.com>

> Subject: [powershell] Date output format

>

> When I run the following:

>

> get-aduser -id userid -properties accountexpirationdate

>

> or similar, I see that the date output is in the form of "2/27/2015 5:00:00 
> PM".

>

> This, in spite of the fact that my machine settings are for

> "2015-02-27 17:00:00".

>

> Is that because the DCs aren't set the same as my computer, or is it internal 
> to AD, or something else? And can I put something in my profile at least to 
> adjust that?

>

> Kurt

>

>

> ================================================

> Did you know you can also post and find answers on PowerShell in the forums?

> http://www.myitforum.com/forums/default.asp?catApp=1

>

>

> ================================================

> Did you know you can also post and find answers on PowerShell in the forums?

> http://www.myitforum.com/forums/default.asp?catApp=1





================================================

Did you know you can also post and find answers on PowerShell in the forums?

http://www.myitforum.com/forums/default.asp?catApp=1



================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1

Reply via email to