From b84261b630f7b09c0ae3ea635c35f2e54aaf7b5c Mon Sep 17 00:00:00 2001 From: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> Date: Sun, 23 Mar 2025 14:38:10 +0000 Subject: [PATCH] Fix incorrect case/capitalization in ref docs This ensures the following components have the correct/consistent case throughout the reference documentation: Preference variable, PS environment variable, PS drive, PS provider, PS command name, PS command argument, PS module, PS file extension, PS host name/application, #Requires statement, parameter name, about_* topic, member name, scope modifier, keyword, operator, calculated property key/value, attribute, type accelerator, type literal/name, WMI namespace/class, variable name, special character, comment-based help keyword, product/company name, Windows drive letter/directory, Windows/Unix environment variable In addition, changes include fixes to incorrect terminology (e.g., referring to a keyword as a command) and formatting of PS syntax elements (non-exhaustive). --- .../About/about_PSModulePath.md | 18 ++++++------ .../About/about_Quoting_Rules.md | 6 ++-- .../About/about_Redirection.md | 10 +++---- .../About/about_Ref.md | 18 ++++++------ .../About/about_Registry_Provider.md | 2 +- .../About/about_Regular_Expressions.md | 2 +- .../About/about_Remote.md | 2 +- .../About/about_Remote_Jobs.md | 22 +++++++-------- .../About/about_Remote_Requirements.md | 2 +- .../About/about_Remote_Troubleshooting.md | 28 +++++++++---------- .../About/about_PSModulePath.md | 26 ++++++++--------- .../About/about_Quoting_Rules.md | 6 ++-- .../About/about_Redirection.md | 10 +++---- .../About/about_Ref.md | 18 ++++++------ .../About/about_Registry_Provider.md | 2 +- .../About/about_Regular_Expressions.md | 2 +- .../About/about_Remote.md | 2 +- .../About/about_Remote_Jobs.md | 22 +++++++-------- .../About/about_Remote_Requirements.md | 2 +- .../About/about_Remote_Troubleshooting.md | 28 +++++++++---------- .../About/about_PSModulePath.md | 26 ++++++++--------- .../About/about_Quoting_Rules.md | 6 ++-- .../About/about_Redirection.md | 10 +++---- .../About/about_Ref.md | 18 ++++++------ .../About/about_Registry_Provider.md | 2 +- .../About/about_Regular_Expressions.md | 2 +- .../About/about_Remote.md | 2 +- .../About/about_Remote_Jobs.md | 22 +++++++-------- .../About/about_Remote_Requirements.md | 2 +- .../About/about_Remote_Troubleshooting.md | 28 +++++++++---------- .../About/about_PSModulePath.md | 26 ++++++++--------- .../About/about_Quoting_Rules.md | 6 ++-- .../About/about_Redirection.md | 10 +++---- .../About/about_Ref.md | 18 ++++++------ .../About/about_Registry_Provider.md | 2 +- .../About/about_Regular_Expressions.md | 2 +- .../About/about_Remote.md | 2 +- .../About/about_Remote_Jobs.md | 22 +++++++-------- .../About/about_Remote_Requirements.md | 2 +- .../About/about_Remote_Troubleshooting.md | 28 +++++++++---------- 40 files changed, 232 insertions(+), 232 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_PSModulePath.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_PSModulePath.md index 0544c9d1fa80..547a81722f2a 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_PSModulePath.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_PSModulePath.md @@ -10,27 +10,27 @@ title: about_PSModulePath ## Short description -This article describes the purpose and usage of the `$env:PSModulePath` +This article describes the purpose and usage of the `$Env:PSModulePath` environment variable. ## Long description -The `$env:PSModulePath` environment variable contains a list of folder +The `$Env:PSModulePath` environment variable contains a list of folder locations. PowerShell recursively searches each folder for module (`.psd1` or `.psm1`) files. -By default, the effective locations assigned to `$env:PSModulePath` are: +By default, the effective locations assigned to `$Env:PSModulePath` are: - Modules installed in the **CurrentUser** scope are stored in `$HOME\Documents\WindowsPowerShell\Modules`. - Modules installed in the **AllUsers** scope are stored in - `$env:ProgramFiles\WindowsPowerShell\Modules`. + `$Env:ProgramFiles\WindowsPowerShell\Modules`. - Modules that ship with Windows PowerShell stored in `$PSHOME\Modules`, which - is `$env:SystemRoot\System32\WindowsPowerShell\1.0\Modules`. + is `$Env:SystemRoot\System32\WindowsPowerShell\1.0\Modules`. ## PowerShell PSModulePath construction -The value of `$env:PSModulePath` is constructed each time PowerShell starts. +The value of `$Env:PSModulePath` is constructed each time PowerShell starts. The value varies by version of PowerShell and how you launched it. ### Windows PowerShell startup @@ -48,8 +48,8 @@ startup: the `$PSHOME` location The **CurrentUser** module path is prefixed only if the User scope -`$env:PSModulePath` doesn't exist. Otherwise, the User scope -`$env:PSModulePath` is used as defined. +`$Env:PSModulePath` doesn't exist. Otherwise, the User scope +`$Env:PSModulePath` is used as defined. ## Module search behavior @@ -78,7 +78,7 @@ locations. However, you might need to change the value of the `PSModulePath` environment variable. For example, to temporarily add the `C:\Program Files\Fabrikam\Modules` -directory to `$env:PSModulePath` for the current session, type: +directory to `$Env:PSModulePath` for the current session, type: ```powershell $Env:PSModulePath = $Env:PSModulePath+";C:\Program Files\Fabrikam\Modules" diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md index dd7959510746..08f321e0c5dc 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md @@ -283,14 +283,14 @@ the here-string, all quotation marks are interpreted literally. For example: ```powershell @" -For help, type "get-help" +For help, type "Get-Help" "@ ``` The output of this command is: ```Output -For help, type "get-help" +For help, type "Get-Help" ``` Using a here-string can simplify using a string in a command. For example: @@ -347,7 +347,7 @@ Here-strings are typically used to assign multiple lines to a variable. For example, the following here-string assigns a page of XML to the $page variable. ```powershell -$page = [XML] @" +$page = [xml] @" diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Redirection.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Redirection.md index a9e449650c1a..7b4fc1250429 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Redirection.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Redirection.md @@ -153,7 +153,7 @@ Get-Item /not-here 2>&1 >> log.txt $ErrorActionPreference = 'Stop' $ErrorActionPreference >> log.txt -Try { +try { Get-Item /not-here 2>&1 >> log.txt } catch { @@ -181,7 +181,7 @@ Can't find path 'C:\not-here' because it doesn't exist. [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): H Get-Item: C:\temp\test.ps1:23 Line | - 23 | get-item /not-here 2>&1 >> log.txt + 23 | Get-Item /not-here 2>&1 >> log.txt | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | The running command stopped because the user selected the Stop option. ``` @@ -194,7 +194,7 @@ Continue Get-Item: C:\temp\test.ps1:3 Line | - 3 | get-item /not-here 2>&1 >> log.txt + 3 | Get-Item /not-here 2>&1 >> log.txt | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Cannot find path 'C:\not-here' because it does not exist. @@ -252,7 +252,7 @@ redirection operators as well. Put the following command near the top of your script to set `Out-File:Width` for the whole script: ```powershell -$PSDefaultParameterValues['out-file:width'] = 2000 +$PSDefaultParameterValues['Out-File:Width'] = 2000 ``` Increasing the output width will increase memory consumption when logging @@ -264,7 +264,7 @@ you will need to pipe the output through `Format-Table -AutoSize` before outputting to file. ```powershell -$PSDefaultParameterValues['out-file:width'] = 2000 +$PSDefaultParameterValues['Out-File:Width'] = 2000 Get-Service | Format-Table -AutoSize > services.log ``` diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Ref.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Ref.md index 6c3e9fb2f5f7..a9012081ce76 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Ref.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Ref.md @@ -32,13 +32,13 @@ to it. In PowerShell, integers are value types so they're passed by value. Therefore, the value of `$var` is unchanged outside the scope of the function. ```powershell -Function Test($data) +Function Test($Data) { - $data = 3 + $Data = 3 } $var = 10 -Test -data $var +Test -Data $var $var ``` @@ -54,13 +54,13 @@ When passing a variable _by reference_, the function can change the data and that change persists after the function executes. ```powershell -Function Test($data) +Function Test($Data) { - $data.Test = "New Text" + $Data.Test = "New Text" } $var = @{} -Test -data $var +Test -Data $var $var ``` @@ -84,8 +84,8 @@ access your data. ```powershell function Test { - param([ref]$data) - $data.Value = 3 + param([ref]$Data) + $Data.Value = 3 } ``` @@ -97,7 +97,7 @@ your variable as a reference. ```powershell $var = 10 -Test -data ([ref]$var) +Test -Data ([ref]$var) $var ``` diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Registry_Provider.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Registry_Provider.md index f28f722ebf2b..691d2fcc71cf 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Registry_Provider.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Registry_Provider.md @@ -335,7 +335,7 @@ ContosoCompany registry key. ```powershell $path = "HKLM:\SOFTWARE\ContosoCompany" -New-ItemProperty -Path $path -Name Test -Type DWORD -Value 1 +New-ItemProperty -Path $path -Name Test -Type DWord -Value 1 ``` > [!NOTE] diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md index 8622e0bfbcf6..fb9e3c25f5d4 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md @@ -230,7 +230,7 @@ input strings. There's a static method of the regex class that can escape text for you. ```powershell -[regex]::escape('3.\d{2,}') +[regex]::Escape('3.\d{2,}') ``` ```Output diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Remote.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Remote.md index 5df805b278b8..2b7877881532 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Remote.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Remote.md @@ -145,7 +145,7 @@ in the same PSSession that uses the `$p` variable. The following command counts the number of processes saved in `$p`. ```powershell -Invoke-Command -Session $s -ScriptBlock {$p.count} +Invoke-Command -Session $s -ScriptBlock {$p.Count} ``` ## How to run a remote command on multiple computers diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md index 16eb63440c33..c49083bbc132 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md @@ -137,7 +137,7 @@ all of the operations occur on the remote computer, not the local computer. results of the job in the PsLog.txt file on the Server01 computer. ```powershell - Server01\C:> Receive-Job $job > c:\logs\PsLog.txt + Server01\C:> Receive-Job $job > C:\logs\PsLog.txt ``` 1. To end the interactive session, use the `Exit-PSSession` cmdlet. The command @@ -164,7 +164,7 @@ all of the operations occur on the remote computer, not the local computer. ```powershell $s = New-PSSession -ComputerName Server01 Invoke-Command -Session $s -ScriptBlock { - Get-Content c:\logs\pslog.txt} + Get-Content C:\logs\pslog.txt} ``` ### Start a remote job that returns the results to the local computer (AsJob) @@ -189,8 +189,8 @@ requirements for remoting. assign a display name to the job. ```powershell - Invoke-Command -Computername Server01 -ScriptBlock { - Get-EventLog system} -AsJob + Invoke-Command -ComputerName Server01 -ScriptBlock { + Get-EventLog System} -AsJob ``` The results of the command resemble the following sample output. @@ -198,7 +198,7 @@ requirements for remoting. ```Output SessionId Name State HasMoreData Location Command --------- ---- ----- ----------- -------- ------- - 1 Job1 Running True Server01 Get-EventLog system + 1 Job1 Running True Server01 Get-EventLog System ``` When the **AsJob** parameter is used, `Invoke-Command` returns the same type @@ -228,7 +228,7 @@ requirements for remoting. ```Output SessionId Name State HasMoreData Location Command --------- ---- ----- ----------- -------- ------- - 1 Job1 Completed True Server01 Get-EventLog system + 1 Job1 Completed True Server01 Get-EventLog System ``` 1. To get the results of the job, use the `Receive-Job` cmdlet. Because the job @@ -279,7 +279,7 @@ commands remotely to manage a local job on the remote computer. ```powershell Invoke-Command -Session $s -ScriptBlock { - Start-Job -ScriptBlock {Get-EventLog system}} + Start-Job -ScriptBlock {Get-EventLog System}} ``` The results resemble the following sample output. @@ -287,7 +287,7 @@ commands remotely to manage a local job on the remote computer. ```Output Id Name State HasMoreData Location Command -- ---- ----- ----------- -------- ------- - 2 Job2 Running True Localhost Get-EventLog system + 2 Job2 Running True Localhost Get-EventLog System ``` When you run a `Start-Job` command remotely, `Invoke-Command` returns the @@ -318,7 +318,7 @@ commands remotely to manage a local job on the remote computer. ```Output SessionId Name State HasMoreData Location Command --------- ---- ----- ----------- -------- ------- - 2 Job2 Completed True LocalHost Get-EventLog system + 2 Job2 Completed True LocalHost Get-EventLog System ``` 1. To get the results of the job, use the `Invoke-Command` cmdlet to run a @@ -342,7 +342,7 @@ commands remotely to manage a local job on the remote computer. ```powershell Invoke-Command -Session $s -Command { - Receive-Job -SessionId 2 > c:\logs\pslog.txt + Receive-Job -SessionId 2 > C:\logs\pslog.txt } ``` @@ -363,7 +363,7 @@ objects generated after the disconnect are returned when re-connected. ```powershell # Create remote session on local machine -PS> $session = New-PSSession -cn localhost +PS> $session = New-PSSession -Cn localhost # Start remote job PS> $job = Invoke-Command -Session $session -ScriptBlock { 1..60 | % { sleep 1; "Output $_" } } -AsJob diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md index 89ae644c58cf..a75180748131 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md @@ -143,7 +143,7 @@ Administrator privileges are required for the following remoting operations: known as a "loopback" scenario. - Managing session configurations on the local computer. - Viewing and changing WS-Management settings on the local computer. These are - the settings in the LocalHost node of the WSMAN: drive. + the settings in the LocalHost node of the WSMan: drive. You must start PowerShell with the **Run as administrator** option even if you are a member of the **Administrators** group on the local computer. diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md index 1ed9cf106b71..92eb38ee8fd1 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md @@ -239,7 +239,7 @@ configurations. To see the **RootSDDL** security descriptor, type: ```powershell -Get-Item wsman:\localhost\Service\RootSDDL +Get-Item WSMan:\localhost\Service\RootSDDL ``` To change the **RootSDDL**, use the `Set-Item` cmdlet in the `WSMan:` drive. To @@ -383,14 +383,14 @@ trusted hosts on the computer. To view the list of trusted hosts, use the following command: ```powershell -Get-Item wsman:\localhost\Client\TrustedHosts +Get-Item WSMan:\localhost\Client\TrustedHosts ``` The following example uses the wildcard character (`*`) to add all computers to the list of trusted hosts. ```powershell -Set-Item wsman:localhost\client\trustedhosts -Value * +Set-Item WSMan:localhost\client\trustedhosts -Value * ``` You can also use a wildcard character (`*`) to add all computers in a @@ -398,14 +398,14 @@ particular domain to the list of trusted hosts. For example, the following command adds all of the computers in the Fabrikam domain. ```powershell -Set-Item wsman:localhost\client\trustedhosts *.fabrikam.com +Set-Item WSMan:localhost\client\trustedhosts *.fabrikam.com ``` The following example set the list of trusted hosts to a single computer. ```powershell $server = 'Server01.Domain01.Fabrikam.com' -Set-Item wsman:\localhost\Client\TrustedHosts -Value $server +Set-Item WSMan:\localhost\Client\TrustedHosts -Value $server ``` To add a computer name to an existing list of trusted hosts, first save the @@ -416,21 +416,21 @@ The following example add Server01 to an existing list of trusted hosts. ```powershell $newServer = 'Server01.Domain01.Fabrikam.com' -$curValue = (Get-Item wsman:\localhost\Client\TrustedHosts).Value -Set-Item wsman:\localhost\Client\TrustedHosts -Value "$curValue, $newServer" +$curValue = (Get-Item WSMan:\localhost\Client\TrustedHosts).Value +Set-Item WSMan:\localhost\Client\TrustedHosts -Value "$curValue, $newServer" ``` To add the IP addresses of particular computers to the list of trusted hosts, use the following command format: ```powershell -Set-Item wsman:\localhost\Client\TrustedHosts -Value +Set-Item WSMan:\localhost\Client\TrustedHosts -Value ``` For example: ```powershell -Set-Item wsman:\localhost\Client\TrustedHosts -Value 172.16.0.0 +Set-Item WSMan:\localhost\Client\TrustedHosts -Value 172.16.0.0 ``` To add a computer to the **TrustedHosts** list of a remote computer, use the @@ -456,7 +456,7 @@ Use `Set-Item` cmdlet to change the **Port** value in the listener leaf node. For example, the following command changes the default port to 8080. ```powershell -Set-Item wsman:\localhost\listener\listener*\port -Value 8080 +Set-Item WSMan:\localhost\listener\listener*\port -Value 8080 ``` ## How to configure remoting with a proxy server @@ -519,17 +519,17 @@ For error: If the remote computer is running a 64-bit version of Windows, and the remote command uses a 32-bit session configuration, like **Microsoft.PowerShell32**, WinRM loads a WOW64 process. Windows automatically redirects all references to -`$env:Windir\System32` to the `$env:Windir\SysWOW64` directory. +`$Env:windir\System32` to the `$Env:windir\SysWOW64` directory. As a result, running tools in the `System32` directory that do not have -counterparts in the `SysWow64` directory can't be found. +counterparts in the `SysWOW64` directory can't be found. To find the processor architecture that is being used in the session, use the value of the **PROCESSOR_ARCHITECTURE** environment variable. ```powershell $s = New-PSSession -ComputerName Server01 -ConfigurationName CustomShell -Invoke-Command -Session $s {$env:PROCESSOR_ARCHITECTURE} +Invoke-Command -Session $s {$Env:PROCESSOR_ARCHITECTURE} ``` ```Output @@ -568,7 +568,7 @@ for the current process. The change only affects the current process. Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned ``` -You can also use the **ExecutionPolicy** parameter of `PowerShell.exe` to start +You can also use the **ExecutionPolicy** parameter of `powershell.exe` to start a single session with a less restrictive execution policy. ```powershell diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_PSModulePath.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_PSModulePath.md index c4e0ec6dbc4f..63749e3fcae1 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_PSModulePath.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_PSModulePath.md @@ -10,16 +10,16 @@ title: about_PSModulePath ## Short description -This article describes the purpose and usage of the `$env:PSModulePath` +This article describes the purpose and usage of the `$Env:PSModulePath` environment variable. ## Long description -The `$env:PSModulePath` environment variable contains a list of folder +The `$Env:PSModulePath` environment variable contains a list of folder locations. PowerShell recursively searches each folder for module (`.psd1` or `.psm1`) files. -By default, the effective locations assigned to `$env:PSModulePath` are: +By default, the effective locations assigned to `$Env:PSModulePath` are: - Modules installed in the **CurrentUser** scope: - On Windows, these modules are stored in @@ -32,7 +32,7 @@ By default, the effective locations assigned to `$env:PSModulePath` are: `$HOME/.local/share/powershell/Modules` folder. - Modules installed in the **AllUsers** scope: - On Windows, these modules are stored in - `$env:ProgramFiles\PowerShell\Modules`. + `$Env:ProgramFiles\PowerShell\Modules`. - On non-Windows systems, these modules are stored in `/usr/local/share/powershell/Modules`. - Modules that ship with PowerShell are stored in `$PSHOME\Modules`. @@ -40,7 +40,7 @@ By default, the effective locations assigned to `$env:PSModulePath` are: > [!NOTE] > Applications that include PowerShell modules can install modules in other > directories on Windows, such as the `Program Files` folder. The installer -> package might not append the location to the `$env:PSModulePath`. +> package might not append the location to the `$Env:PSModulePath`. The default locations for Windows PowerShell 5.1 are different from PowerShell 7. @@ -48,13 +48,13 @@ The default locations for Windows PowerShell 5.1 are different from PowerShell - Modules installed in the **CurrentUser** scope are stored in `$HOME\Documents\WindowsPowerShell\Modules`. - Modules installed in the **AllUsers** scope are stored in - `$env:ProgramFiles\WindowsPowerShell\Modules`. + `$Env:ProgramFiles\WindowsPowerShell\Modules`. - Modules that ship with Windows PowerShell stored in `$PSHOME\Modules`, which - is `$env:SystemRoot\System32\WindowsPowerShell\1.0\Modules`. + is `$Env:SystemRoot\System32\WindowsPowerShell\1.0\Modules`. ## PowerShell PSModulePath construction -The value of `$env:PSModulePath` is constructed each time PowerShell starts. +The value of `$Env:PSModulePath` is constructed each time PowerShell starts. The value varies by version of PowerShell and how you launched it. ### Windows PowerShell startup @@ -72,8 +72,8 @@ startup: the `$PSHOME` location The **CurrentUser** module path is prefixed only if the User scope -`$env:PSModulePath` doesn't exist. Otherwise, the User scope -`$env:PSModulePath` is used as defined. +`$Env:PSModulePath` doesn't exist. Otherwise, the User scope +`$Env:PSModulePath` is used as defined. ### PowerShell 7 startup @@ -90,7 +90,7 @@ User-scoped `Path` with the Machine-scoped `Path`. - Compare to process inherited `PSModulePath` environment variable - If the same: - Append the **AllUsers** `PSModulePath` to the end following the semantics - of the `Path` environment variable + of the `PATH` environment variable - The Windows `System32` path comes from the machine defined `PSModulePath` so doesn't need to be added explicitly - If different, treat as though user explicitly modified it and don't append @@ -110,7 +110,7 @@ if not already defined. For this discussion, _Windows PowerShell_ means both `powershell.exe` and `powershell_ise.exe`. -The value of `$env:PSModulePath` is copied to `WinPSModulePath` with the +The value of `$Env:PSModulePath` is copied to `WinPSModulePath` with the following modifications: - Remove PS7 the User module path @@ -154,7 +154,7 @@ locations. However, you might need to change the value of the `PSModulePath` environment variable. For example, to temporarily add the `C:\Program Files\Fabrikam\Modules` -directory to `$env:PSModulePath` for the current session, type: +directory to `$Env:PSModulePath` for the current session, type: ```powershell $Env:PSModulePath = $Env:PSModulePath+";C:\Program Files\Fabrikam\Modules" diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md index 60cd09726232..37a46dca236f 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md @@ -283,14 +283,14 @@ the here-string, all quotation marks are interpreted literally. For example: ```powershell @" -For help, type "get-help" +For help, type "Get-Help" "@ ``` The output of this command is: ```Output -For help, type "get-help" +For help, type "Get-Help" ``` Using a here-string can simplify using a string in a command. For example: @@ -347,7 +347,7 @@ Here-strings are typically used to assign multiple lines to a variable. For example, the following here-string assigns a page of XML to the $page variable. ```powershell -$page = [XML] @" +$page = [xml] @" diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Redirection.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Redirection.md index 7e18fa41ea17..5fa0ace747fb 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Redirection.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Redirection.md @@ -160,7 +160,7 @@ Get-Item /not-here 2>&1 >> log.txt $ErrorActionPreference = 'Stop' $ErrorActionPreference >> log.txt -Try { +try { Get-Item /not-here 2>&1 >> log.txt } catch { @@ -188,7 +188,7 @@ Can't find path 'C:\not-here' because it doesn't exist. [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): H Get-Item: C:\temp\test.ps1:23 Line | - 23 | get-item /not-here 2>&1 >> log.txt + 23 | Get-Item /not-here 2>&1 >> log.txt | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | The running command stopped because the user selected the Stop option. ``` @@ -201,7 +201,7 @@ Continue Get-Item: C:\temp\test.ps1:3 Line | - 3 | get-item /not-here 2>&1 >> log.txt + 3 | Get-Item /not-here 2>&1 >> log.txt | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Cannot find path 'C:\not-here' because it does not exist. @@ -301,7 +301,7 @@ redirection operators as well. Put the following command near the top of your script to set `Out-File:Width` for the whole script: ```powershell -$PSDefaultParameterValues['out-file:width'] = 2000 +$PSDefaultParameterValues['Out-File:Width'] = 2000 ``` Increasing the output width will increase memory consumption when logging @@ -313,7 +313,7 @@ you will need to pipe the output through `Format-Table -AutoSize` before outputting to file. ```powershell -$PSDefaultParameterValues['out-file:width'] = 2000 +$PSDefaultParameterValues['Out-File:Width'] = 2000 Get-Service | Format-Table -AutoSize > services.log ``` diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Ref.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Ref.md index 364f117031c1..2db596d16040 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Ref.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Ref.md @@ -32,13 +32,13 @@ to it. In PowerShell, integers are value types so they're passed by value. Therefore, the value of `$var` is unchanged outside the scope of the function. ```powershell -Function Test($data) +Function Test($Data) { - $data = 3 + $Data = 3 } $var = 10 -Test -data $var +Test -Data $var $var ``` @@ -54,13 +54,13 @@ When passing a variable _by reference_, the function can change the data and that change persists after the function executes. ```powershell -Function Test($data) +Function Test($Data) { - $data.Test = "New Text" + $Data.Test = "New Text" } $var = @{} -Test -data $var +Test -Data $var $var ``` @@ -84,8 +84,8 @@ access your data. ```powershell function Test { - param([ref]$data) - $data.Value = 3 + param([ref]$Data) + $Data.Value = 3 } ``` @@ -97,7 +97,7 @@ your variable as a reference. ```powershell $var = 10 -Test -data ([ref]$var) +Test -Data ([ref]$var) $var ``` diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Registry_Provider.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Registry_Provider.md index 26996a7aa4bc..0557aeebac17 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Registry_Provider.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Registry_Provider.md @@ -337,7 +337,7 @@ ContosoCompany registry key. ```powershell $path = "HKLM:\SOFTWARE\ContosoCompany" -New-ItemProperty -Path $path -Name Test -Type DWORD -Value 1 +New-ItemProperty -Path $path -Name Test -Type DWord -Value 1 ``` > [!NOTE] diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md index 7d58eda17237..cf6be5846bce 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md @@ -230,7 +230,7 @@ input strings. There's a static method of the regex class that can escape text for you. ```powershell -[regex]::escape('3.\d{2,}') +[regex]::Escape('3.\d{2,}') ``` ```Output diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Remote.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Remote.md index cb416d87c60b..18f69f68a0f7 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Remote.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Remote.md @@ -103,7 +103,7 @@ in the same PSSession that uses the `$p` variable. The following command counts the number of processes saved in `$p`. ```powershell -Invoke-Command -Session $s -ScriptBlock {$p.count} +Invoke-Command -Session $s -ScriptBlock {$p.Count} ``` ## How to run a remote command on multiple computers diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md index 6a06273789f8..4553ad31f8dc 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md @@ -138,7 +138,7 @@ all of the operations occur on the remote computer, not the local computer. results of the job in the PsLog.txt file on the Server01 computer. ```powershell - Server01\C:> Receive-Job $job > c:\logs\PsLog.txt + Server01\C:> Receive-Job $job > C:\logs\PsLog.txt ``` 1. To end the interactive session, use the `Exit-PSSession` cmdlet. The command @@ -165,7 +165,7 @@ all of the operations occur on the remote computer, not the local computer. ```powershell $s = New-PSSession -ComputerName Server01 Invoke-Command -Session $s -ScriptBlock { - Get-Content c:\logs\pslog.txt} + Get-Content C:\logs\pslog.txt} ``` ### Start a remote job that returns the results to the local computer (AsJob) @@ -190,8 +190,8 @@ requirements for remoting. assign a display name to the job. ```powershell - Invoke-Command -Computername Server01 -ScriptBlock { - Get-EventLog system} -AsJob + Invoke-Command -ComputerName Server01 -ScriptBlock { + Get-EventLog System} -AsJob ``` The results of the command resemble the following sample output. @@ -199,7 +199,7 @@ requirements for remoting. ```Output SessionId Name State HasMoreData Location Command --------- ---- ----- ----------- -------- ------- - 1 Job1 Running True Server01 Get-EventLog system + 1 Job1 Running True Server01 Get-EventLog System ``` When the **AsJob** parameter is used, `Invoke-Command` returns the same type @@ -229,7 +229,7 @@ requirements for remoting. ```Output SessionId Name State HasMoreData Location Command --------- ---- ----- ----------- -------- ------- - 1 Job1 Completed True Server01 Get-EventLog system + 1 Job1 Completed True Server01 Get-EventLog System ``` 1. To get the results of the job, use the `Receive-Job` cmdlet. Because the job @@ -280,7 +280,7 @@ commands remotely to manage a local job on the remote computer. ```powershell Invoke-Command -Session $s -ScriptBlock { - Start-Job -ScriptBlock {Get-EventLog system}} + Start-Job -ScriptBlock {Get-EventLog System}} ``` The results resemble the following sample output. @@ -288,7 +288,7 @@ commands remotely to manage a local job on the remote computer. ```Output Id Name State HasMoreData Location Command -- ---- ----- ----------- -------- ------- - 2 Job2 Running True Localhost Get-EventLog system + 2 Job2 Running True Localhost Get-EventLog System ``` When you run a `Start-Job` command remotely, `Invoke-Command` returns the @@ -319,7 +319,7 @@ commands remotely to manage a local job on the remote computer. ```Output SessionId Name State HasMoreData Location Command --------- ---- ----- ----------- -------- ------- - 2 Job2 Completed True LocalHost Get-EventLog system + 2 Job2 Completed True LocalHost Get-EventLog System ``` 1. To get the results of the job, use the `Invoke-Command` cmdlet to run a @@ -343,7 +343,7 @@ commands remotely to manage a local job on the remote computer. ```powershell Invoke-Command -Session $s -Command { - Receive-Job -SessionId 2 > c:\logs\pslog.txt + Receive-Job -SessionId 2 > C:\logs\pslog.txt } ``` @@ -364,7 +364,7 @@ objects generated after the disconnect are returned when re-connected. ```powershell # Create remote session on local machine -PS> $session = New-PSSession -cn localhost +PS> $session = New-PSSession -Cn localhost # Start remote job PS> $job = Invoke-Command -Session $session -ScriptBlock { 1..60 | % { sleep 1; "Output $_" } } -AsJob diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md index ea9d658b9921..3c628e5e9047 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md @@ -143,7 +143,7 @@ Administrator privileges are required for the following remoting operations: known as a "loopback" scenario. - Managing session configurations on the local computer. - Viewing and changing WS-Management settings on the local computer. These are - the settings in the LocalHost node of the WSMAN: drive. + the settings in the LocalHost node of the WSMan: drive. You must start PowerShell with the **Run as administrator** option even if you are a member of the **Administrators** group on the local computer. diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md index 192241985eb7..0b4594f97f66 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md @@ -238,7 +238,7 @@ configurations. To see the **RootSDDL** security descriptor, type: ```powershell -Get-Item wsman:\localhost\Service\RootSDDL +Get-Item WSMan:\localhost\Service\RootSDDL ``` To change the **RootSDDL**, use the `Set-Item` cmdlet in the `WSMan:` drive. To @@ -382,14 +382,14 @@ trusted hosts on the computer. To view the list of trusted hosts, use the following command: ```powershell -Get-Item wsman:\localhost\Client\TrustedHosts +Get-Item WSMan:\localhost\Client\TrustedHosts ``` The following example uses the wildcard character (`*`) to add all computers to the list of trusted hosts. ```powershell -Set-Item wsman:localhost\client\trustedhosts -Value * +Set-Item WSMan:localhost\client\trustedhosts -Value * ``` You can also use a wildcard character (`*`) to add all computers in a @@ -397,14 +397,14 @@ particular domain to the list of trusted hosts. For example, the following command adds all of the computers in the Fabrikam domain. ```powershell -Set-Item wsman:localhost\client\trustedhosts *.fabrikam.com +Set-Item WSMan:localhost\client\trustedhosts *.fabrikam.com ``` The following example set the list of trusted hosts to a single computer. ```powershell $server = 'Server01.Domain01.Fabrikam.com' -Set-Item wsman:\localhost\Client\TrustedHosts -Value $server +Set-Item WSMan:\localhost\Client\TrustedHosts -Value $server ``` To add a computer name to an existing list of trusted hosts, first save the @@ -415,21 +415,21 @@ The following example add Server01 to an existing list of trusted hosts. ```powershell $newServer = 'Server01.Domain01.Fabrikam.com' -$curValue = (Get-Item wsman:\localhost\Client\TrustedHosts).Value -Set-Item wsman:\localhost\Client\TrustedHosts -Value "$curValue, $newServer" +$curValue = (Get-Item WSMan:\localhost\Client\TrustedHosts).Value +Set-Item WSMan:\localhost\Client\TrustedHosts -Value "$curValue, $newServer" ``` To add the IP addresses of particular computers to the list of trusted hosts, use the following command format: ```powershell -Set-Item wsman:\localhost\Client\TrustedHosts -Value +Set-Item WSMan:\localhost\Client\TrustedHosts -Value ``` For example: ```powershell -Set-Item wsman:\localhost\Client\TrustedHosts -Value 172.16.0.0 +Set-Item WSMan:\localhost\Client\TrustedHosts -Value 172.16.0.0 ``` To add a computer to the **TrustedHosts** list of a remote computer, use the @@ -455,7 +455,7 @@ Use `Set-Item` cmdlet to change the **Port** value in the listener leaf node. For example, the following command changes the default port to 8080. ```powershell -Set-Item wsman:\localhost\listener\listener*\port -Value 8080 +Set-Item WSMan:\localhost\listener\listener*\port -Value 8080 ``` ## How to configure remoting with a proxy server @@ -518,17 +518,17 @@ For error: If the remote computer is running a 64-bit version of Windows, and the remote command uses a 32-bit session configuration, like **Microsoft.PowerShell32**, WinRM loads a WOW64 process. Windows automatically redirects all references to -`$env:Windir\System32` to the `$env:Windir\SysWOW64` directory. +`$Env:windir\System32` to the `$Env:windir\SysWOW64` directory. As a result, running tools in the `System32` directory that do not have -counterparts in the `SysWow64` directory can't be found. +counterparts in the `SysWOW64` directory can't be found. To find the processor architecture that is being used in the session, use the value of the **PROCESSOR_ARCHITECTURE** environment variable. ```powershell $s = New-PSSession -ComputerName Server01 -ConfigurationName CustomShell -Invoke-Command -Session $s {$env:PROCESSOR_ARCHITECTURE} +Invoke-Command -Session $s {$Env:PROCESSOR_ARCHITECTURE} ``` ```Output @@ -567,7 +567,7 @@ for the current process. The change only affects the current process. Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned ``` -You can also use the **ExecutionPolicy** parameter of `PowerShell.exe` to start +You can also use the **ExecutionPolicy** parameter of `powershell.exe` to start a single session with a less restrictive execution policy. ```powershell diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_PSModulePath.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_PSModulePath.md index b7f002348ea5..1bc58885b87d 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_PSModulePath.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_PSModulePath.md @@ -10,16 +10,16 @@ title: about_PSModulePath ## Short description -This article describes the purpose and usage of the `$env:PSModulePath` +This article describes the purpose and usage of the `$Env:PSModulePath` environment variable. ## Long description -The `$env:PSModulePath` environment variable contains a list of folder +The `$Env:PSModulePath` environment variable contains a list of folder locations. PowerShell recursively searches each folder for module (`.psd1` or `.psm1`) files. -By default, the effective locations assigned to `$env:PSModulePath` are: +By default, the effective locations assigned to `$Env:PSModulePath` are: - Modules installed in the **CurrentUser** scope: - On Windows, these modules are stored in @@ -32,7 +32,7 @@ By default, the effective locations assigned to `$env:PSModulePath` are: `$HOME/.local/share/powershell/Modules` folder. - Modules installed in the **AllUsers** scope: - On Windows, these modules are stored in - `$env:ProgramFiles\PowerShell\Modules`. + `$Env:ProgramFiles\PowerShell\Modules`. - On non-Windows systems, these modules are stored in `/usr/local/share/powershell/Modules`. - Modules that ship with PowerShell are stored in `$PSHOME\Modules`. @@ -40,7 +40,7 @@ By default, the effective locations assigned to `$env:PSModulePath` are: > [!NOTE] > Applications that include PowerShell modules can install modules in other > directories on Windows, such as the `Program Files` folder. The installer -> package might not append the location to the `$env:PSModulePath`. +> package might not append the location to the `$Env:PSModulePath`. The default locations for Windows PowerShell 5.1 are different from PowerShell 7. @@ -48,13 +48,13 @@ The default locations for Windows PowerShell 5.1 are different from PowerShell - Modules installed in the **CurrentUser** scope are stored in `$HOME\Documents\WindowsPowerShell\Modules`. - Modules installed in the **AllUsers** scope are stored in - `$env:ProgramFiles\WindowsPowerShell\Modules`. + `$Env:ProgramFiles\WindowsPowerShell\Modules`. - Modules that ship with Windows PowerShell stored in `$PSHOME\Modules`, which - is `$env:SystemRoot\System32\WindowsPowerShell\1.0\Modules`. + is `$Env:SystemRoot\System32\WindowsPowerShell\1.0\Modules`. ## PowerShell PSModulePath construction -The value of `$env:PSModulePath` is constructed each time PowerShell starts. +The value of `$Env:PSModulePath` is constructed each time PowerShell starts. The value varies by version of PowerShell and how you launched it. ### Windows PowerShell startup @@ -72,8 +72,8 @@ startup: the `$PSHOME` location The **CurrentUser** module path is prefixed only if the User scope -`$env:PSModulePath` doesn't exist. Otherwise, the User scope -`$env:PSModulePath` is used as defined. +`$Env:PSModulePath` doesn't exist. Otherwise, the User scope +`$Env:PSModulePath` is used as defined. ### PowerShell 7 startup @@ -90,7 +90,7 @@ User-scoped `Path` with the Machine-scoped `Path`. - Compare to process inherited `PSModulePath` environment variable - If the same: - Append the **AllUsers** `PSModulePath` to the end following the semantics - of the `Path` environment variable + of the `PATH` environment variable - The Windows `System32` path comes from the machine defined `PSModulePath` so doesn't need to be added explicitly - If different, treat as though user explicitly modified it and don't append @@ -110,7 +110,7 @@ if not already defined. For this discussion, _Windows PowerShell_ means both `powershell.exe` and `powershell_ise.exe`. -The value of `$env:PSModulePath` is copied to `WinPSModulePath` with the +The value of `$Env:PSModulePath` is copied to `WinPSModulePath` with the following modifications: - Remove PS7 the User module path @@ -154,7 +154,7 @@ locations. However, you might need to change the value of the `PSModulePath` environment variable. For example, to temporarily add the `C:\Program Files\Fabrikam\Modules` -directory to `$env:PSModulePath` for the current session, type: +directory to `$Env:PSModulePath` for the current session, type: ```powershell $Env:PSModulePath = $Env:PSModulePath+";C:\Program Files\Fabrikam\Modules" diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md index 5b4b3b555803..a2ca9fbfd4c9 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md @@ -283,14 +283,14 @@ the here-string, all quotation marks are interpreted literally. For example: ```powershell @" -For help, type "get-help" +For help, type "Get-Help" "@ ``` The output of this command is: ```Output -For help, type "get-help" +For help, type "Get-Help" ``` Using a here-string can simplify using a string in a command. For example: @@ -347,7 +347,7 @@ Here-strings are typically used to assign multiple lines to a variable. For example, the following here-string assigns a page of XML to the $page variable. ```powershell -$page = [XML] @" +$page = [xml] @" diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Redirection.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Redirection.md index b669d77008e9..eaa46e6ae5b2 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Redirection.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Redirection.md @@ -160,7 +160,7 @@ Get-Item /not-here 2>&1 >> log.txt $ErrorActionPreference = 'Stop' $ErrorActionPreference >> log.txt -Try { +try { Get-Item /not-here 2>&1 >> log.txt } catch { @@ -188,7 +188,7 @@ Can't find path 'C:\not-here' because it doesn't exist. [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): H Get-Item: C:\temp\test.ps1:23 Line | - 23 | get-item /not-here 2>&1 >> log.txt + 23 | Get-Item /not-here 2>&1 >> log.txt | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | The running command stopped because the user selected the Stop option. ``` @@ -201,7 +201,7 @@ Continue Get-Item: C:\temp\test.ps1:3 Line | - 3 | get-item /not-here 2>&1 >> log.txt + 3 | Get-Item /not-here 2>&1 >> log.txt | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Cannot find path 'C:\not-here' because it does not exist. @@ -301,7 +301,7 @@ redirection operators as well. Put the following command near the top of your script to set `Out-File:Width` for the whole script: ```powershell -$PSDefaultParameterValues['out-file:width'] = 2000 +$PSDefaultParameterValues['Out-File:Width'] = 2000 ``` Increasing the output width will increase memory consumption when logging @@ -313,7 +313,7 @@ you will need to pipe the output through `Format-Table -AutoSize` before outputting to file. ```powershell -$PSDefaultParameterValues['out-file:width'] = 2000 +$PSDefaultParameterValues['Out-File:Width'] = 2000 Get-Service | Format-Table -AutoSize > services.log ``` diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Ref.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Ref.md index 7a111cc73d46..5a0e327477eb 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Ref.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Ref.md @@ -32,13 +32,13 @@ to it. In PowerShell, integers are value types so they're passed by value. Therefore, the value of `$var` is unchanged outside the scope of the function. ```powershell -Function Test($data) +Function Test($Data) { - $data = 3 + $Data = 3 } $var = 10 -Test -data $var +Test -Data $var $var ``` @@ -54,13 +54,13 @@ When passing a variable _by reference_, the function can change the data and that change persists after the function executes. ```powershell -Function Test($data) +Function Test($Data) { - $data.Test = "New Text" + $Data.Test = "New Text" } $var = @{} -Test -data $var +Test -Data $var $var ``` @@ -84,8 +84,8 @@ access your data. ```powershell function Test { - param([ref]$data) - $data.Value = 3 + param([ref]$Data) + $Data.Value = 3 } ``` @@ -97,7 +97,7 @@ your variable as a reference. ```powershell $var = 10 -Test -data ([ref]$var) +Test -Data ([ref]$var) $var ``` diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Registry_Provider.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Registry_Provider.md index 953f26eb4885..e2097b1ee015 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Registry_Provider.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Registry_Provider.md @@ -337,7 +337,7 @@ ContosoCompany registry key. ```powershell $path = "HKLM:\SOFTWARE\ContosoCompany" -New-ItemProperty -Path $path -Name Test -Type DWORD -Value 1 +New-ItemProperty -Path $path -Name Test -Type DWord -Value 1 ``` > [!NOTE] diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md index 35787092707c..21c5f14158bb 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md @@ -230,7 +230,7 @@ input strings. There's a static method of the regex class that can escape text for you. ```powershell -[regex]::escape('3.\d{2,}') +[regex]::Escape('3.\d{2,}') ``` ```Output diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Remote.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Remote.md index cf2a64106f95..95c97dd7febf 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Remote.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Remote.md @@ -104,7 +104,7 @@ in the same PSSession that uses the `$p` variable. The following command counts the number of processes saved in `$p`. ```powershell -Invoke-Command -Session $s -ScriptBlock {$p.count} +Invoke-Command -Session $s -ScriptBlock {$p.Count} ``` ## How to run a remote command on multiple computers diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md index bd4fd712983e..89b8cc1ab655 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md @@ -138,7 +138,7 @@ all of the operations occur on the remote computer, not the local computer. results of the job in the PsLog.txt file on the Server01 computer. ```powershell - Server01\C:> Receive-Job $job > c:\logs\PsLog.txt + Server01\C:> Receive-Job $job > C:\logs\PsLog.txt ``` 1. To end the interactive session, use the `Exit-PSSession` cmdlet. The command @@ -165,7 +165,7 @@ all of the operations occur on the remote computer, not the local computer. ```powershell $s = New-PSSession -ComputerName Server01 Invoke-Command -Session $s -ScriptBlock { - Get-Content c:\logs\pslog.txt} + Get-Content C:\logs\pslog.txt} ``` ### Start a remote job that returns the results to the local computer (AsJob) @@ -190,8 +190,8 @@ requirements for remoting. assign a display name to the job. ```powershell - Invoke-Command -Computername Server01 -ScriptBlock { - Get-EventLog system} -AsJob + Invoke-Command -ComputerName Server01 -ScriptBlock { + Get-EventLog System} -AsJob ``` The results of the command resemble the following sample output. @@ -199,7 +199,7 @@ requirements for remoting. ```Output SessionId Name State HasMoreData Location Command --------- ---- ----- ----------- -------- ------- - 1 Job1 Running True Server01 Get-EventLog system + 1 Job1 Running True Server01 Get-EventLog System ``` When the **AsJob** parameter is used, `Invoke-Command` returns the same type @@ -229,7 +229,7 @@ requirements for remoting. ```Output SessionId Name State HasMoreData Location Command --------- ---- ----- ----------- -------- ------- - 1 Job1 Completed True Server01 Get-EventLog system + 1 Job1 Completed True Server01 Get-EventLog System ``` 1. To get the results of the job, use the `Receive-Job` cmdlet. Because the job @@ -280,7 +280,7 @@ commands remotely to manage a local job on the remote computer. ```powershell Invoke-Command -Session $s -ScriptBlock { - Start-Job -ScriptBlock {Get-EventLog system}} + Start-Job -ScriptBlock {Get-EventLog System}} ``` The results resemble the following sample output. @@ -288,7 +288,7 @@ commands remotely to manage a local job on the remote computer. ```Output Id Name State HasMoreData Location Command -- ---- ----- ----------- -------- ------- - 2 Job2 Running True Localhost Get-EventLog system + 2 Job2 Running True Localhost Get-EventLog System ``` When you run a `Start-Job` command remotely, `Invoke-Command` returns the @@ -319,7 +319,7 @@ commands remotely to manage a local job on the remote computer. ```Output SessionId Name State HasMoreData Location Command --------- ---- ----- ----------- -------- ------- - 2 Job2 Completed True LocalHost Get-EventLog system + 2 Job2 Completed True LocalHost Get-EventLog System ``` 1. To get the results of the job, use the `Invoke-Command` cmdlet to run a @@ -343,7 +343,7 @@ commands remotely to manage a local job on the remote computer. ```powershell Invoke-Command -Session $s -Command { - Receive-Job -SessionId 2 > c:\logs\pslog.txt + Receive-Job -SessionId 2 > C:\logs\pslog.txt } ``` @@ -364,7 +364,7 @@ objects generated after the disconnect are returned when re-connected. ```powershell # Create remote session on local machine -PS> $session = New-PSSession -cn localhost +PS> $session = New-PSSession -Cn localhost # Start remote job PS> $job = Invoke-Command -Session $session -ScriptBlock { 1..60 | % { sleep 1; "Output $_" } } -AsJob diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md index 45c80ae04ad8..b53e5701261f 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md @@ -144,7 +144,7 @@ Administrator privileges are required for the following remoting operations: known as a "loopback" scenario. - Managing session configurations on the local computer. - Viewing and changing WS-Management settings on the local computer. These are - the settings in the LocalHost node of the WSMAN: drive. + the settings in the LocalHost node of the WSMan: drive. You must start PowerShell with the **Run as administrator** option even if you are a member of the **Administrators** group on the local computer. diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md index cbce1f400f63..ca8b83243531 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md @@ -239,7 +239,7 @@ configurations. To see the **RootSDDL** security descriptor, type: ```powershell -Get-Item wsman:\localhost\Service\RootSDDL +Get-Item WSMan:\localhost\Service\RootSDDL ``` To change the **RootSDDL**, use the `Set-Item` cmdlet in the `WSMan:` drive. To @@ -383,14 +383,14 @@ trusted hosts on the computer. To view the list of trusted hosts, use the following command: ```powershell -Get-Item wsman:\localhost\Client\TrustedHosts +Get-Item WSMan:\localhost\Client\TrustedHosts ``` The following example uses the wildcard character (`*`) to add all computers to the list of trusted hosts. ```powershell -Set-Item wsman:localhost\client\trustedhosts -Value * +Set-Item WSMan:localhost\client\trustedhosts -Value * ``` You can also use a wildcard character (`*`) to add all computers in a @@ -398,14 +398,14 @@ particular domain to the list of trusted hosts. For example, the following command adds all of the computers in the Fabrikam domain. ```powershell -Set-Item wsman:localhost\client\trustedhosts *.fabrikam.com +Set-Item WSMan:localhost\client\trustedhosts *.fabrikam.com ``` The following example set the list of trusted hosts to a single computer. ```powershell $server = 'Server01.Domain01.Fabrikam.com' -Set-Item wsman:\localhost\Client\TrustedHosts -Value $server +Set-Item WSMan:\localhost\Client\TrustedHosts -Value $server ``` To add a computer name to an existing list of trusted hosts, first save the @@ -416,21 +416,21 @@ The following example add Server01 to an existing list of trusted hosts. ```powershell $newServer = 'Server01.Domain01.Fabrikam.com' -$curValue = (Get-Item wsman:\localhost\Client\TrustedHosts).Value -Set-Item wsman:\localhost\Client\TrustedHosts -Value "$curValue, $newServer" +$curValue = (Get-Item WSMan:\localhost\Client\TrustedHosts).Value +Set-Item WSMan:\localhost\Client\TrustedHosts -Value "$curValue, $newServer" ``` To add the IP addresses of particular computers to the list of trusted hosts, use the following command format: ```powershell -Set-Item wsman:\localhost\Client\TrustedHosts -Value +Set-Item WSMan:\localhost\Client\TrustedHosts -Value ``` For example: ```powershell -Set-Item wsman:\localhost\Client\TrustedHosts -Value 172.16.0.0 +Set-Item WSMan:\localhost\Client\TrustedHosts -Value 172.16.0.0 ``` To add a computer to the **TrustedHosts** list of a remote computer, use the @@ -456,7 +456,7 @@ Use `Set-Item` cmdlet to change the **Port** value in the listener leaf node. For example, the following command changes the default port to 8080. ```powershell -Set-Item wsman:\localhost\listener\listener*\port -Value 8080 +Set-Item WSMan:\localhost\listener\listener*\port -Value 8080 ``` ## How to configure remoting with a proxy server @@ -519,17 +519,17 @@ For error: If the remote computer is running a 64-bit version of Windows, and the remote command uses a 32-bit session configuration, like **Microsoft.PowerShell32**, WinRM loads a WOW64 process. Windows automatically redirects all references to -`$env:Windir\System32` to the `$env:Windir\SysWOW64` directory. +`$Env:windir\System32` to the `$Env:windir\SysWOW64` directory. As a result, running tools in the `System32` directory that do not have -counterparts in the `SysWow64` directory can't be found. +counterparts in the `SysWOW64` directory can't be found. To find the processor architecture that is being used in the session, use the value of the **PROCESSOR_ARCHITECTURE** environment variable. ```powershell $s = New-PSSession -ComputerName Server01 -ConfigurationName CustomShell -Invoke-Command -Session $s {$env:PROCESSOR_ARCHITECTURE} +Invoke-Command -Session $s {$Env:PROCESSOR_ARCHITECTURE} ``` ```Output @@ -568,7 +568,7 @@ for the current process. The change only affects the current process. Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned ``` -You can also use the **ExecutionPolicy** parameter of `PowerShell.exe` to start +You can also use the **ExecutionPolicy** parameter of `powershell.exe` to start a single session with a less restrictive execution policy. ```powershell diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_PSModulePath.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_PSModulePath.md index 254e0c42f90f..b1d1ead159f1 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_PSModulePath.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_PSModulePath.md @@ -10,16 +10,16 @@ title: about_PSModulePath ## Short description -This article describes the purpose and usage of the `$env:PSModulePath` +This article describes the purpose and usage of the `$Env:PSModulePath` environment variable. ## Long description -The `$env:PSModulePath` environment variable contains a list of folder +The `$Env:PSModulePath` environment variable contains a list of folder locations. PowerShell recursively searches each folder for module (`.psd1` or `.psm1`) files. -By default, the effective locations assigned to `$env:PSModulePath` are: +By default, the effective locations assigned to `$Env:PSModulePath` are: - Modules installed in the **CurrentUser** scope: - On Windows, these modules are stored in @@ -32,7 +32,7 @@ By default, the effective locations assigned to `$env:PSModulePath` are: `$HOME/.local/share/powershell/Modules` folder. - Modules installed in the **AllUsers** scope: - On Windows, these modules are stored in - `$env:ProgramFiles\PowerShell\Modules`. + `$Env:ProgramFiles\PowerShell\Modules`. - On non-Windows systems, these modules are stored in `/usr/local/share/powershell/Modules`. - Modules that ship with PowerShell are stored in `$PSHOME\Modules`. @@ -40,7 +40,7 @@ By default, the effective locations assigned to `$env:PSModulePath` are: > [!NOTE] > Applications that include PowerShell modules can install modules in other > directories on Windows, such as the `Program Files` folder. The installer -> package might not append the location to the `$env:PSModulePath`. +> package might not append the location to the `$Env:PSModulePath`. The default locations for Windows PowerShell 5.1 are different from PowerShell 7. @@ -48,13 +48,13 @@ The default locations for Windows PowerShell 5.1 are different from PowerShell - Modules installed in the **CurrentUser** scope are stored in `$HOME\Documents\WindowsPowerShell\Modules`. - Modules installed in the **AllUsers** scope are stored in - `$env:ProgramFiles\WindowsPowerShell\Modules`. + `$Env:ProgramFiles\WindowsPowerShell\Modules`. - Modules that ship with Windows PowerShell stored in `$PSHOME\Modules`, which - is `$env:SystemRoot\System32\WindowsPowerShell\1.0\Modules`. + is `$Env:SystemRoot\System32\WindowsPowerShell\1.0\Modules`. ## PowerShell PSModulePath construction -The value of `$env:PSModulePath` is constructed each time PowerShell starts. +The value of `$Env:PSModulePath` is constructed each time PowerShell starts. The value varies by version of PowerShell and how you launched it. ### Windows PowerShell startup @@ -72,8 +72,8 @@ startup: the `$PSHOME` location The **CurrentUser** module path is prefixed only if the User scope -`$env:PSModulePath` doesn't exist. Otherwise, the User scope -`$env:PSModulePath` is used as defined. +`$Env:PSModulePath` doesn't exist. Otherwise, the User scope +`$Env:PSModulePath` is used as defined. ### PowerShell 7 startup @@ -90,7 +90,7 @@ User-scoped `Path` with the Machine-scoped `Path`. - Compare to process inherited `PSModulePath` environment variable - If the same: - Append the **AllUsers** `PSModulePath` to the end following the semantics - of the `Path` environment variable + of the `PATH` environment variable - The Windows `System32` path comes from the machine defined `PSModulePath` so doesn't need to be added explicitly - If different, treat as though user explicitly modified it and don't append @@ -110,7 +110,7 @@ if not already defined. For this discussion, _Windows PowerShell_ means both `powershell.exe` and `powershell_ise.exe`. -The value of `$env:PSModulePath` is copied to `WinPSModulePath` with the +The value of `$Env:PSModulePath` is copied to `WinPSModulePath` with the following modifications: - Remove PS7 the User module path @@ -154,7 +154,7 @@ locations. However, you might need to change the value of the `PSModulePath` environment variable. For example, to temporarily add the `C:\Program Files\Fabrikam\Modules` -directory to `$env:PSModulePath` for the current session, type: +directory to `$Env:PSModulePath` for the current session, type: ```powershell $Env:PSModulePath = $Env:PSModulePath+";C:\Program Files\Fabrikam\Modules" diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md index 83565a666872..de96d67efe65 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md @@ -283,14 +283,14 @@ the here-string, all quotation marks are interpreted literally. For example: ```powershell @" -For help, type "get-help" +For help, type "Get-Help" "@ ``` The output of this command is: ```Output -For help, type "get-help" +For help, type "Get-Help" ``` Using a here-string can simplify using a string in a command. For example: @@ -347,7 +347,7 @@ Here-strings are typically used to assign multiple lines to a variable. For example, the following here-string assigns a page of XML to the $page variable. ```powershell -$page = [XML] @" +$page = [xml] @" diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_Redirection.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_Redirection.md index d17b70751713..2a1b0359f310 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_Redirection.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_Redirection.md @@ -160,7 +160,7 @@ Get-Item /not-here 2>&1 >> log.txt $ErrorActionPreference = 'Stop' $ErrorActionPreference >> log.txt -Try { +try { Get-Item /not-here 2>&1 >> log.txt } catch { @@ -188,7 +188,7 @@ Can't find path 'C:\not-here' because it doesn't exist. [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): H Get-Item: C:\temp\test.ps1:23 Line | - 23 | get-item /not-here 2>&1 >> log.txt + 23 | Get-Item /not-here 2>&1 >> log.txt | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | The running command stopped because the user selected the Stop option. ``` @@ -201,7 +201,7 @@ Continue Get-Item: C:\temp\test.ps1:3 Line | - 3 | get-item /not-here 2>&1 >> log.txt + 3 | Get-Item /not-here 2>&1 >> log.txt | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Cannot find path 'C:\not-here' because it does not exist. @@ -301,7 +301,7 @@ redirection operators as well. Put the following command near the top of your script to set `Out-File:Width` for the whole script: ```powershell -$PSDefaultParameterValues['out-file:width'] = 2000 +$PSDefaultParameterValues['Out-File:Width'] = 2000 ``` Increasing the output width will increase memory consumption when logging @@ -313,7 +313,7 @@ you will need to pipe the output through `Format-Table -AutoSize` before outputting to file. ```powershell -$PSDefaultParameterValues['out-file:width'] = 2000 +$PSDefaultParameterValues['Out-File:Width'] = 2000 Get-Service | Format-Table -AutoSize > services.log ``` diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_Ref.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_Ref.md index 274435b4fb40..b0fbeb226301 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_Ref.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_Ref.md @@ -32,13 +32,13 @@ to it. In PowerShell, integers are value types so they're passed by value. Therefore, the value of `$var` is unchanged outside the scope of the function. ```powershell -Function Test($data) +Function Test($Data) { - $data = 3 + $Data = 3 } $var = 10 -Test -data $var +Test -Data $var $var ``` @@ -54,13 +54,13 @@ When passing a variable _by reference_, the function can change the data and that change persists after the function executes. ```powershell -Function Test($data) +Function Test($Data) { - $data.Test = "New Text" + $Data.Test = "New Text" } $var = @{} -Test -data $var +Test -Data $var $var ``` @@ -84,8 +84,8 @@ access your data. ```powershell function Test { - param([ref]$data) - $data.Value = 3 + param([ref]$Data) + $Data.Value = 3 } ``` @@ -97,7 +97,7 @@ your variable as a reference. ```powershell $var = 10 -Test -data ([ref]$var) +Test -Data ([ref]$var) $var ``` diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_Registry_Provider.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_Registry_Provider.md index 794578d83018..c46134f39cfc 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_Registry_Provider.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_Registry_Provider.md @@ -337,7 +337,7 @@ ContosoCompany registry key. ```powershell $path = "HKLM:\SOFTWARE\ContosoCompany" -New-ItemProperty -Path $path -Name Test -Type DWORD -Value 1 +New-ItemProperty -Path $path -Name Test -Type DWord -Value 1 ``` > [!NOTE] diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md index 7698b2f16cbb..c56806eb8f51 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md @@ -230,7 +230,7 @@ input strings. There's a static method of the regex class that can escape text for you. ```powershell -[regex]::escape('3.\d{2,}') +[regex]::Escape('3.\d{2,}') ``` ```Output diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_Remote.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_Remote.md index 2a12804a3886..6bf74b49ebfe 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_Remote.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_Remote.md @@ -104,7 +104,7 @@ in the same PSSession that uses the `$p` variable. The following command counts the number of processes saved in `$p`. ```powershell -Invoke-Command -Session $s -ScriptBlock {$p.count} +Invoke-Command -Session $s -ScriptBlock {$p.Count} ``` ## How to run a remote command on multiple computers diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md index 8c661b4ce244..3b5ed912d0e5 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md @@ -138,7 +138,7 @@ all of the operations occur on the remote computer, not the local computer. results of the job in the PsLog.txt file on the Server01 computer. ```powershell - Server01\C:> Receive-Job $job > c:\logs\PsLog.txt + Server01\C:> Receive-Job $job > C:\logs\PsLog.txt ``` 1. To end the interactive session, use the `Exit-PSSession` cmdlet. The command @@ -165,7 +165,7 @@ all of the operations occur on the remote computer, not the local computer. ```powershell $s = New-PSSession -ComputerName Server01 Invoke-Command -Session $s -ScriptBlock { - Get-Content c:\logs\pslog.txt} + Get-Content C:\logs\pslog.txt} ``` ### Start a remote job that returns the results to the local computer (AsJob) @@ -190,8 +190,8 @@ requirements for remoting. assign a display name to the job. ```powershell - Invoke-Command -Computername Server01 -ScriptBlock { - Get-EventLog system} -AsJob + Invoke-Command -ComputerName Server01 -ScriptBlock { + Get-EventLog System} -AsJob ``` The results of the command resemble the following sample output. @@ -199,7 +199,7 @@ requirements for remoting. ```Output SessionId Name State HasMoreData Location Command --------- ---- ----- ----------- -------- ------- - 1 Job1 Running True Server01 Get-EventLog system + 1 Job1 Running True Server01 Get-EventLog System ``` When the **AsJob** parameter is used, `Invoke-Command` returns the same type @@ -229,7 +229,7 @@ requirements for remoting. ```Output SessionId Name State HasMoreData Location Command --------- ---- ----- ----------- -------- ------- - 1 Job1 Completed True Server01 Get-EventLog system + 1 Job1 Completed True Server01 Get-EventLog System ``` 1. To get the results of the job, use the `Receive-Job` cmdlet. Because the job @@ -280,7 +280,7 @@ commands remotely to manage a local job on the remote computer. ```powershell Invoke-Command -Session $s -ScriptBlock { - Start-Job -ScriptBlock {Get-EventLog system}} + Start-Job -ScriptBlock {Get-EventLog System}} ``` The results resemble the following sample output. @@ -288,7 +288,7 @@ commands remotely to manage a local job on the remote computer. ```Output Id Name State HasMoreData Location Command -- ---- ----- ----------- -------- ------- - 2 Job2 Running True Localhost Get-EventLog system + 2 Job2 Running True Localhost Get-EventLog System ``` When you run a `Start-Job` command remotely, `Invoke-Command` returns the @@ -319,7 +319,7 @@ commands remotely to manage a local job on the remote computer. ```Output SessionId Name State HasMoreData Location Command --------- ---- ----- ----------- -------- ------- - 2 Job2 Completed True LocalHost Get-EventLog system + 2 Job2 Completed True LocalHost Get-EventLog System ``` 1. To get the results of the job, use the `Invoke-Command` cmdlet to run a @@ -343,7 +343,7 @@ commands remotely to manage a local job on the remote computer. ```powershell Invoke-Command -Session $s -Command { - Receive-Job -SessionId 2 > c:\logs\pslog.txt + Receive-Job -SessionId 2 > C:\logs\pslog.txt } ``` @@ -364,7 +364,7 @@ objects generated after the disconnect are returned when re-connected. ```powershell # Create remote session on local machine -PS> $session = New-PSSession -cn localhost +PS> $session = New-PSSession -Cn localhost # Start remote job PS> $job = Invoke-Command -Session $session -ScriptBlock { 1..60 | % { sleep 1; "Output $_" } } -AsJob diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md index 2a7b8604f38a..2c07dddf7d17 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md @@ -144,7 +144,7 @@ Administrator privileges are required for the following remoting operations: known as a "loopback" scenario. - Managing session configurations on the local computer. - Viewing and changing WS-Management settings on the local computer. These are - the settings in the LocalHost node of the WSMAN: drive. + the settings in the LocalHost node of the WSMan: drive. You must start PowerShell with the **Run as administrator** option even if you are a member of the **Administrators** group on the local computer. diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md index c2e09533863c..5b16418bef20 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md @@ -239,7 +239,7 @@ configurations. To see the **RootSDDL** security descriptor, type: ```powershell -Get-Item wsman:\localhost\Service\RootSDDL +Get-Item WSMan:\localhost\Service\RootSDDL ``` To change the **RootSDDL**, use the `Set-Item` cmdlet in the `WSMan:` drive. To @@ -383,14 +383,14 @@ trusted hosts on the computer. To view the list of trusted hosts, use the following command: ```powershell -Get-Item wsman:\localhost\Client\TrustedHosts +Get-Item WSMan:\localhost\Client\TrustedHosts ``` The following example uses the wildcard character (`*`) to add all computers to the list of trusted hosts. ```powershell -Set-Item wsman:localhost\client\trustedhosts -Value * +Set-Item WSMan:localhost\client\trustedhosts -Value * ``` You can also use a wildcard character (`*`) to add all computers in a @@ -398,14 +398,14 @@ particular domain to the list of trusted hosts. For example, the following command adds all of the computers in the Fabrikam domain. ```powershell -Set-Item wsman:localhost\client\trustedhosts *.fabrikam.com +Set-Item WSMan:localhost\client\trustedhosts *.fabrikam.com ``` The following example set the list of trusted hosts to a single computer. ```powershell $server = 'Server01.Domain01.Fabrikam.com' -Set-Item wsman:\localhost\Client\TrustedHosts -Value $server +Set-Item WSMan:\localhost\Client\TrustedHosts -Value $server ``` To add a computer name to an existing list of trusted hosts, first save the @@ -416,21 +416,21 @@ The following example add Server01 to an existing list of trusted hosts. ```powershell $newServer = 'Server01.Domain01.Fabrikam.com' -$curValue = (Get-Item wsman:\localhost\Client\TrustedHosts).Value -Set-Item wsman:\localhost\Client\TrustedHosts -Value "$curValue, $newServer" +$curValue = (Get-Item WSMan:\localhost\Client\TrustedHosts).Value +Set-Item WSMan:\localhost\Client\TrustedHosts -Value "$curValue, $newServer" ``` To add the IP addresses of particular computers to the list of trusted hosts, use the following command format: ```powershell -Set-Item wsman:\localhost\Client\TrustedHosts -Value +Set-Item WSMan:\localhost\Client\TrustedHosts -Value ``` For example: ```powershell -Set-Item wsman:\localhost\Client\TrustedHosts -Value 172.16.0.0 +Set-Item WSMan:\localhost\Client\TrustedHosts -Value 172.16.0.0 ``` To add a computer to the **TrustedHosts** list of a remote computer, use the @@ -456,7 +456,7 @@ Use `Set-Item` cmdlet to change the **Port** value in the listener leaf node. For example, the following command changes the default port to 8080. ```powershell -Set-Item wsman:\localhost\listener\listener*\port -Value 8080 +Set-Item WSMan:\localhost\listener\listener*\port -Value 8080 ``` ## How to configure remoting with a proxy server @@ -519,17 +519,17 @@ For error: If the remote computer is running a 64-bit version of Windows, and the remote command uses a 32-bit session configuration, like **Microsoft.PowerShell32**, WinRM loads a WOW64 process. Windows automatically redirects all references to -`$env:Windir\System32` to the `$env:Windir\SysWOW64` directory. +`$Env:windir\System32` to the `$Env:windir\SysWOW64` directory. As a result, running tools in the `System32` directory that do not have -counterparts in the `SysWow64` directory can't be found. +counterparts in the `SysWOW64` directory can't be found. To find the processor architecture that is being used in the session, use the value of the **PROCESSOR_ARCHITECTURE** environment variable. ```powershell $s = New-PSSession -ComputerName Server01 -ConfigurationName CustomShell -Invoke-Command -Session $s {$env:PROCESSOR_ARCHITECTURE} +Invoke-Command -Session $s {$Env:PROCESSOR_ARCHITECTURE} ``` ```Output @@ -568,7 +568,7 @@ for the current process. The change only affects the current process. Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned ``` -You can also use the **ExecutionPolicy** parameter of `PowerShell.exe` to start +You can also use the **ExecutionPolicy** parameter of `powershell.exe` to start a single session with a less restrictive execution policy. ```powershell