Creating a folder named after the current date and time

Posted by lowerkey on Super User See other posts from Super User or by lowerkey
Published on 2012-12-07T13:52:49Z Indexed on 2012/12/07 17:13 UTC
Read the original article Hit count: 225

Filed under:

I'm trying to create a powershell script that creates a new folder with the current date (formatted as yyyy-MM-dd) as a name.

Here's what I have so far:

PS C:\Users\me\Desktop> powershell.exe -command "new-item ($(get-location)
+ (Get-Date).year + "-" + (Get-Date).month + "-" + (Get-Date).day) -type directo
ry"
Die Benennung "C:\Users\me\Desktop" wurde nicht als Name eines Cmdlet, ein
er Funktion, einer Skriptdatei oder eines ausführbaren Programms erkannt. Überp
rüfen Sie die Schreibweise des Namens, oder ob der Pfad korrekt ist (sofern ent
halten), und wiederholen Sie den Vorgang.
Bei Zeile:1 Zeichen:35
+ new-item (C:\Users\me\Desktop <<<<  + (Get-Date).year +  - + (Get-Date).
month + - + (Get-Date).day) -type directory
+ CategoryInfo          : ObjectNotFound: (C:\Users\j.moore\Desktop:String
) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

© Super User or respective owner

Related posts about powershell