Powershell - Easier way to get short date for filename

date, powershell, replace

Solution

You can use the `-Format` argument of `get-date`:

get-date -format "MM.dd.yyyy"
11.20.2012

Problem

More out of curiosity as its working fine for me (I'm just beginning with Powershell) but I'm using below to obtain a short date for use in file names: ``` $shortdate = (get-date).toshortdatestring().replace("/",".") ``` Is there a built in functionality for this or is this the correct way to accomplish this?

Original source