0% found this document useful (0 votes)
15 views2 pages

Lab1 OS 23

PowerShell is a command line environment by Microsoft used for various tasks including system management and data handling. It provides numerous commands for managing processes, files, and system configurations. Batch files are scripts that execute a series of commands in order, often used for automating tasks, with basic commands such as ECHO, CLS, and COPY.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

Lab1 OS 23

PowerShell is a command line environment by Microsoft used for various tasks including system management and data handling. It provides numerous commands for managing processes, files, and system configurations. Batch files are scripts that execute a series of commands in order, often used for automating tasks, with basic commands such as ECHO, CLS, and COPY.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab1 OS Eng.

Shaima'a AL-Jabali
• What is PowerShell?

PowerShell is a command line environment developed by Microsoft that is based on the .NET Framework.
PowerShell can be used to perform many different tasks, such as managing the operating system,
controlling programs and services, managing networks, and handling data. It is also possible to use
PowerShell to manage Active Directory, Exchange Server, SQL Server and other popular servers and
applications

• Running PowerShell?
To run PowerShell in Windows 10 or 11, you can do one of the following:
1. Search for "PowerShell" in the Start menu search bar.
2. Press the "Win + X" button on your keyboard and choose "Windows PowerShell" or "Windows
PowerShell (Admin)" from the list.
3. From any empty place, for example: the desktop, pressing the shift button with the right mouse button,
and choosing PowerShell.

 Some commands in PowerShell:


 Get-Command
 Get-Help
 Get-Process
 Stop-Process
 Get-ChildItem ..... CHDIR
 Cd
 Dir
o Obtain a listing of all fi les and folders off the root that begin with the letter m. dir m*
 Cls ….. clear
 Md …… mkdir ……. Mkdir \1\2\3
 New-Item …. Notepad …. fsutil file createnew c:\test\myfile.txt 1000
 Get-Content
 Remove-Item
 Rename-Item
 Out-File
o Get-Process | Out-File C:\Users\UserName\Desktop\processes.tx
 Clear-Host
 Invoke-Expression
o "Invoke-Expression 'Get-Process | Where-Object {$_.Name -eq "chrome.exe "'}"
 Get-Location
 set-Location
 Get-Date
 Get-Alias
 Set-variable
o Set-Variable -Name myVar -Value 'Hello
 ipconfig /all
 route print
 hostname
o Pipeline the result of ipconfi g /all to a text fi le. This is illustrated here.
 C:\> ipconfig /all >ipconfig.txt
o Use multiple commands on a single Windows PowerShell line. Enter each complete
command, and then use a semicolon to separate the commands
 ipconfig /all >tshoot.txt; route print >>tshoot.txt

1
Lab1 OS Eng.Shaima'a AL-Jabali
o Use the New-Alias cmdlet to assign the G+H keystroke combination to the Get-Help cmdlet.
To do this, use the following command.
 New-Alias gh Get-Help

 What's Batch files?

A batch (or BAT) file represents a script file that stores a series of commands set to be executed in a serial
order. Such files are often used to load programs, run several simultaneous processes, or automate
repetitive tasks. Contrary to popular belief, creating BAT files doesn’t require advanced computer skills.

 Some basic commands of batch file:


1. ECHO – Prints out the input string. It can be ON or OFF, for ECHO to turn the echoing feature on
or off. If ECHO is ON, the command prompt will display the command it is executing.
2. CLS – Clears the command prompt screen.
3. TITLE – Changes the title text displayed on top of prompt window.
4. EXIT – To exit the Command Prompt.
5. PAUSE – Used to stop the execution of a Windows batch file.
6. :: / REM – Add a comment in the batch file.
7. COPY – Copy a file or files.

 Examples:

“@ECHO OFF
ECHO Hello and welcome to batch scripting! If you’re seeing this text, it means you’ve
successfully created a BAT file in Windows. Great job!
PAUSE”.

“@ECHO OFF
move Source-Path*.* Destination-Path”.

“ECHO OFF
copy [source] [destination]”.

“@ECHO OFF
DEL [file destination and name]”.

@ECHO OFF
REM This is a comment line.
REM Listing all the files in the directory Program files
DIR"C:\Program Files" > C:\geeks_list.txt
ECHO "Done!"
 Homework:
Run any batch file when the computer startup?

You might also like