diff --git a/reference/docs-conceptual/developer/cmdlet/extending-output-objects.md b/reference/docs-conceptual/developer/cmdlet/extending-output-objects.md index 86ac1e3fe5ed..0027a132878a 100644 --- a/reference/docs-conceptual/developer/cmdlet/extending-output-objects.md +++ b/reference/docs-conceptual/developer/cmdlet/extending-output-objects.md @@ -6,7 +6,7 @@ title: Extending Output Objects --- # Extending Output Objects -You can extend the .NET Framework objects that are returned by cmdlets, functions, and scripts by using types files (.ps1xml). Types files are XML-based files that let you add properties and methods to existing objects. For example, Windows PowerShell provides the Types.ps1xml file, which adds elements to several existing .NET Framework objects. The Types.ps1xml file is located in the Windows PowerShell installation directory (`$pshome`). You can create your own types file to further extend those objects or to extend other objects. When you extend an object by using a types file, any instance of the object is extended with the new elements. +You can extend the .NET Framework objects that are returned by cmdlets, functions, and scripts by using types files (.ps1xml). Types files are XML-based files that let you add properties and methods to existing objects. For example, Windows PowerShell provides the Types.ps1xml file, which adds elements to several existing .NET Framework objects. The Types.ps1xml file is located in the Windows PowerShell installation directory (`$PSHOME`). You can create your own types file to further extend those objects or to extend other objects. When you extend an object by using a types file, any instance of the object is extended with the new elements. ## Extending the System.Array Object @@ -66,7 +66,7 @@ PS> (1, 2, 3, 4).Length ## Custom Types Files -To create a custom types file, start by copying an existing types file. The new file can have any name, but it must have a .ps1xml file name extension. When you copy the file, you can place the new file in any directory that is accessible to Windows PowerShell, but it is useful to place the files in the Windows PowerShell installation directory (`$pshome`) or in a subdirectory of the installation directory. +To create a custom types file, start by copying an existing types file. The new file can have any name, but it must have a .ps1xml file name extension. When you copy the file, you can place the new file in any directory that is accessible to Windows PowerShell, but it is useful to place the files in the Windows PowerShell installation directory (`$PSHOME`) or in a subdirectory of the installation directory. To add your own extended types to the file, add a types element for each object that you want to extend. The following topics provide examples. diff --git a/reference/docs-conceptual/developer/format/powershell-formatting-files.md b/reference/docs-conceptual/developer/format/powershell-formatting-files.md index 633708696ff9..ca395b3f8fd0 100644 --- a/reference/docs-conceptual/developer/format/powershell-formatting-files.md +++ b/reference/docs-conceptual/developer/format/powershell-formatting-files.md @@ -7,7 +7,7 @@ title: Windows PowerShell Formatting Files # Windows PowerShell Formatting Files Windows PowerShell provides several formatting files (.format.ps1xml) that are located in the -installation directory (`$pshome`). Each of these files defines the default display for a specific +installation directory (`$PSHOME`). Each of these files defines the default display for a specific set of .NET objects. These files should never be changed. However, you can use them as a reference for creating your own custom formatting files. diff --git a/reference/docs-conceptual/developer/hosting/host04-sample.md b/reference/docs-conceptual/developer/hosting/host04-sample.md index 04f4b827e699..651b174bd100 100644 --- a/reference/docs-conceptual/developer/hosting/host04-sample.md +++ b/reference/docs-conceptual/developer/hosting/host04-sample.md @@ -27,7 +27,7 @@ This sample requires Windows PowerShell 2.0. - Building a console application that uses these host classes to build an interactive Windows PowerShell shell. -- Creating a `$profile` variable and loading the following profiles. +- Creating a `$PROFILE` variable and loading the following profiles. - current user, current host - current user, all hosts @@ -145,7 +145,7 @@ namespace Microsoft.Samples.PowerShell.Host this.myRunSpace.Open(); // Create a PowerShell object that will be used to execute the commands - // to create $profile and load the profiles. + // to create $PROFILE and load the profiles. lock (this.instanceLock) { this.currentPowerShell = PowerShell.Create(); diff --git a/reference/docs-conceptual/developer/hosting/host05-sample.md b/reference/docs-conceptual/developer/hosting/host05-sample.md index 2dcfe7b49405..7387f75a9c6a 100644 --- a/reference/docs-conceptual/developer/hosting/host05-sample.md +++ b/reference/docs-conceptual/developer/hosting/host05-sample.md @@ -30,7 +30,7 @@ host application also supports calls to remote computers by using the - Building a console application that uses these host classes to build an interactive Windows PowerShell shell. -- Creating a `$profile` variable and loading the following profiles. +- Creating a `$PROFILE` variable and loading the following profiles. - current user, current host - current user, all hosts @@ -159,7 +159,7 @@ namespace Microsoft.Samples.PowerShell.Host this.myRunSpace.Open(); // Create a PowerShell object to run the commands used to create - // $profile and load the profiles. + // $PROFILE and load the profiles. lock (this.instanceLock) { this.currentPowerShell = PowerShell.Create(); diff --git a/reference/docs-conceptual/developer/hosting/host06-sample.md b/reference/docs-conceptual/developer/hosting/host06-sample.md index d7a5501a8340..1b53bf7767c2 100644 --- a/reference/docs-conceptual/developer/hosting/host06-sample.md +++ b/reference/docs-conceptual/developer/hosting/host06-sample.md @@ -29,7 +29,7 @@ the user. - Building a console application that uses these host classes to build an interactive Windows PowerShell shell. -- Creating a `$profile` variable and loading the following profiles. +- Creating a `$PROFILE` variable and loading the following profiles. - current user, current host - current user, all hosts @@ -165,7 +165,7 @@ namespace Microsoft.Samples.PowerShell.Host this.myRunSpace.Open(); // Create a PowerShell object to run the commands used to create - // $profile and load the profiles. + // $PROFILE and load the profiles. lock (this.instanceLock) { this.currentPowerShell = PowerShell.Create(); diff --git a/reference/docs-conceptual/developer/module/how-to-write-a-powershell-module-manifest.md b/reference/docs-conceptual/developer/module/how-to-write-a-powershell-module-manifest.md index 997b983d8f24..f21ecc650bc5 100644 --- a/reference/docs-conceptual/developer/module/how-to-write-a-powershell-module-manifest.md +++ b/reference/docs-conceptual/developer/module/how-to-write-a-powershell-module-manifest.md @@ -93,7 +93,7 @@ The following table describes the elements you can include in a module manifest. | **Copyright**
Type: `String` | `'(c) . All rights reserved.'` | Copyright statement for this module. If a value isn't specified, `New-ModuleManifest` uses the default with the current user as the ``. To specify an author, use the **Author** parameter.
Example: `Copyright = '2019 AuthorName. All rights reserved.'` | | **Description**
Type: `String` | `` | Description of the functionality provided by this module.
Example: `Description = 'This is the module's description.'` | | **PowerShellVersion**
Type: `Version` | `` | Minimum version of the PowerShell engine required by this module. Valid values are 1.0, 2.0, 3.0, 4.0, 5.0, 5.1, 6.0, 6.1, 6.2, 7.0 and 7.1.
Example: `PowerShellVersion = '5.0'` | -| **PowerShellHostName**
Type: `String` | `` | Name of the PowerShell host required by this module. This name is provided by PowerShell. To find the name of a host program, in the program, type: `$host.name`.
Example: `PowerShellHostName = 'ConsoleHost'` | +| **PowerShellHostName**
Type: `String` | `` | Name of the PowerShell host required by this module. This name is provided by PowerShell. To find the name of a host program, in the program, type: `$Host.name`.
Example: `PowerShellHostName = 'ConsoleHost'` | | **PowerShellHostVersion**
Type: `Version` | `` | Minimum version of the PowerShell host required by this module.
Example: `PowerShellHostVersion = '2.0'` | | **DotNetFrameworkVersion**
Type: `Version` | `` | Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only, such as Windows PowerShell 5.1, and only applies to .NET Framework versions lower than 4.5.
Example: `DotNetFrameworkVersion = '3.5'` | | **CLRVersion**
Type: `Version` | `` | Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only, such as Windows PowerShell 5.1, and only applies to .NET Framework versions lower than 4.5.
Example: `CLRVersion = '3.5'` | diff --git a/reference/docs-conceptual/developer/module/installing-a-powershell-module.md b/reference/docs-conceptual/developer/module/installing-a-powershell-module.md index eff2532be081..48da1b5da3d6 100644 --- a/reference/docs-conceptual/developer/module/installing-a-powershell-module.md +++ b/reference/docs-conceptual/developer/module/installing-a-powershell-module.md @@ -33,7 +33,7 @@ PowerShell modules. Cmdlets rely on the value of this environment variable to fi By default, the **PSModulePath** environment variable value contains the following system and user module directories, but you can add to and edit the value. -- `$PSHome\Modules` (`%Windir%\System32\WindowsPowerShell\v1.0\Modules`) +- `$PSHOME\Modules` (`%Windir%\System32\WindowsPowerShell\v1.0\Modules`) > [!WARNING] > This location is reserved for modules that ship with Windows. Do not install modules to this diff --git a/reference/docs-conceptual/how-to-use-docs.md b/reference/docs-conceptual/how-to-use-docs.md index 66eb44c204cb..86f44cfa2d00 100644 --- a/reference/docs-conceptual/how-to-use-docs.md +++ b/reference/docs-conceptual/how-to-use-docs.md @@ -48,7 +48,7 @@ If there are version-specific differences, the documentation makes note of those ![Animation showing how to use the version selector.][04] -You can verify the version of PowerShell you are using by inspecting the `$PSversionTable.PSVersion` +You can verify the version of PowerShell you are using by inspecting the `$PSVersionTable.PSVersion` value. The following example shows the output for Windows PowerShell 5.1. ```powershell diff --git a/reference/docs-conceptual/lang-spec/chapter-04.md b/reference/docs-conceptual/lang-spec/chapter-04.md index 3991ecc3f294..977631b0e7c6 100644 --- a/reference/docs-conceptual/lang-spec/chapter-04.md +++ b/reference/docs-conceptual/lang-spec/chapter-04.md @@ -929,7 +929,7 @@ In PowerShell, this type is `System.Management.Automation.PSCustomObject`. The c ### 4.5.14 Command description type -The automatic variable `$PsCmdlet` is an object that represents the cmdlet or function being +The automatic variable `$PSCmdlet` is an object that represents the cmdlet or function being executed. The type of this object is implementation defined; it has the following accessible members: diff --git a/reference/docs-conceptual/lang-spec/chapter-07.md b/reference/docs-conceptual/lang-spec/chapter-07.md index 41a8dd230aeb..296b0998a84c 100644 --- a/reference/docs-conceptual/lang-spec/chapter-07.md +++ b/reference/docs-conceptual/lang-spec/chapter-07.md @@ -1698,10 +1698,10 @@ dash: Description: If the left operand does not designate a collection, the result has type `bool` and if that result -is `$true`, the elements of the Hashtable `$matches` are set to the strings that match (or +is `$true`, the elements of the Hashtable `$Matches` are set to the strings that match (or do-not-match) the value designated by the right operand. Otherwise, the result is a possibly empty unconstrained 1-dimensional array containing the elements of the collection that test True when -compared to the value designated by the right operand, and `$matches` is not set. The right operand +compared to the value designated by the right operand, and `$Matches` is not set. The right operand may designate a string that contains regular expressions ([§3.16][§3.16]), in which case, it is referred to as a _pattern_. These operators have two variants ([§7.8][§7.8]). @@ -1710,11 +1710,11 @@ These operators support submatches ([§7.8.4.6][§7.8.4.6]). Examples: ```powershell -"Hello" -match ".l" # True, $matches key/value is 0/"el" -"Hello" -match '\^h.*o$' # True, $matches key/value is +"Hello" -match ".l" # True, $Matches key/value is 0/"el" +"Hello" -match '\^h.*o$' # True, $Matches key/value is 0/"Hello" -"Hello" -cmatch '\^h.*o$' # False, $matches not set -"abc\^ef" -match ".\\\^e" # True, $matches key/value is 0/"c\^e" +"Hello" -cmatch '\^h.*o$' # False, $Matches not set +"abc\^ef" -match ".\\\^e" # True, $Matches key/value is 0/"c\^e" "abc" -notmatch "[A-Za-z]" # False "abc" -match "[\^A-Za-z]" # False @@ -1885,7 +1885,7 @@ _submatches_) delimited by parentheses. Consider the following example: `"red" -match "red"` -The result is `$true` and key 0 of `$matches` contains "red", that part of the string designated by +The result is `$true` and key 0 of `$Matches` contains "red", that part of the string designated by the left operand that exactly matched the pattern designated by the right operand. In the following example, the whole pattern is a submatch: @@ -1914,7 +1914,7 @@ In the case of `-replace`, the replacement text can access the submatches via na The resulting string is "the morning of Monday". -Instead of having keys in `$matches` be zero-based indexes, submatches can be named using the form +Instead of having keys in `$Matches` be zero-based indexes, submatches can be named using the form `?<*name*>`. For example, `"((r)e)(d)"` can be written with three named submatches, `m1`, `m2`, and `m3`, as follows: `"(?(?r)e)(?d)"`. diff --git a/reference/docs-conceptual/lang-spec/chapter-08.md b/reference/docs-conceptual/lang-spec/chapter-08.md index 1d270df94fae..a40a7fd6dc66 100644 --- a/reference/docs-conceptual/lang-spec/chapter-08.md +++ b/reference/docs-conceptual/lang-spec/chapter-08.md @@ -857,7 +857,7 @@ is case-insensitive. A pattern may contain a regular expression ([§3.16][§3.16]), in which case, regular expression string comparisons are performed, but only if the *switch-parameter* `-Regex` is present. By default, the -comparison is case-insensitive. If `-Regex` is present and a pattern is matched, `$matches` is +comparison is case-insensitive. If `-Regex` is present and a pattern is matched, `$Matches` is defined in the *switch-clause* *statement-block* for that pattern. A *switch-parameter* may be abbreviated; any distinct leading part of a parameter may be used. For @@ -1169,7 +1169,7 @@ only: - All operators except `-match` - The `if` statement -- The following automatic variables: `$PsCulture`, `$PsUICulture`, `$true`, `$false`, and `$null`. +- The following automatic variables: `$PSCulture`, `$PSUICulture`, `$true`, `$false`, and `$null`. - Comments - Pipelines - Statements separated by semicolons (`;`) @@ -1660,7 +1660,7 @@ function Test { [Parameter(Position = 0, ParameterSetname = "SetB")] [int]$in ) - $PsCmdlet.ParameterSetName + $PSCmdlet.ParameterSetName } Test 42d # outputs "SetA" diff --git a/reference/docs-conceptual/lang-spec/chapter-12.md b/reference/docs-conceptual/lang-spec/chapter-12.md index 13cdc3c64169..0f04a14309c7 100644 --- a/reference/docs-conceptual/lang-spec/chapter-12.md +++ b/reference/docs-conceptual/lang-spec/chapter-12.md @@ -179,7 +179,7 @@ conversion from `$null` to int. This attribute is used in the *attribute-list* of *param-block* of a function to indicate that function acts similar to a cmdlet. Specifically, it allows functions to access a number of methods -and properties through the $PsCmdlet variable by using begin, process, and end named blocks +and properties through the $PSCmdlet variable by using begin, process, and end named blocks ([§8.10.7][§8.10.7]). When this attribute is present, positional arguments that have no matching positional parameters @@ -322,11 +322,11 @@ ParameterSetName = "User")]
ParameterSetName = "Computer")]
[Parameter(ParameterSetName = "User")]
[int] $SharedParam = 5 )

-

if ($PsCmdlet.ParameterSetName -eq "Computer")
+

if ($PSCmdlet.ParameterSetName -eq "Computer")
{
# handle "Computer" parameter set
}

-

elseif ($PsCmdlet.ParameterSetName -eq "User")
+

elseif ($PSCmdlet.ParameterSetName -eq "User")
{
# handle "User" parameter set
}
diff --git a/reference/docs-conceptual/learn/deep-dives/everything-about-arrays.md b/reference/docs-conceptual/learn/deep-dives/everything-about-arrays.md index c1036cb8a72d..302b926ab45c 100644 --- a/reference/docs-conceptual/learn/deep-dives/everything-about-arrays.md +++ b/reference/docs-conceptual/learn/deep-dives/everything-about-arrays.md @@ -764,7 +764,7 @@ We can take the same approach with `Select-String`. $servers | Select-String SQL ``` -I take a closer look at `Select-String`,`-match` and the `$matches` variable in another post called +I take a closer look at `Select-String`,`-match` and the `$Matches` variable in another post called [The many ways to use regex][10]. ### $null or empty diff --git a/reference/docs-conceptual/learn/deep-dives/everything-about-hashtable.md b/reference/docs-conceptual/learn/deep-dives/everything-about-hashtable.md index afedbcccb808..6b14315f0e11 100644 --- a/reference/docs-conceptual/learn/deep-dives/everything-about-hashtable.md +++ b/reference/docs-conceptual/learn/deep-dives/everything-about-hashtable.md @@ -912,7 +912,7 @@ $PSDefaultParameterValues["Out-File:Encoding"] = "UTF8" This adds an entry to the `$PSDefaultParameterValues` hashtable that sets `UTF8` as the default value for the `Out-File -Encoding` parameter. This is session-specific so you should place it in -your `$profile`. +your `$PROFILE`. I use this often to pre-assign values that I type quite often. @@ -932,7 +932,7 @@ For a more in-depth breakdown, see this great article on [Automatic Defaults][Au ## Regex $Matches -When you use the `-match` operator, an automatic variable called `$matches` is created with the +When you use the `-match` operator, an automatic variable called `$Matches` is created with the results of the match. If you have any sub expressions in your regex, those sub matches are also listed. diff --git a/reference/docs-conceptual/learn/deep-dives/everything-about-switch.md b/reference/docs-conceptual/learn/deep-dives/everything-about-switch.md index b3b10ce22749..205b744b5330 100644 --- a/reference/docs-conceptual/learn/deep-dives/everything-about-switch.md +++ b/reference/docs-conceptual/learn/deep-dives/everything-about-switch.md @@ -558,10 +558,10 @@ switch ( $age ) It still executes the same way and gives a better visual break when quickly looking at it. -### Regex $matches +### Regex $Matches We need to revisit regex to touch on something that isn't immediately obvious. The use of regex -populates the `$matches` variable. I do go into the use of `$matches` more when I talk about +populates the `$Matches` variable. I do go into the use of `$Matches` more when I talk about [The many ways to use regex][The many ways to use regex]. Here is a quick sample to show it in action with named matches. @@ -572,15 +572,15 @@ switch -Regex ($message) { '(?\d\d\d-\d\d-\d\d\d\d)' { - Write-Warning "message contains a SSN: $($matches.SSN)" + Write-Warning "message contains a SSN: $($Matches.SSN)" } '(?\d\d\d\d-\d\d\d\d-\d\d\d\d-\d\d\d\d)' { - Write-Warning "message contains a credit card number: $($matches.CC)" + Write-Warning "message contains a credit card number: $($Matches.CC)" } '(?\d\d\d-\d\d\d-\d\d\d\d)' { - Write-Warning "message contains a phone number: $($matches.Phone)" + Write-Warning "message contains a phone number: $($Matches.Phone)" } } ``` diff --git a/reference/docs-conceptual/samples/Creating-.NET-and-COM-Objects--New-Object-.md b/reference/docs-conceptual/samples/Creating-.NET-and-COM-Objects--New-Object-.md index f07064838be7..075e544c36df 100644 --- a/reference/docs-conceptual/samples/Creating-.NET-and-COM-Objects--New-Object-.md +++ b/reference/docs-conceptual/samples/Creating-.NET-and-COM-Objects--New-Object-.md @@ -276,10 +276,10 @@ TargetPath Property string TargetPath () {get} {set} We need to specify the **TargetPath**, which is the application folder for PowerShell, and then save the shortcut by calling the `Save` method. The PowerShell application folder path is stored in the -variable `$PSHome`, so we can do this by typing: +variable `$PSHOME`, so we can do this by typing: ```powershell -$lnk.TargetPath = $PSHome +$lnk.TargetPath = $PSHOME $lnk.Save() ``` diff --git a/reference/docs-conceptual/samples/Decode-PowerShell-Command-from-a-Running-Process.md b/reference/docs-conceptual/samples/Decode-PowerShell-Command-from-a-Running-Process.md index 04a3e57edc7d..7abaa92f2788 100644 --- a/reference/docs-conceptual/samples/Decode-PowerShell-Command-from-a-Running-Process.md +++ b/reference/docs-conceptual/samples/Decode-PowerShell-Command-from-a-Running-Process.md @@ -58,7 +58,7 @@ $commandDetails = $powerShellProcesses | Select-Object -Property ProcessId, expression = { if ( $_.CommandLine -match 'encodedCommand (.*) -inputFormat' ) { - return $matches[1] + return $Matches[1] } } } diff --git a/reference/docs-conceptual/samples/Working-with-Registry-Entries.md b/reference/docs-conceptual/samples/Working-with-Registry-Entries.md index 519c9a5e68b8..c39288cd43ac 100644 --- a/reference/docs-conceptual/samples/Working-with-Registry-Entries.md +++ b/reference/docs-conceptual/samples/Working-with-Registry-Entries.md @@ -195,7 +195,7 @@ The operation completed successfully. To add a new entry named "PowerShellPath" to the **CurrentVersion** key, use `New-ItemProperty` with the path to the key, the entry name, and the value of the entry. For this example, we will take the -value of the Windows PowerShell variable `$PSHome`, which stores the path to the installation +value of the Windows PowerShell variable `$PSHOME`, which stores the path to the installation directory for Windows PowerShell. You can add the new entry to the key using the following command, and the command also returns @@ -206,7 +206,7 @@ $newItemPropertySplat = @{ Path = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion' Name = 'PowerShellPath' PropertyType = 'String' - Value = $PSHome + Value = $PSHOME } New-ItemProperty @newItemPropertySplat ``` @@ -240,7 +240,7 @@ parameter: $newItemPropertySplat = @{ Name = 'PowerShellPath' PropertyType = 'String' - Value = $PSHome + Value = $PSHOME Path = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion', 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion' } diff --git a/reference/docs-conceptual/security/preventing-script-injection.md b/reference/docs-conceptual/security/preventing-script-injection.md index 47319e86724b..cd2f57146f14 100644 --- a/reference/docs-conceptual/security/preventing-script-injection.md +++ b/reference/docs-conceptual/security/preventing-script-injection.md @@ -34,7 +34,7 @@ another script that's parsed and run using the `Invoke-Expression` cmdlet. This when a valid process Id integer is passed in. ```powershell -Get-ProcessById $pid +Get-ProcessById $PID NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName ------ ----- ----- ------ -- -- ----------- @@ -45,10 +45,10 @@ However, the `$ProcId` parameter doesn't specify a type. It accepts any arbitrar can include other commands. ```powershell -Get-ProcessById "$pid; Write-Host 'pwnd!'" +Get-ProcessById "$PID; Write-Host 'pwnd!'" ``` -In this example, the function correctly retrieved the process identified by `$pid`, but also ran the +In this example, the function correctly retrieved the process identified by `$PID`, but also ran the injected script `Write-Host 'pwnd!'`. ```Output @@ -73,13 +73,13 @@ function Get-ProcessById Invoke-Expression -Command "Get-Process -Id $ProcId" } -Get-ProcessById "$pid; Write-Host 'pwnd!'" +Get-ProcessById "$PID; Write-Host 'pwnd!'" ``` ```Output Get-ProcessById: Line | - 7 | Get-ProcessById "$pid; Write-Host 'pwnd!'" + 7 | Get-ProcessById "$PID; Write-Host 'pwnd!'" | ~~~~~~~~~~~~~~~~~~~~~~~~~ | Cannot process argument transformation on parameter 'ProcId'. Cannot convert value "8064; Write-Host 'pwnd!'" to type "System.Int32". Error: "The input string '8064; Write-Host 'pwnd!' @@ -101,7 +101,7 @@ function Get-ProcessById Get-Process -Id $ProcId } -Get-ProcessById "$pid; Write-Host 'pwnd!'" +Get-ProcessById "$PID; Write-Host 'pwnd!'" ``` ```Output @@ -133,7 +133,7 @@ function Get-ProcessById Invoke-Expression -Command "Get-Process -Id '$ProcId'" } -Get-ProcessById "$pid; Write-Host 'pwnd!'" +Get-ProcessById "$PID; Write-Host 'pwnd!'" ``` ```Output @@ -145,7 +145,7 @@ However, this version of the function isn't yet completely safe from injection a user can still use single quotes in their input to inject code. ```powershell -Get-ProcessById "$pid'; Write-Host 'pwnd!';'" +Get-ProcessById "$PID'; Write-Host 'pwnd!';'" ``` This example uses single quotes in the user input to force the function to run three separate @@ -174,7 +174,7 @@ function Get-ProcessById EscapeSingleQuotedStringContent("$ProcId") Invoke-Expression -Command "Get-Process -Id '$ProcIdClean'" } -Get-ProcessById "$pid'; Write-Host 'pwnd!';'" +Get-ProcessById "$PID'; Write-Host 'pwnd!';'" ``` ```Output diff --git a/reference/docs-conceptual/security/remoting/powershell-remoting-faq.yml b/reference/docs-conceptual/security/remoting/powershell-remoting-faq.yml index 6a7aa9ccd299..21ed150f8181 100644 --- a/reference/docs-conceptual/security/remoting/powershell-remoting-faq.yml +++ b/reference/docs-conceptual/security/remoting/powershell-remoting-faq.yml @@ -219,7 +219,7 @@ sections: Where are my profiles? answer: | PowerShell profiles are not run automatically in remote sessions, so the commands that the - profile adds are not present in the session. In addition, the `$profile` automatic + profile adds are not present in the session. In addition, the `$PROFILE` automatic variable is not populated in remote sessions. To run a profile in a session, use the `Invoke-Command` cmdlet. @@ -228,16 +228,16 @@ sections: local computer in the session in `$s`. ``` - Invoke-Command -Session $s -FilePath $profile + Invoke-Command -Session $s -FilePath $PROFILE ``` The following command runs the **CurrentUserCurrentHost** profile from the remote computer - in the session in `$s`. Because the `$profile` variable is not populated, the command uses + in the session in `$s`. Because the `$PROFILE` variable is not populated, the command uses the explicit path to the profile. ```powershell Invoke-Command -Session $s { - . "$home\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1" + . "$HOME\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1" } ``` diff --git a/reference/docs-conceptual/whats-new/What-s-New-in-PowerShell-74.md b/reference/docs-conceptual/whats-new/What-s-New-in-PowerShell-74.md index 0e1752d8d0d4..b1f62dfeeafe 100644 --- a/reference/docs-conceptual/whats-new/What-s-New-in-PowerShell-74.md +++ b/reference/docs-conceptual/whats-new/What-s-New-in-PowerShell-74.md @@ -85,7 +85,7 @@ Many thanks to **@MartinGC94** and others for all their work to improve tab comp ([#17750][17750]) (Thanks @fflaten!). - Fix dynamic parameter completion ([#19510][19510]) - Add completion for variables assigned by the Data statement ([#19831][19831]) -- Fix expanding tilde (`~`) on Windows systems to `$home` to prevent breaking use cases with native +- Fix expanding tilde (`~`) on Windows systems to `$HOME` to prevent breaking use cases with native commands ([#21529][21529]) ## Web cmdlet improvements diff --git a/reference/docs-conceptual/whats-new/What-s-New-in-PowerShell-75.md b/reference/docs-conceptual/whats-new/What-s-New-in-PowerShell-75.md index cd989448ef42..2959bd1bc3b5 100644 --- a/reference/docs-conceptual/whats-new/What-s-New-in-PowerShell-75.md +++ b/reference/docs-conceptual/whats-new/What-s-New-in-PowerShell-75.md @@ -40,7 +40,7 @@ Many thanks to **@ArmaanMcleod** and others for all their work to improve tab co - Fall back to type inference when hashtable key-value cannot be retrieved from safe expression ([#21184][21184]) (Thanks @MartinGC94!) - Fix the regression when doing type inference for `$_` ([#21223][21223]) (Thanks @MartinGC94!) -- Expand `~` to `$home` on Windows with tab completion ([#21529][21529]) +- Expand `~` to `$HOME` on Windows with tab completion ([#21529][21529]) - Don't complete when declaring parameter name and class member ([#21182][21182]) (Thanks @MartinGC94!) - Prevent fallback to file completion when tab completing type names ([#20084][20084]) (Thanks @@ -136,7 +136,7 @@ Many thanks to **@ArmaanMcleod** and others for all their work to improve tab co - Fix using assembly to use Path.Combine when constructing assembly paths ([#21169][21169]) - Validate the value for using namespace during semantic checks to prevent declaring invalid namespaces ([#21162][21162]) -- Handle global tool specially when prepending `$PSHome` to PATH ([#24228][24228]) +- Handle global tool specially when prepending `$PSHOME` to PATH ([#24228][24228]) ## Experimental features diff --git a/reference/docs-conceptual/windows-powershell/ise/How-to-Debug-Scripts-in-Windows-PowerShell-ISE.md b/reference/docs-conceptual/windows-powershell/ise/How-to-Debug-Scripts-in-Windows-PowerShell-ISE.md index 13c4cd44c201..0018b13f5915 100644 --- a/reference/docs-conceptual/windows-powershell/ise/How-to-Debug-Scripts-in-Windows-PowerShell-ISE.md +++ b/reference/docs-conceptual/windows-powershell/ise/How-to-Debug-Scripts-in-Windows-PowerShell-ISE.md @@ -228,7 +228,7 @@ debugging a script. However, these methods do not work for the following automat - `$_` -- `$Input` +- `$input` - `$MyInvocation` @@ -238,7 +238,7 @@ debugging a script. However, these methods do not work for the following automat If you try to display the value of any of these variables, you get the value of that variable for in an internal pipeline the debugger uses, not the value of the variable in the script. You can work -around this for a few variables (`$_`, `$Input`, `$MyInvocation`, `$PSBoundParameters`, and `$args`) +around this for a few variables (`$_`, `$input`, `$MyInvocation`, `$PSBoundParameters`, and `$args`) by using the following method: 1. In the script, assign the value of the automatic variable to a new variable. diff --git a/reference/docs-conceptual/windows-powershell/ise/object-model/The-ISEFileCollection-Object.md b/reference/docs-conceptual/windows-powershell/ise/object-model/The-ISEFileCollection-Object.md index e9640b524e7d..6bf1a10f1382 100644 --- a/reference/docs-conceptual/windows-powershell/ise/object-model/The-ISEFileCollection-Object.md +++ b/reference/docs-conceptual/windows-powershell/ise/object-model/The-ISEFileCollection-Object.md @@ -27,7 +27,7 @@ the full path. $newFile = $psISE.CurrentPowerShellTab.Files.Add() # Adds a file specified by its full path to the collection of files in the current PowerShell tab. -$psISE.CurrentPowerShellTab.Files.Add("$pshome\Examples\profile.ps1") +$psISE.CurrentPowerShellTab.Files.Add("$PSHOME\Examples\profile.ps1") ``` ### Remove\( File, \[Force\] \) diff --git a/reference/docs-conceptual/windows-powershell/ise/object-model/The-ISESnippetCollection-Object.md b/reference/docs-conceptual/windows-powershell/ise/object-model/The-ISESnippetCollection-Object.md index e7f75d0ba5d0..7c79b1128686 100644 --- a/reference/docs-conceptual/windows-powershell/ise/object-model/The-ISESnippetCollection-Object.md +++ b/reference/docs-conceptual/windows-powershell/ise/object-model/The-ISESnippetCollection-Object.md @@ -25,7 +25,7 @@ The path and file name to a .snippets.ps1xml file that contains snippet definiti ```powershell # Loads a custom snippet file into the current PowerShell tab. -$SnipFile = Join-Path ( Split-Path $profile) 'Snippets\MySnips.snippets.ps1xml' $psISE.CurrentPowerShellTab.Snippets.Add($SnipPath) +$SnipFile = Join-Path ( Split-Path $PROFILE) 'Snippets\MySnips.snippets.ps1xml' $psISE.CurrentPowerShellTab.Snippets.Add($SnipPath) ``` ## See Also diff --git a/tests/Pester/Update-Help.Tests.ps1 b/tests/Pester/Update-Help.Tests.ps1 index 8c36bc6ad93a..3cc668323647 100644 --- a/tests/Pester/Update-Help.Tests.ps1 +++ b/tests/Pester/Update-Help.Tests.ps1 @@ -21,49 +21,49 @@ $testCases = @{ HelpFiles = "System.Management.Automation.dll-help.xml" HelpInfoFiles = "Microsoft.PowerShell.Core_00000000-0000-0000-0000-000000000000_HelpInfo.xml" CompressedFiles = "Microsoft.PowerShell.Core_00000000-0000-0000-0000-000000000000_en-US_HelpContent$extension" - HelpInstallationPath = "$pshome\en-US" + HelpInstallationPath = "$PSHOME\en-US" } "Microsoft.PowerShell.Diagnostics" = @{ HelpFiles = "Microsoft.PowerShell.Commands.Diagnostics.dll-help.xml" HelpInfoFiles = "Microsoft.PowerShell.Diagnostics_ca046f10-ca64-4740-8ff9-2565dba61a4f_HelpInfo.xml" CompressedFiles = "Microsoft.PowerShell.Diagnostics_ca046f10-ca64-4740-8ff9-2565dba61a4f_en-US_helpcontent$extension" - HelpInstallationPath = "$pshome\en-US" + HelpInstallationPath = "$PSHOME\en-US" } "Microsoft.PowerShell.Host" = @{ HelpFiles = "Microsoft.PowerShell.ConsoleHost.dll-help.xml" HelpInfoFiles = "Microsoft.PowerShell.Host_56d66100-99a0-4ffc-a12d-eee9a6718aef_HelpInfo.xml" CompressedFiles = "Microsoft.PowerShell.Host_56d66100-99a0-4ffc-a12d-eee9a6718aef_en-US_helpcontent$extension" - HelpInstallationPath = "$pshome\en-US" + HelpInstallationPath = "$PSHOME\en-US" } "Microsoft.PowerShell.Management" = @{ HelpFiles = "Microsoft.PowerShell.Commands.Management.dll-help.xml" HelpInfoFiles = "Microsoft.PowerShell.Management_eefcb906-b326-4e99-9f54-8b4bb6ef3c6d_HelpInfo.xml" CompressedFiles = "Microsoft.PowerShell.Management_eefcb906-b326-4e99-9f54-8b4bb6ef3c6d_en-US_helpcontent$extension" - HelpInstallationPath = "$pshome\en-US" + HelpInstallationPath = "$PSHOME\en-US" } "Microsoft.PowerShell.Security" = @{ HelpFiles = "Microsoft.PowerShell.Security.dll-help.xml" HelpInfoFiles = "Microsoft.PowerShell.Security_a94c8c7e-9810-47c0-b8af-65089c13a35a_HelpInfo.xml" CompressedFiles = "Microsoft.PowerShell.Security_a94c8c7e-9810-47c0-b8af-65089c13a35a_en-US_helpcontent$extension" - HelpInstallationPath = "$pshome\en-US" + HelpInstallationPath = "$PSHOME\en-US" } "Microsoft.PowerShell.Utility" = @{ HelpFiles = "Microsoft.PowerShell.Commands.Utility.dll-Help.xml", "Microsoft.PowerShell.Utility-help.xml" HelpInfoFiles = "Microsoft.PowerShell.Utility_1da87e53-152b-403e-98dc-74d7b4d63d59_HelpInfo.xml" CompressedFiles = "Microsoft.PowerShell.Utility_1da87e53-152b-403e-98dc-74d7b4d63d59_en-US_helpcontent$extension" - HelpInstallationPath = "$pshome\en-US" + HelpInstallationPath = "$PSHOME\en-US" } "Microsoft.WSMan.Management" = @{ HelpFiles = "Microsoft.WSMan.Management.dll-help.xml" HelpInfoFiles = "Microsoft.WsMan.Management_766204A6-330E-4263-A7AB-46C87AFC366C_HelpInfo.xml" CompressedFiles = "Microsoft.WsMan.Management_766204A6-330E-4263-A7AB-46C87AFC366C_en-US_helpcontent$extension" - HelpInstallationPath = "$pshome\en-US" + HelpInstallationPath = "$PSHOME\en-US" } } @@ -74,7 +74,7 @@ if(($PSVersionTable.PSVersion.Major -ge 5) -and ($PSVersionTable.PSVersion.Minor HelpFiles = "Microsoft.Powershell.LocalAccounts.dll-help.xml" HelpInfoFiles = "Microsoft.PowerShell.LocalAccounts_8e362604-2c0b-448f-a414-a6a690a644e2_HelpInfo.xml" CompressedFiles = "Microsoft.PowerShell.LocalAccounts_8e362604-2c0b-448f-a414-a6a690a644e2_en-US_HelpContent$extension" - HelpInstallationPath = "$pshome\Modules\Microsoft.PowerShell.LocalAccounts\*\en-US" + HelpInstallationPath = "$PSHOME\Modules\Microsoft.PowerShell.LocalAccounts\*\en-US" } }