Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

PowerShell: Create New File or Directory

📅 2010-Mar-13 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ powershell ⬩ 📚 Archive

The New-Item cmdlet can be used to create a new file or directory:

$ New-Item fooFile -ItemType file
$ New-Item fooDir -ItemType directory

This version is too verbose to use in practice at the command line. Using aliases and parameter shortening, this can be reduced to:

$ ni fooFile -i f
$ ni fooDir -i d

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧