Powershell Create a New Directory Named With Todays Date
This is a common requirement if using powershell to run certain scripts on a schedule and have the output stored in a dated folder e.g. a backup script. This solution is a pretty straight forward way of creating the directory.
$today = (Get-Date -Format dd-MM-yyyy)
$path = "\\server\share\" + "$Today"
new-item -path $path -itemtype directory
I found if I tried to type the path for the new-item cmdlet with $today on the end it simply created a directory named $today but the extra line to create $path gets the desired result.