In this Video, You will learn about PowerShell Operators (Theory & Demo) about -
-- Comparison Operators
-------- Equality Operators
------- Matching Operators
------- Containment Operators
------- Replacement Operator
------- Type Operators
###################################################
Code & Commands, that has been used in this Video is mentioned Below, You can please Practice using this code.
###################################################
Comparison 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"}
Comparison 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
######################################################
######################################################
Comparison Operators - Matching Operators - In case of Scaler Values
"Test" -like "*test*"
"Test" -notlike "*test*"
Get-Service|Where-Object {$_.DisplayName -like "*Windows Update*"}
Get-Service|Where-Object {$_.DisplayName -notlike "*Windows Update*"}
"PowerShell" -match 'shell'
"PowerShell" -notmatch 'shell'
Comparision Operators - Matching Operators - In case of Collection of Values
"Test", "best","test" -like "*test*"
"Test", "best","test" -notlike "*test*"
######################################################
######################################################
Comparision Operators - Containment Operators
"Test", "Best", "Chest" -contains "Best"
"Test", "Best", "Chest" -notcontains "Best"
"Best" -in "Test", "Best", "Chest"
"Best" -notin "Test", "Best", "Chest"
######################################################
######################################################
Comparison Operators - Replacement Operators
"Test Value" -replace 'Te', 'Be'
1..5|foreach {New-Item -Name $("file" + $_ + ".txt")}
Get-ChildItem *.txt | foreach {Rename-Item $_.Name -NewName $($_.name -replace '.txt','.log')}
Get-ChildItem *.txt | foreach {Rename-Item $_.Name -NewName $($_.name -replace '.log','.txt')}
######################################################
######################################################
Comparision Operators - Type Operators
$A = 2
$A -is [int]
$A -isNOT [int]
$A | Get-Member
************************************************************************
************************************************************************
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