EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 360+ Courses All in One Bundle
  • Login
Home Data Science Data Science Tutorials PowerShell Tutorial PowerShell not like
Secondary Sidebar
PowerShell Tutorial
  • Functions
    • PowerShell Functions
    • PowerShell String Functions
    • powershell nslookup
    • PowerShell here string
    • PowerShell Wildcards
    • Regex in PowerShell
    • PowerShell not like
    • PowerShell Filter
    • PowerShell Sleep
    • PowerShell where
    • PowerShell join string
    • PowerShell Exit
    • PowerShell null
    • PowerShell Dictionary
    • PowerShell Location
    • PowerShell Start-Service
    • PowerShell is not digitally signed
    • PowerShell Uptime
    • PowerShell Create Directory
    • PowerShell Trim
    • PowerShell Join-Path
    • PowerShell Execution Policy
    • PowerShell SubString
    • PowerShell Format Table
    • PowerShell Import Module
    • PowerShell ForEach Object
    • PowerShell Alias
    • PowerShell Scheduled Task
    • PowerShell Convert String to Date
    • PowerShell Split String
    • PowerShell Multiline String
    • PowerShell MultiLine Comment
    • PowerShell Rename Folder
    • PowerShell Delete Folder
    • PowerShell String Replace
    • PowerShell join
    • PowerShell xcopy
    • PowerShell Base64
    • PowerShell Tail
    • PowerShell User List
    • PowerShell remove User from group
    • PowerShell JSON Format
    • PowerShell Send Mail
    • PowerShell Convert to String
    • PowerShell Start-Process
    • PowerShell change directory
    • PowerShell Open File
    • PowerShell Batch File
    • PowerShell ZIP
    • PowerShell unzip
    • PowerShell XML
    • PowerShell XML Parsing
    • Remote PowerShell
    • PowerShell Escape Character
    • PowerShell scriptblock
    • PowerShell Executable Location
    • PowerShell Import-CSV?
    • PowerShell Export CSV
  • Basics
    • PowerShell Restart Service
    • PowerShell comment
    • PowerShell Map Network Drive
    • PowerShell Append to File
    • PowerShell print
    • What is PowerShell
    • Uses Of Powershell
    • PowerShell Empire
    • PowerShell Parameter
    • PowerShell Stop Service
    • PowerShell Versions
    • How To Install PowerShell
    • PowerShell uninstall module
    • How to Use PowerShell?
    • PowerShell Logging
    • PowerShell Tools
    • PowerShell Commands
    • PowerShell Version Command
    • PowerShell Administrator
    • PowerShell Modules
    • PowerShell Registry
    • PowerShell block Comment
    • PowerShell Verbs
    • PowerShell list
    • PowerShell add user to group
    • PowerShell Write to Console
    • Variable in PowerShell
    • PowerShell New Line
    • PowerShell prompt for input
    • PowerShell File Extension
    • Powershell Remotesigned
    • PowerShell Write to File
    • PowerShell Ping
    • PowerShell wget
    • PowerShell Global variable
    • PowerShell Get-ADGroup
    • Array in PowerShell
    • PowerShell Multidimensional Array
    • PowerShell Array of Strings
    • PowerShell? join array
    • Useful PowerShell Scripts
    • String in PowerShell
    • PowerShell Switch Statement
    • PowerShell Function Parameters
    • PowerShell vs PowerShell ISE
    • PowerShell test-connection
    • PowerShell Test-NetConnection
    • PowerShell GUI
    • PowerShell Variable in String
    • PowerShell Active Directory
  • Variables
    • PowerShell Variables
    • PowerShell Environment Variables
    • PowerShell set environment variable
    • Hashtable in PowerShell
    • Set Variable in PowerShell
  • Operators
    • PowerShell Operators
    • Comparison Operators in PowerShell
    • Logical Operators in PowerShell
    • PowerShell Boolean
    • PowerShell Like Operator
  • cmdlet
    • PowerShell Wait
    • PowerShell Match
    • cmdlets in PowerShell
    • Start PowerShell from cmd
    • Add-Content in PowerShell
    • Get Help in PowerShell
    • PowerShell Copy-Item
    • PowerShell Remove-Item
    • PowerShell Move-Item
    • Get Command in PowerShell
    • PowerShell Run Command
    • Windows PowerShell ISE
    • Windows Powershell Commands
    • WinRM PowerShell
    • PowerShell Date
    • Powershell Write-Host
    • PowerShell Get-ChildItem
    • PowerShell Sort-Object
    • PowerShell Where Object
    • PowerShell Set-Content
    • PowerShell Set-Location
    • PowerShell Invoke-Command
    • PowerShell Invoke-Webrequest
    • PowerShell Get-Location
    • PowerShell Get-Date
    • PowerShell Get-Service
    • PowerShell Test-Path
    • Powershell Module Path
    • PowerShell Out-File
    • PowerShell if File Exists
    • Powershell Copy File
    • PowerShell Delete File
    • PowerShell New-Item
    • PowerShell Rename-Item
    • PowerShell ComputerName
    • PowerShell Get-Content
    • PowerShell Get-Item
    • PowerShell Get-ADUser
    • PowerShell Grep
    • PowerShell Concatenate String
    • PowerShell Get-Process
    • PowerShell Count
    • PowerShell pause
  • Control Statements
    • If Statement in PowerShell
    • If Else in PowerShell
    • Else If in PowerShell
    • Loops in PowerShell
    • For loop in PowerShell
    • PowerShell While Loop
    • PowerShell do while
    • PowerShell Loop through Array
    • PowerShell add to array
    • PowerShell ForEach Loop
    • PowerShell Break
    • PowerShell Continue
    • Switch Case in PowerShell
    • PowerShell If-Not
    • Try-catch in PowerShell
  • Interview Questions
    • PowerShell Interview Questions

Related Courses

Shell Scripting Course

All in One Data Science Courses

Data Visualization Courses

PowerShell not like

By Priya PedamkarPriya Pedamkar

PowerShell not like

Introduction to PowerShell not like

The following article provides an outline for PowerShell not like. Comparison operators let the users indicate conditions for comparing values and finding values that satisfies the mentioned condition. To utilize a comparison operator, indicate the values that you just need to compare along with an operator that isolates these values. The not like operator is a type of matching comparison operator. This along with like, match and not match operators are part of the matching comparison operator type. The not like operator returns true if the string doesn’t match the specified condition. Here we will see about not like operator along with other matching operators.

Syntax of not like operator:

Given below is the syntax of not like operator:

<string[]> -notlike <wildcard-expression>

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Example:

Code:

"vigneshkrishnakumar" -notlike "*mar"
"vigneshkrishnakumar" -notlike "*sethu"

Output:

PowerShell not like 1

Working of not like Operator

The like operator uses wild card expression for comparison. For example, let us consider a sentence “how old are you?” If we execute the cmdlet “how old are you” -like “*you”, the cmdlet will return true however if the cmdlet is modified to “how old are you” -like “you”, the cmdlet will return false. It is due to the asterisk symbol before you. The asterisk symbol stands for wild card expressions.

If the wildcard is present in the beginning of the comparison text, it means anything can be before the searched expression whereas if the asterisk is present at the end, it means the searched expression should have something followed by it. In the above example if the asterisk is placed after the text it will return false. The not like operator is the exact opposite of the like operator. It will return true when there the condition is false and false when there is a match.

Example:

Code:

Write-Host " wild card before the comparison text" -ForegroundColor Green
“my name is Vignesh krishnakumar” -like “*is”
Write-Host "no wild card involved" -ForegroundColor Green
“my name is Vignesh krishnakumar” -like “is”
Write-Host "wild card after the comparison text"-ForegroundColor Green
“my name is Vignesh krishnakumar” -like “is*”
Write-Host " wild card before the comparison text" -ForegroundColor Green
“my name is Vignesh krishnakumar” -notlike “*is”
Write-Host "no wild card involved" -ForegroundColor Green
“my name is Vignesh krishnakumar” -notlike “is”
Write-Host "wild card after the comparison text"-ForegroundColor Green
“my name is Vignesh krishnakumar” -notlike “is*”

All in One Data Science Bundle(360+ Courses, 50+ projects)
Python TutorialMachine LearningAWSArtificial Intelligence
TableauR ProgrammingPowerBIDeep Learning
Price
View Courses
360+ Online Courses | 50+ projects | 1500+ Hours | Verifiable Certificates | Lifetime Access
4.7 (86,241 ratings)

Output:

PowerShell not like 2

Comparing like and not like with match and not match

Another type of comparison operator is match / non match operator. Although comparative to Like, it’s much more PowerShell (however a small more complicated). The match or non match operators administrator employments customary expressions (regex). This is often a gigantic advantage and gives Coordinate an unequivocal leg up on Like. In any case, in case you’ve never utilized customary expressions some time recently, plan yourself. Let’s go with our past illustration string once more.

Syntax for match and not match operator:

<string[]> -match <regular-expression>

<string[]> -notmatch <regular-expression>

Example #1:

Code:

"sun", "mon","tue","wed","thu","fri","sat" -match "su"
"viki", "vignesh","vikiii","vikii","nandhini","vyapini","sethu" -notmatch "viki"

Output:

PowerShell not like 3

Example #2:

Code:

Write-Host " wild card before the comparison text" -ForegroundColor Green
“my name is Vignesh krishnakumar” -match “*is”
Write-Host "no wild card involved" -ForegroundColor Green
“my name is Vignesh krishnakumar” -match “is”
Write-Host "wild card after the comparison text"-ForegroundColor Green
“my name is Vignesh krishnakumar” -match “is*”
Write-Host " wild card before the comparison text" -ForegroundColor Green
“my name is Vignesh krishnakumar” -notmatch “*is”
Write-Host "no wild card involved" -ForegroundColor Green
“my name is Vignesh krishnakumar” -notmatch “is”
Write-Host "wild card after the comparison text"-ForegroundColor Green
“my name is Vignesh krishnakumar” -notmatch “is*”

Output:

wild card before comparison text

As you can see from the above output, the match operator doesn’t work with wild card expressions.

Example #3:

Code:

$start=(Get-Date).Millisecond
Write-Host " wild card before the comparison text" -ForegroundColor Green
“corona originated in china but now it is cured there” -like “*there”
Write-Host "no wild card involved" -ForegroundColor Green
“corona originated in china but now it is cured there” -like “there”
Write-Host "wild card after the comparison text"-ForegroundColor Green
“corona originated in china but now it is cured there” -like “there*”
Write-Host "wild card before the comparison text"-ForegroundColor Green
“corona originated in china but now it is cured there” -notlike “*there”
Write-Host "no wild card involved" -ForegroundColor Green
“corona originated in china but now it is cured there” -notlike “there”
Write-Host "wild card after the comparison text" -ForegroundColor Green
“corona originated in china but now it is cured there” -notlike “there*”
$end=(Get-Date).Millisec
Write-Host "Total time in milli seconds for like and not like: $($start-$end)" -ForegroundColor Yellow
$start1=(Get-Date).Millisecond
Write-Host " wild card before the comparison text" -ForegroundColor Green
“corona originated in china but now it is cured there” -match “there”
Write-Host "no wild card involved" -ForegroundColor Green
“corona originated in china but now it is cured there” -match “now”
Write-Host "wild card after the comparison text"-ForegroundColor Green
“corona originated in china but now it is cured there” -match “america”
Write-Host "wild card before the comparison text"-ForegroundColor Green
“corona originated in china but now it is cured there” -notmatch “america”
Write-Host "no wild card involved" -ForegroundColor Green
“corona originated in china but now it is cured there” -notmatch “sweden”
Write-Host "wild card after the comparison text" -ForegroundColor Green
“corona originated in china but now it is cured there” -notmatch "china”
$end1=(Get-Date).Millisec
Write-Host "Total time in milli seconds for match and not match: $($start1-$end1)" -ForegroundColor Yellow

Output:

wild card before the comparison text

As you can see from the above output, like and not like took lesser time to execute.

Conclusion – PowerShell not like

Thus, in this article we saw about the not like operator in detail. Here we saw the syntax, the usage and its advantage with appropriate examples. Here we also saw the match and not match operators and its similarities and differences with not like operator.

Recommended Articles

This is a guide to PowerShell not like. Here we discuss working of not like operator and comparing like and not like with match and not match. You may also have a look at the following articles to learn more –

  1. PowerShell Continue
  2. Windows PowerShell ISE
  3. PowerShell Rename Folder
  4. PowerShell Get-Service
Popular Course in this category
PowerShell Training (2 Courses, 1 Project)
  2 Online Courses |  1 Hands-on Project |   4+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course

Related Courses

Shell Scripting Training (4 Courses, 1 Project)4.9
All in One Data Science Bundle (360+ Courses, 50+ projects)4.8
Data Visualization Training (15 Courses, 5+ Projects)4.7
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Data Science Course

SPSS, Data visualization with Python, Matplotlib Library, Seaborn Package

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more