0
0
PowerShellscripting~5 mins

New-Item for creation in PowerShell - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the PowerShell cmdlet <code>New-Item</code> do?

New-Item creates a new item like a file or folder at a specified location.

Click to reveal answer
beginner
How do you create a new folder named Reports in PowerShell using New-Item?

Use New-Item -Path . -Name Reports -ItemType Directory to create a folder named Reports in the current directory.

Click to reveal answer
beginner
What parameter specifies the type of item to create with New-Item?

The -ItemType parameter tells New-Item what kind of item to create, like File or Directory.

Click to reveal answer
beginner
How can you create a new empty text file named notes.txt using New-Item?

Run New-Item -Path . -Name notes.txt -ItemType File to create an empty text file in the current folder.

Click to reveal answer
intermediate
What happens if you try to create an item with New-Item that already exists?

By default, New-Item will give an error if the item exists.

Click to reveal answer
Which parameter do you use with New-Item to create a folder?
A-ItemType Directory
B-Type Folder
C-Create Folder
D-Folder
What does New-Item -Path . -Name file.txt -ItemType File do?
ACreates a new folder named file.txt
BRenames a file to file.txt
CDeletes file.txt
DCreates a new file named file.txt
If the parent directories do not exist, what parameter helps New-Item -ItemType Directory?
A-Overwrite
B-Replace
C-Force
D-Update
Which of these is NOT a valid -ItemType value for New-Item?
ADirectory
BFolder
CLink
DFile
How do you create a new file named log.txt in a specific folder C:\Logs?
ANew-Item -Path C:\Logs -Name log.txt -ItemType File
BNew-Item -Path log.txt -Name C:\Logs -ItemType File
CNew-Item -Folder C:\Logs -File log.txt
DNew-Item -CreateFile log.txt -InFolder C:\Logs
Explain how to create a new folder and a new file using New-Item in PowerShell.
Think about what parameters tell PowerShell what to create and where.
You got /4 concepts.
    What should you do if you want to create an item but it already exists?
    Consider how to handle existing files or folders.
    You got /3 concepts.