Creating files, folders, and registry items with PowerShell
When you want to create a new file, folder, or registry key, you will need to leverage the new-item
cmdlet. The syntax of this command is new-item
, calling the –path
argument to specify the location, calling the -name
argument to provide a name for the item, and the -ItemType
argument to designate whether you want a file or a directory (folder). When you are creating a file, it has an additional argument of –value
, which allows you to prepopulate data into the file after creation. When you are creating a new registry key in PowerShell, you can omit the –ItemType
argument as it is not needed for registry key creation. PowerShell assumes that when you are interacting with the registry using ...
Get PowerShell: Automating Administrative Tasks now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.