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 new-item
, you are creating registry keys. The new-item
command accepts the -force
argument in the instance that the file, folder, or key is being created in a space that is restricted by
User Account Control (UAC).
To create a new folder and registry...