0
0
PowerShellscripting~10 mins

New-Item for creation in PowerShell - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new folder named 'TestFolder' in the current directory.

PowerShell
New-Item -Path . -Name 'TestFolder' -ItemType [1]
Drag options to blanks, or click blank then click option'
ADirectory
BFile
CLink
DSymbolicLink
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'File' instead of 'Directory' creates a file, not a folder.
Omitting the -ItemType parameter creates a file by default.
2fill in blank
medium

Complete the code to create a new empty file named 'notes.txt' in the 'Documents' folder.

PowerShell
New-Item -Path $HOME\Documents -Name 'notes.txt' -ItemType [1]
Drag options to blanks, or click blank then click option'
AText
BFile
CFolder
DDirectory
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Directory' creates a folder, not a file.
Using 'Text' is not a valid ItemType.
3fill in blank
hard

Fix the error in the code to create a new folder named 'Projects' in 'C:\Users\Public'.

PowerShell
New-Item -Path 'C:\Users\Public' -Name 'Projects' -ItemType [1]
Drag options to blanks, or click blank then click option'
AFile
BFolder
CLink
DDirectory
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Folder' instead of 'Directory' causes an error.
Using 'File' creates a file, not a folder.
4fill in blank
hard

Fill both blanks to create a new file named 'log.txt' in the 'C:\Temp' directory and force overwrite if it exists.

PowerShell
New-Item -Path [1] -Name [2] -ItemType File -Force
Drag options to blanks, or click blank then click option'
A'C:\Temp'
B'log.txt'
C'C:\Logs'
D'data.txt'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the path and name values.
Using a wrong path or file name.
5fill in blank
hard

Fill all three blanks to create a new directory named 'Backup' inside 'D:\Data' and confirm creation with a message.

PowerShell
$folder = New-Item -Path [1] -Name [2] -ItemType [3]; Write-Host "Created folder: $($folder.FullName)"
Drag options to blanks, or click blank then click option'
A'D:\Data'
B'Backup'
CDirectory
DFile
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'File' instead of 'Directory' for folder creation.
Incorrect path or name values.