In this Video, You will learn about PowerShell Operators in Detail.
By the end of this Section, you will come to know many things about PowerShell Operators like :
---- What are PowerShell Operators ?
---- Different type of Operators ?
---- How to use them in different scenarios.
---- Arithmetic Operators
---- Assignment Operators
#####################################################
CODE and COMMANDS THAT HAS BEEN USED IN THIS VIDEO DEMOS -
#####################################################
arithmetic operators (+, -, *, /, %)
[int]$1stnumber = Read-host "Ente1r Ist number "
[int]$2ndnumber = Read-host "Enter 2nd number "
Write-Host "Sum of these Numbers is $($1stnumber + $2ndnumber)"
Write-Host "Multiplication of these Numbers is $($1stnumber * $2ndnumber)"
Write-Host "Result of this Division Operation is $($1stnumber / $2ndnumber)"
Write-Host "Remainder this of Division Operation is $($1stnumber % $2ndnumber)"
Arithmetic Operator with Strings
$1stSring = "Best"
$2ndString = "Test"
Write-Host "Sum of these Strings is $($1stSring + $2ndString)"
Write-Host "Multiplication of these Numbers is $($1stSring * 8)"
########################################################################
New-Item -Name $("Test_" + "File_" + (Date).DayOfWeek + ".txt")
##########################################################################
##########################################################################
######################## Assignment Operators
$MyNumber = 100
"Now my Number is $MyNumber"
$Mynumber += 50
"Now my Number is $MyNumber"
$Mynumber -= 50
"Now my Number is $MyNumber"
$Mynumber *= 50
"Now my Number is $MyNumber"
$Mynumber /= 50
"Now my Number is $MyNumber"
$Mynumber %= 50
"Now my Number is $MyNumber"
Assignment Operators with Strings
$Value = "Test"
$Value
$Value += 2
$Value
$Value *= 2
$Value
###############################################################
###############################################################
Comparision Operators - Equality Operators - In case of Single/Scaler Values
$X = 50
$Y = 100
If ($X -eq $Y)
{Write-Host "This condition is True"}
else
{Write-Host "This condition is False"}
If ($X -ne $Y)
{Write-Host "This condition is True"}
else
{Write-Host "This condition is False"}
If ($X -gt $Y)
{Write-Host "This condition is True"}
else
{Write-Host "This condition is False"}
If ($X -ge $Y)
{Write-Host "This condition is True"}
else
{Write-Host "This condition is False"}
If ($X -lt $Y)
{Write-Host "This condition is True"}
else
{Write-Host "This condition is False"}
If ($X -ge $Y)
{Write-Host "This condition is True"}
else
{Write-Host "This condition is False"}
Comparision Operators - Equality Operators - In case of Collection
"Test", "best","test" -eq "test"
"Test", "best","test" -ne "test"
4,5,8,6,2,1 -gt 2
4,5,8,6,2,1 -lt 2
4,5,8,6,2,1 -ge 2
4,5,8,6,2,1 -le 2
************************************************************************
************************************************************************
Join Me on --
Facebook Group
/ mylearningsonline
Facebook Page
/ mylearningsonline
YouTube Channel
/ mylearningsonline
**************************************************************************
#PowerShell #PowerShellScripting #PowerShellForBeginners #learnPowerShell #PowerShelltraining #PowerShellTutorial #MyLearningsOnline
PowerShell Scripting for Beginners
PowerShell Tutorial for Beginners
PowerShell Full Course
PowerShell Training for Beginners