Files
cheatsheet-tldr/tldr/windows/new-item

39 lines
1.1 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
syntax: markdown
tags: [tldr, windows]
source: https://github.com/tldr-pages/tldr.git
---
# New-Item
> Create a new file, directory, symbolic link, or a registry entry.
> This command can only be used through PowerShell.
> More information: <https://learn.microsoft.com/powershell/module/microsoft.powershell.management/new-item>.
- Create a new blank file (equivalent to `touch`):
`New-Item {{path o ile}}`
- Create a new directory:
`New-Item -ItemType Directory {{path o\directory}}`
- Write a new text file with specified content:
`New-Item {{path o ile}} -Value {{content}}`
- Write the same text file in multiple locations:
`New-Item {{path o ile1 , path o ile2 , ...}} -Value {{content}}`
- Create a symbolic link\hard link\junction to a file or directory:
`New-Item -ItemType {{SymbolicLink|HardLink|Junction}} -Path {{path o\link_file}} -Target {{path o\source_file_or_directory}}`
- Create a new blank registry entry (in REG_SZ, use `New-ItemProperty` or `Set-ItemProperty` to fine-tune the value type):
`New-Item {{path o
egistry_key}}`
- Create a new blank registry entry with specified value:
`New-Item {{path o
egistry_key}} -Value {{value}}`