0
0
PowerShellscripting~15 mins

New-Item for creation in PowerShell - Mini Project: Build & Apply

Choose your learning style9 modes available
Create Files and Folders Using New-Item
📖 Scenario: You are organizing your project folder. You need to create a new folder and a new file inside it using PowerShell commands.
🎯 Goal: Learn how to use the New-Item cmdlet to create a folder and a file in PowerShell.
📋 What You'll Learn
Create a new folder named ProjectDocs
Create a new text file named README.txt inside the ProjectDocs folder
Use the New-Item cmdlet for both creations
Display the full path of the created file
💡 Why This Matters
🌍 Real World
Creating folders and files automatically is common when setting up projects or organizing data.
💼 Career
System administrators and automation engineers often use PowerShell scripts to prepare environments and manage files efficiently.
Progress0 / 4 steps
1
Create a new folder named ProjectDocs
Write a PowerShell command using New-Item to create a folder named ProjectDocs in the current directory.
PowerShell
Need a hint?

Use -ItemType Directory to create a folder.

2
Set the folder path in a variable
Create a variable called $folderPath and set it to the path ./ProjectDocs.
PowerShell
Need a hint?

Use $folderPath = './ProjectDocs' to store the folder path.

3
Create a new text file README.txt inside ProjectDocs
Use New-Item with -Path set to $folderPath and -Name set to README.txt to create a new file inside the folder.
PowerShell
Need a hint?

Use -ItemType File to create a file.

4
Display the full path of the created README.txt file
Assign the result of the New-Item command creating README.txt to a variable called $newFile. Then print the full path of the file using Write-Output and $newFile.FullName.
PowerShell
Need a hint?

Store the created file in $newFile and print $newFile.FullName.