Lab 1 PowerShell (3)
Lab 1 PowerShell (3)
Systems
One of the key advantages of PowerShell is that it is case-insensitive, meaning you can type
commands in any combination of uppercase or lowercase letters without affecting the outcome. To
make usage even more efficient, PowerShell includes aliases—shorter, alternative forms of cmdlets,
such as using cd in place of Set-Location. This allows users familiar with other command-line
interfaces, like Command Prompt or Linux's Bash shell, to transition smoothly into PowerShell.
Each cmdlet can be extended with additional parameters, enabling you to fine-tune commands and
control their output. For example, the -Recurse parameter in Get-ChildItem lets you list all
files in subdirectories, not just the current directory. This flexibility makes PowerShell a highly
customizable tool.
To start using PowerShell, simply click the Start menu, search for "PowerShell," and launch it.
1. Get-Location (pwd)
Description: Displays the current working directory (i.e., where you are located in the file
system).
Alias: pwd (similar to the Unix/Linux command).
• Task 1 Display Your Current Directory
1. Open PowerShell.
Page 1
Name: Department of Intelligent Reg #:
Systems
Page 2
Name: Department of Intelligent Reg #:
Systems
4. New-Item (ni)
Description: Creates a new file or directory.
Aliases: ni.
• Task 1 Create a New Directory
1. In PowerShell, type New-Item -Path C:\TestFolder -ItemType Directory.
2. Use Get-ChildItem C:\ to confirm that TestFolder was created.
• Task 2 Use Alias ni to Create a New Directory
1. In PowerShell, type ni -Path C:\TestFolder2 -ItemType Directory.
2. Verify the creation with Get-ChildItem C:\.
• Task 3 Create a New File in the Directory
1. In PowerShell, type New-Item -Path C:\TestFolder\MyFile.txt -
ItemType File.
2. Navigate to C:\TestFolder and run dir to check that MyFile.txt was created.
• Task 4 Write your observations
Page 3
Name: Department of Intelligent Reg #:
Systems
Page 4
Name: Department of Intelligent Reg #:
Systems
Page 5
Name: Department of Intelligent Reg #:
Systems
Page 6