Thanks to visit codestin.com
Credit goes to www.scribd.com

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

PowerShell Commands for OS Course

Uploaded by

mohamedtraka321
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

PowerShell Commands for OS Course

Uploaded by

mohamedtraka321
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

Alexandria University - Faculty of Science

Course: Operating Systems


Lecturer: Dr. Ahmed Younes

Example
PowerShell:

To get the policy of execution of powershell script:

Get-ExecutionPolicy
Set-ExecutionPolicy -Scope CurrentUser "then" enter policy

Viewing Objects in a Directory:

Get-ChildItem -path C:\Users\Carnival\Desktop

Get-ChildItem C:\Users\Carnival\Desktop -Recurse

Get-ChildItem -Path C:\Users\Carnival\Desktop -Recurse -Include ‘*.txt’ | Where-Object


{($_.LastWriteTime -gt '2024-03-28')}

Pipe:

"Welcome to powershell" | Out-File C:\Users\Carnival\Desktop\OS\LAB\file2.txt

Get-Service | WHERE {$_.status -eq "Running"} | SELECT displayname

Creating Files and Folders:

New-Item -Path 'C:\Users\Carnival\Desktop\os' -ItemType Directory

New-Item -Path 'C:\Users\Carnival\Desktop\oslab.txt' -ItemType File

Delete file or directory:

Remove-Item -Path 'C:\Users\Carnival\Desktop\oslab.txt'

Remove-Item -Path 'C:\Users\Carnival\Desktop\os' -Recurse //delete dir and subdir


Alexandria University - Faculty of Science
Course: Operating Systems
Lecturer: Dr. Ahmed Younes

Get-ChildItem -Path C:\Users\Carnival\Desktop\Newfolder -Recurse -Include ‘lab*’ |


Where-Object {($_.LastWriteTime -gt '2024-03-28')} | Remove-item -force

Copying Files and Folders:

Copy-Item -Path ‘C:\Users\Carnival\Desktop\OS\cp.txt’ -Destination


‘C:\Users\Carnival\Desktop\OS\file3.txt’

Moving Files and Directories:

Move-Item -Path "C:\Users\Carnival\Desktop\OS\cp.txt" -Destination


"C:\Users\Carnival\Desktop\DB 2024\cp.txt"

Rename:

Rename-Item -Path "C:\Users\Carnival\Desktop\os.txt" -NewName "labos.txt"

You might also like