From 79262d8402661825f6f8f87f70b41e99f0879414 Mon Sep 17 00:00:00 2001 From: Phil Anderson Date: Wed, 27 Oct 2021 16:59:11 +0100 Subject: [PATCH 1/2] Update Installing-PowerShell-on-Windows.md (#8264) * Update Installing-PowerShell-on-Windows.md Existing notes on the correct way to install powershell using `winget` were inaccurate. I have added more complete notes which add installing by name, id and also version. The existing command using the `exact` parameter was incorrect so I have removed it. * Update reference/docs-conceptual/install/Installing-PowerShell-on-Windows.md Co-authored-by: Sean Wheeler * Update Installing-PowerShell-on-Windows.md However I tried the syntax of your suggested change @sdwheeler and still found this syntax to be incorrect. I have therefore proposed a change which works syntactically and Powershell accepts. Please review the changes and let me know what you think. Thank you. Co-authored-by: Sean Wheeler --- .../install/Installing-PowerShell-on-Windows.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reference/docs-conceptual/install/Installing-PowerShell-on-Windows.md b/reference/docs-conceptual/install/Installing-PowerShell-on-Windows.md index 0859ae541fd0..3a5e44c7f4d0 100644 --- a/reference/docs-conceptual/install/Installing-PowerShell-on-Windows.md +++ b/reference/docs-conceptual/install/Installing-PowerShell-on-Windows.md @@ -137,11 +137,11 @@ PowerShell Microsoft.PowerShell 7.1.5.0 winget Powershell Preview Microsoft.PowerShell.Preview 7.2.0.10 winget ``` -Install a version of PowerShell using the `--exact` parameter +Install Powershell or Powershell Preview using the `id` parameter ```powershell -winget install --name PowerShell --exact --source winget -winget install --name PowerShell-Preview --exact --source winget +winget install --id Microsoft.Powershell --source winget +winget install --id Microsoft.Powershell.Preview --source winget ``` ## Installing from the Microsoft Store From c5fec7175958dae7f31a4838d417e3cd9d2174c9 Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Wed, 27 Oct 2021 16:01:06 -0500 Subject: [PATCH 2/2] Add `$this` for event senders (#8265) --- .../About/about_Automatic_Variables.md | 33 ++++++++++++++++--- .../About/about_Automatic_Variables.md | 33 ++++++++++++++++--- .../About/about_Automatic_Variables.md | 33 ++++++++++++++++--- .../About/about_Automatic_Variables.md | 33 ++++++++++++++++--- 4 files changed, 112 insertions(+), 20 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md index 0fe0bcef42b5..3f70d612f4b8 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md @@ -1,7 +1,7 @@ --- description: Describes variables that store state information for PowerShell. These variables are created and maintained by PowerShell. Locale: en-US -ms.date: 08/24/2021 +ms.date: 10/27/2021 no-loc: [Reset, Current, Background, Blink, Bold, Foreground, Formatting, Hidden, Italic, Reset, Reverse, Underline] online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 @@ -561,11 +561,34 @@ and change the current loop iteration. For more information, see ### $this -In a script block that defines a script property or script method, the `$this` -variable refers to the object that is being extended. +The `$this` variable is used in script blocks that extend classes to refer to +the instance of the class itself. -In a custom class, the `$this` variable refers to the class object itself -allowing access to properties and methods defined in the class. +PowerShell's Extensible Type System (ETS) allows you to add properties to +classes using script blocks. In a script block that defines a script property +or script method, the `$this` variable refers to an instance of object of the +class that is being extended. For example, PowerShell uses ETS to add the +**BaseName** property to the **FileInfo** class. + +```powershell +PS> Get-ChildItem .\README.md | Get-Member BaseName | Format-List + +TypeName : System.IO.FileInfo +Name : BaseName +MemberType : ScriptProperty +Definition : System.Object BaseName {get=if ($this.Extension.Length -gt 0){$this.Name.Remove($this.Name.Length - + $this.Extension.Length)}else{$this.Name};} +``` + +For more information, see [about_Types.ps1xml](./about_Types.ps1xml.md). + +In a PowerShell class, the `$this` variable refers to the instance object of +the class itself, allowing access to properties and methods defined in the +class. For more information, see [about_Classes](about_Classes.md). + +The `$this` variable is also used by .NET event classes that take script blocks +as delegates for the event handler. In this scenario, `$this` represents the +object originating the event, known as the event sender. ### $true diff --git a/reference/7.0/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md b/reference/7.0/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md index db8cee003ac7..1de5bc91075c 100644 --- a/reference/7.0/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md +++ b/reference/7.0/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md @@ -1,7 +1,7 @@ --- description: Describes variables that store state information for PowerShell. These variables are created and maintained by PowerShell. Locale: en-US -ms.date: 08/24/2021 +ms.date: 10/27/2021 no-loc: [Reset, Current, Background, Blink, Bold, Foreground, Formatting, Hidden, Italic, Reset, Reverse, Underline] online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 @@ -592,11 +592,34 @@ and change the current loop iteration. For more information, see ### $this -In a script block that defines a script property or script method, the `$this` -variable refers to the object that is being extended. +The `$this` variable is used in script blocks that extend classes to refer to +the instance of the class itself. -In a custom class, the `$this` variable refers to the class object itself -allowing access to properties and methods defined in the class. +PowerShell's Extensible Type System (ETS) allows you to add properties to +classes using script blocks. In a script block that defines a script property +or script method, the `$this` variable refers to an instance of object of the +class that is being extended. For example, PowerShell uses ETS to add the +**BaseName** property to the **FileInfo** class. + +```powershell +PS> Get-ChildItem .\README.md | Get-Member BaseName | Format-List + +TypeName : System.IO.FileInfo +Name : BaseName +MemberType : ScriptProperty +Definition : System.Object BaseName {get=if ($this.Extension.Length -gt 0){$this.Name.Remove($this.Name.Length - + $this.Extension.Length)}else{$this.Name};} +``` + +For more information, see [about_Types.ps1xml](./about_Types.ps1xml.md). + +In a PowerShell class, the `$this` variable refers to the instance object of +the class itself, allowing access to properties and methods defined in the +class. For more information, see [about_Classes](about_Classes.md). + +The `$this` variable is also used by .NET event classes that take script blocks +as delegates for the event handler. In this scenario, `$this` represents the +object originating the event, known as the event sender. ### $true diff --git a/reference/7.1/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md b/reference/7.1/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md index d0af097a9bec..ae4544332d3b 100644 --- a/reference/7.1/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md +++ b/reference/7.1/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md @@ -1,7 +1,7 @@ --- description: Describes variables that store state information for PowerShell. These variables are created and maintained by PowerShell. Locale: en-US -ms.date: 08/24/2021 +ms.date: 10/27/2021 no-loc: [Reset, Current, Background, Blink, Bold, Foreground, Formatting, Hidden, Italic, Reset, Reverse, Underline] online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 @@ -592,11 +592,34 @@ and change the current loop iteration. For more information, see ### $this -In a script block that defines a script property or script method, the `$this` -variable refers to the object that is being extended. +The `$this` variable is used in script blocks that extend classes to refer to +the instance of the class itself. -In a custom class, the `$this` variable refers to the class object itself -allowing access to properties and methods defined in the class. +PowerShell's Extensible Type System (ETS) allows you to add properties to +classes using script blocks. In a script block that defines a script property +or script method, the `$this` variable refers to an instance of object of the +class that is being extended. For example, PowerShell uses ETS to add the +**BaseName** property to the **FileInfo** class. + +```powershell +PS> Get-ChildItem .\README.md | Get-Member BaseName | Format-List + +TypeName : System.IO.FileInfo +Name : BaseName +MemberType : ScriptProperty +Definition : System.Object BaseName {get=if ($this.Extension.Length -gt 0){$this.Name.Remove($this.Name.Length - + $this.Extension.Length)}else{$this.Name};} +``` + +For more information, see [about_Types.ps1xml](./about_Types.ps1xml.md). + +In a PowerShell class, the `$this` variable refers to the instance object of +the class itself, allowing access to properties and methods defined in the +class. For more information, see [about_Classes](about_Classes.md). + +The `$this` variable is also used by .NET event classes that take script blocks +as delegates for the event handler. In this scenario, `$this` represents the +object originating the event, known as the event sender. ### $true diff --git a/reference/7.2/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md b/reference/7.2/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md index 612870bdcfed..487703729edb 100644 --- a/reference/7.2/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md +++ b/reference/7.2/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md @@ -1,7 +1,7 @@ --- description: Describes variables that store state information for PowerShell. These variables are created and maintained by PowerShell. Locale: en-US -ms.date: 08/24/2021 +ms.date: 10/27/2021 no-loc: [Reset, Current, Background, Blink, Bold, Foreground, Formatting, Hidden, Italic, Reset, Reverse, Underline] online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 @@ -835,11 +835,34 @@ and change the current loop iteration. For more information, see ### $this -In a script block that defines a script property or script method, the `$this` -variable refers to the object that is being extended. +The `$this` variable is used in script blocks that extend classes to refer to +the instance of the class itself. -In a custom class, the `$this` variable refers to the class object itself -allowing access to properties and methods defined in the class. +PowerShell's Extensible Type System (ETS) allows you to add properties to +classes using script blocks. In a script block that defines a script property +or script method, the `$this` variable refers to an instance of object of the +class that is being extended. For example, PowerShell uses ETS to add the +**BaseName** property to the **FileInfo** class. + +```powershell +PS> Get-ChildItem .\README.md | Get-Member BaseName | Format-List + +TypeName : System.IO.FileInfo +Name : BaseName +MemberType : ScriptProperty +Definition : System.Object BaseName {get=if ($this.Extension.Length -gt 0){$this.Name.Remove($this.Name.Length - + $this.Extension.Length)}else{$this.Name};} +``` + +For more information, see [about_Types.ps1xml](./about_Types.ps1xml.md). + +In a PowerShell class, the `$this` variable refers to the instance object of +the class itself, allowing access to properties and methods defined in the +class. For more information, see [about_Classes](about_Classes.md). + +The `$this` variable is also used by .NET event classes that take script blocks +as delegates for the event handler. In this scenario, `$this` represents the +object originating the event, known as the event sender. ### $true