From 968086a46f394176bf58116f944c538d866ea9fb Mon Sep 17 00:00:00 2001 From: Kareem Zahre Date: Tue, 16 Aug 2022 18:33:22 +0100 Subject: Switch Jump-Location to ZLocation Jump-Location is no longer maintained and ZLocation is the declared successor. --- powershell.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'powershell.html.markdown') diff --git a/powershell.html.markdown b/powershell.html.markdown index 318bf043..033d6c25 100644 --- a/powershell.html.markdown +++ b/powershell.html.markdown @@ -802,6 +802,6 @@ Interesting Projects * [Oh-My-Posh](https://github.com/JanDeDobbeleer/oh-my-posh) Shell customization similar to the popular Oh-My-Zsh on Mac * [PSake](https://github.com/psake/psake) Build automation tool * [Pester](https://github.com/pester/Pester) BDD Testing Framework -* [Jump-Location](https://github.com/tkellogg/Jump-Location) Powershell `cd` that reads your mind +* [ZLocation](https://github.com/vors/ZLocation) Powershell `cd` that reads your mind * [PowerShell Community Extensions](https://github.com/Pscx/Pscx) * [More on the Powershell Pipeline Issue](https://github.com/PowerShell/PowerShell/issues/1908) -- cgit v1.2.3 From 6c46b911f2cdf5b84d19ab0623db8b2eba493bb8 Mon Sep 17 00:00:00 2001 From: Tomasz Wojdat Date: Wed, 1 Nov 2023 21:28:26 +0100 Subject: Fix typo --- powershell.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'powershell.html.markdown') diff --git a/powershell.html.markdown b/powershell.html.markdown index 033d6c25..0383035b 100644 --- a/powershell.html.markdown +++ b/powershell.html.markdown @@ -574,7 +574,7 @@ Get-Process | Foreach-Object ProcessName | Group-Object 1..10 | ForEach-Object { "Loop number $PSITEM" } 1..10 | Where-Object { $PSITEM -gt 5 } | ConvertTo-Json -# A notable pitfall of the pipeline is it's performance when +# A notable pitfall of the pipeline is its performance when # compared with other options. # Additionally, raw bytes are not passed through the pipeline, # so passing an image causes some issues. -- cgit v1.2.3 From d123cd4a5c6599401e20c5d4190173d75cddd520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Peeters?= Date: Sun, 25 Feb 2024 23:36:47 +0100 Subject: [powershell/en] Fix and clarify -eq operator on (some) objects (#4333) --- powershell.html.markdown | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'powershell.html.markdown') diff --git a/powershell.html.markdown b/powershell.html.markdown index 0383035b..2e7539a5 100644 --- a/powershell.html.markdown +++ b/powershell.html.markdown @@ -118,14 +118,15 @@ $False - 5 # => -5 2 -lt 3 -and 3 -lt 2 # => False # (-is vs. -eq) -is checks if two objects are the same type. -# -eq checks if the objects have the same values. +# -eq checks if the objects have the same values, but sometimes doesn't work +# as expected. # Note: we called '[Math]' from .NET previously without the preceeding # namespaces. We can do the same with [Collections.ArrayList] if preferred. [System.Collections.ArrayList]$a = @() # Point a at a new list $a = (1,2,3,4) $b = $a # => Point b at what a is pointing to $b -is $a.GetType() # => True, a and b equal same type -$b -eq $a # => True, a and b values are equal +$b -eq $a # => None! See below [System.Collections.Hashtable]$b = @{} # => Point a at a new hash table $b = @{'one' = 1 'two' = 2} @@ -154,6 +155,13 @@ $age = 22 "$name's name is $($name.Length) characters long." # => "Steve's name is 5 characters long." +# Strings can be compared with -eq, but are case insensitive. We can +# force with -ceq or -ieq. +"ab" -eq "ab" # => True +"ab" -eq "AB" # => True! +"ab" -ceq "AB" # => False +"ab" -ieq "AB" # => True + # Escape Characters in Powershell # Many languages use the '\', but Windows uses this character for # file paths. Powershell thus uses '`' to escape characters @@ -274,6 +282,10 @@ $array.AddRange($otherArray) # Now $array is [1, 2, 3, 4, 5, 6] # Examine length with "Count" (Note: "Length" on arrayList = each items length) $array.Count # => 6 +# -eq doesn't compare array but extract the matching elements +$array = 1,2,3,1,1 +$array -eq 1 # => 1,1,1 +($array -eq 1).Count # => 3 # Tuples are like arrays but are immutable. # To use Tuples in powershell, you must use the .NET tuple class. -- cgit v1.2.3 From ae7197c6a692f9b67e98a721ed5debb582bfa599 Mon Sep 17 00:00:00 2001 From: Boris Verkhovskiy Date: Wed, 3 Apr 2024 04:14:45 -0700 Subject: [powershell/*] fix syntax highlighting --- powershell.html.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'powershell.html.markdown') diff --git a/powershell.html.markdown b/powershell.html.markdown index 2e7539a5..50e1e27e 100644 --- a/powershell.html.markdown +++ b/powershell.html.markdown @@ -677,7 +677,7 @@ Powershell as a Tool: Getting Help: -```Powershell +```powershell # Find commands Get-Command about_* # alias: gcm Get-Command -Verb Add @@ -694,7 +694,7 @@ Update-Help # Run as admin If you are uncertain about your environment: -```Powershell +```powershell Get-ExecutionPolicy -List Set-ExecutionPolicy AllSigned # Execution policies include: @@ -708,7 +708,7 @@ help about_Execution_Policies # for more info $PSVersionTable ``` -```Powershell +```powershell # Calling external commands, executables, # and functions with the call operator. # Exe paths with arguments passed or containing spaces can create issues. -- cgit v1.2.3