0% found this document useful (0 votes)
20 views3 pages

OS Lab 3

OPERATING SYSTEM

Uploaded by

dk7113318
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)
20 views3 pages

OS Lab 3

OPERATING SYSTEM

Uploaded by

dk7113318
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/ 3

DEPARTMENT OF INFORMATION TECHNOLOGY

FACULTY OF ENGINEERING AND TECHNOLOGY


UNIVERSITY OF SINDH, JAMSHORO
LAB # 3
BSIT (Part-III)
SENG- 529 Operating Systems
Windows PowerShell Scripting
Institute of Information & Communication Technology
Student Name________________________________ Role No___________________________

LAB OBJECTIVE: To get familiar with windows power shell (command –line shell) and
working with its commands (cmdlets) and scripts.

INTRODUCTION

Windows PowerShell (PS) is a command-line shell and scripting language designed especially
for system administration. Its analogue in Linux is called as Bash Scripting. Built on the .NET
Framework, Windows PowerShell helps IT professionals to control and automate the
administration of the Windows operating system and applications that run on Windows Server
environment. Windows PowerShell commands, called cmdlets, let you manage the computers
from the command line. Windows PowerShell providers let you access data stores, such as the
Registry and Certificate Store, as easily as you access the file system.
Arithmetic operator in PS

Operator Description Example

Adds values on either side of the operator. A + B will give


+ (Addition)
30

Subtracts right-hand operand from left-hand operand. A - B will give -


- (Subtraction)
10

Multiplies values on either side of the operator. A * B will give


* (Multiplication)
200

/ (Division) Divides left-hand operand by right-hand operand. B / A will give 2

Divides left-hand operand by right-hand operand and


% (Modulus) B%A
returns remainder.

Comparison Operators
Operator Description Example

Compares two values to be equal or not. A -eq B will


eq (equals)
give false
DEPARTMENT OF INFORMATION TECHNOLOGY
FACULTY OF ENGINEERING AND TECHNOLOGY
UNIVERSITY OF SINDH, JAMSHORO
Compares two values to be not equal. A -ne B will
ne (not equals)
give true

Compares first value to be greater than second one. B -gt A will


gt (greater than)
give true

ge (greater than or Compares first value to be greater than or equals to B -ge A will
equals to) second one. give true

Logical Operators

Operator Description Example

Called Logical AND operator. If both the


AND (logical and) operands are non-zero, then the condition (A -AND B) is false
becomes true.

Called Logical OR Operator. If any of the two


OR (logical or) operands are non-zero, then the condition (A -OR B) is true
becomes true.

Called Logical NOT Operator. Use to reverses the


-NOT(A -AND B) is
NOT (logical not) logical state of its operand. If a condition is true
true
then Logical NOT operator will make false.

Variable declaration

$x = 10

Output function
write-host("This is first script")

Conditions
If: statement consists of a Boolean expression followed by one or more statements.

Syntax
Following is the syntax of an if statement −

if(Boolean_expression) {
// Statements will execute if the Boolean expression is true
}

$x = 10
DEPARTMENT OF INFORMATION TECHNOLOGY
FACULTY OF ENGINEERING AND TECHNOLOGY
UNIVERSITY OF SINDH, JAMSHORO
if($x -le 20){
write-host("This is if statement")

IF- esle

$x = 30

if($x -le 20){

write-host("This is if statement")

}else {

write-host("This is else statement")

Else-if

$x = 30

if($x -eq 10){


write-host("Value of X is 10")

} elseif($x -eq 20){

write-host("Value of X is 20")

} elseif($x -eq 30){

write-host("Value of X is 30")

} else {

write-host("This is else statement")

Exercise

 Write Shell Script which checks a number that whether it is even or odd and prints the
message on screen
 Write Shell Script which checks a number that whether it is positive or negative and
prints the message on screen
 Write Shell Script which compares 2 numbers and prints the greater

You might also like