diff --git a/reference/5.1/Microsoft.PowerShell.Core/Disconnect-PSSession.md b/reference/5.1/Microsoft.PowerShell.Core/Disconnect-PSSession.md index b98040142354..3b2001430f83 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/Disconnect-PSSession.md +++ b/reference/5.1/Microsoft.PowerShell.Core/Disconnect-PSSession.md @@ -221,7 +221,7 @@ OutputBufferingMode : Block AutoRestart : false SecurityDescriptorSddl : O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD) MaxMemoryPerShellMB : 1024 -MaxIdleTimeoutms : 2147483647 +MaxIdleTimeoutMs : 2147483647 Uri : http://schemas.microsoft.com/powershell/microsoft.powershell SDKVersion : 2 Name : microsoft.powershell @@ -296,7 +296,7 @@ violation can go undetected while the session is in use. The fourth command uses the `Invoke-Command` cmdlet to run a `Get-PSSessionConfiguration` command for the `Microsoft.PowerShell` session configuration on the Server01 computer. The command uses the `Format-List` cmdlet to display all properties of the session configuration in a list.The output -shows that the **MaxIdleTimeoutMS** property, which establishes the maximum permitted +shows that the **MaxIdleTimeoutMs** property, which establishes the maximum permitted **IdleTimeout** value for sessions that use the session configuration, is `43200000` milliseconds (12 hours). @@ -321,7 +321,7 @@ which is measured in milliseconds. The output confirms that the command was succ Disconnects from sessions with the specified session ID. Type one or more IDs (separated by commas), or use the range operator (`..`) to specify a range of IDs. -To get the ID of a session, use the `Get-PSSession` cmdlet. The instance ID is stored in the **ID** +To get the ID of a session, use the `Get-PSSession` cmdlet. The instance ID is stored in the **Id** property of the session. ```yaml @@ -376,7 +376,7 @@ The instance ID is a GUID that uniquely identifies a session on a local or remot instance ID is unique, even across multiple sessions on multiple computers. To get the instance ID of a session, use the `Get-PSSession` cmdlet. The instance ID is stored in -the **InstanceID** property of the session. +the **InstanceId** property of the session. ```yaml Type: System.Guid[] diff --git a/reference/5.1/Microsoft.PowerShell.Core/Enter-PSSession.md b/reference/5.1/Microsoft.PowerShell.Core/Enter-PSSession.md index e89cb9842e23..27debac72bf3 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/Enter-PSSession.md +++ b/reference/5.1/Microsoft.PowerShell.Core/Enter-PSSession.md @@ -117,20 +117,20 @@ remote computer. When the session starts, the command prompt changes to include The second command gets the PowerShell process and redirects the output to the `Process.txt` file. The command is submitted to the remote computer, and the file is saved on the remote computer. -The third command uses the **Exit** keyword to end the interactive session and close the connection. +The third command uses the `exit` keyword to end the interactive session and close the connection. The fourth command confirms that the Process.txt file is on the remote computer. A `Get-ChildItem` ("dir") command on the local computer cannot find the file. ```powershell PS C:\> Enter-PSSession -ComputerName Server01 [Server01]: PS C:\> -[Server01]: PS C:\> Get-Process PowerShell > C:\ps-test\Process.txt +[Server01]: PS C:\> Get-Process powershell > C:\ps-test\Process.txt [Server01]: PS C:\> exit PS C:\> PS C:\> dir C:\ps-test\Process.txt Get-ChildItem : Cannot find path 'C:\ps-test\Process.txt' because it does not exist. At line:1 char:4 -+ dir <<<< c:\ps-test\Process.txt ++ dir <<<< C:\ps-test\Process.txt ``` This command shows how to work in an interactive session with a remote computer. @@ -169,7 +169,7 @@ This example shows how to start and stop an interactive session. The first comma `Enter-PSSession` cmdlet to start an interactive session with the Server01 computer. The second command uses the `Exit-PSSession` cmdlet to end the session. You can also use the -**Exit** keyword to end the interactive session. `Exit-PSSession` and **Exit** have the same effect. +`exit` keyword to end the interactive session. `Exit-PSSession` and `exit` have the same effect. ## PARAMETERS @@ -484,7 +484,7 @@ Specifies the instance ID of an existing session. `Enter-PSSession` uses the spe the interactive session. The instance ID is a GUID. To find the instance ID of a session, use the `Get-PSSession` cmdlet. You -can also use the **Session**, **Name**, or **ID** parameters to specify an existing session. Or, you +can also use the **Session**, **Name**, or **Id** parameters to specify an existing session. Or, you can use the **ComputerName** parameter to start a temporary session. ```yaml @@ -505,7 +505,7 @@ Specifies the friendly name of an existing session. `Enter-PSSession` uses the s the interactive session. If the name that you specify matches more than one session, the command fails. You can also use the -**Session**, **InstanceID**, or **ID** parameters to specify an existing session. Or, you can use +**Session**, **InstanceId**, or **Id** parameters to specify an existing session. Or, you can use the **ComputerName** parameter to start a temporary session. To establish a friendly name for a session, use the **Name** parameter of the `New-PSSession` @@ -571,7 +571,7 @@ Accept wildcard characters: False ### -Session Specifies a PowerShell session (**PSSession**) to use for the interactive session. This parameter -takes a session object. You can also use the **Name**, **InstanceID**, or **ID** parameters to +takes a session object. You can also use the **Name**, **InstanceId**, or **Id** parameters to specify a **PSSession**. Enter a variable that contains a session object or a command that creates or gets a session object, @@ -579,7 +579,7 @@ such as a `New-PSSession` or `Get-PSSession` command. You can also pipe a sessio `Enter-PSSession`. You can submit only one **PSSession** by using this parameter. If you enter a variable that contains more than one **PSSession**, the command fails. -When you use `Exit-PSSession` or the **EXIT** keyword, the interactive session ends, but the +When you use `Exit-PSSession` or the `exit` keyword, the interactive session ends, but the **PSSession** that you created remains open and available for use. ```yaml diff --git a/reference/5.1/Microsoft.PowerShell.Core/Exit-PSSession.md b/reference/5.1/Microsoft.PowerShell.Core/Exit-PSSession.md index c1a1db3ba86a..079abaa09095 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/Exit-PSSession.md +++ b/reference/5.1/Microsoft.PowerShell.Core/Exit-PSSession.md @@ -69,7 +69,7 @@ The third command uses `Exit-PSSession` to stop the interactive session. The final command displays the **PSSession** in the `$s` variable. The **State** property shows the **PSSession** is still open and available for use. -### Example 3: Use the Exit keyword to stop a session +### Example 3: Use the `exit` keyword to stop a session ```powershell PS C:\> Enter-PSSession -ComputerName Server01 diff --git a/reference/5.1/Microsoft.PowerShell.Core/ForEach-Object.md b/reference/5.1/Microsoft.PowerShell.Core/ForEach-Object.md index b78ebd8d2378..2f302762ca56 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/ForEach-Object.md +++ b/reference/5.1/Microsoft.PowerShell.Core/ForEach-Object.md @@ -46,7 +46,7 @@ command. `Get-Process | ForEach-Object {$_.ProcessName}` `ForEach-Object` supports the `begin`, `process`, and `end` blocks as described in - [about_functions](about/about_functions.md#piping-objects-to-functions). + [about_Functions](about/about_functions.md#piping-objects-to-functions). > [!NOTE] > The script blocks run in the caller's scope. Therefore, the blocks have access to variables in @@ -88,7 +88,7 @@ Get-ChildItem $PSHOME | If the object isn't a directory, the script block gets the name of the file, divides the value of its **Length** property by 1024, and adds a space (" ") to separate it from the next entry. The -cmdlet uses the **PSISContainer** property to determine whether an object is a directory. +cmdlet uses the **PSIsContainer** property to determine whether an object is a directory. ### Example 3: Operate on the most recent System events @@ -163,7 +163,7 @@ the **MemberName** parameter of the `ForEach-Object` cmdlet. ```powershell Get-Module -ListAvailable | ForEach-Object -MemberName Path -Get-Module -ListAvailable | Foreach Path +Get-Module -ListAvailable | foreach Path ``` The second command is equivalent to the first. It uses the `Foreach` alias of the `ForEach-Object` @@ -185,7 +185,7 @@ are equivalent and interchangeable. The output is the same for all three cases. "Microsoft.PowerShell.Core", "Microsoft.PowerShell.Host" | ForEach-Object -MemberName Split -ArgumentList "." "Microsoft.PowerShell.Core", "Microsoft.PowerShell.Host" | - Foreach Split "." + foreach Split "." ``` ```Output @@ -204,7 +204,7 @@ argument. The second command uses the **MemberName** parameter to specify the **Split** method and the **ArgumentList** parameter to identify the dot (`.`) as the split delimiter. -The third command uses the **Foreach** alias of the `ForEach-Object` cmdlet and omits the names of +The third command uses the `foreach` alias of the `ForEach-Object` cmdlet and omits the names of the **MemberName** and **ArgumentList** parameters, which are optional. ### Example 8: Using ForEach-Object with two script blocks @@ -354,7 +354,7 @@ Specifies the name of the member property to get or the member method to call. T instance members, not static members. Wildcard characters are permitted, but work only if the resulting string resolves to a unique value. -For example, if you run `Get-Process | ForEach -MemberName *Name`, the wildcard pattern matches more +For example, if you run `Get-Process | foreach -MemberName *Name`, the wildcard pattern matches more than one member causing the command to fail. This parameter was introduced in Windows PowerShell 3.0. @@ -471,12 +471,12 @@ Windows PowerShell includes the following aliases for `ForEach-Object`: - `%` - `foreach` -The `ForEach-Object` cmdlet works much like the **Foreach** statement, except that you cannot pipe -input to a **Foreach** statement. For more information about the **Foreach** statement, see +The `ForEach-Object` cmdlet works much like the `foreach` statement, except that you cannot pipe +input to a `foreach` statement. For more information about the `foreach` statement, see [about_Foreach](./About/about_Foreach.md). Starting in PowerShell 4.0, `Where` and `ForEach` methods were added for use with collections. You -can read more about these new methods here [about_arrays](./About/about_Arrays.md) +can read more about these new methods here [about_Arrays](./About/about_Arrays.md) ## RELATED LINKS diff --git a/reference/5.1/Microsoft.PowerShell.Core/Get-Command.md b/reference/5.1/Microsoft.PowerShell.Core/Get-Command.md index 0b5f9f6eb1ff..963bd4417042 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/Get-Command.md +++ b/reference/5.1/Microsoft.PowerShell.Core/Get-Command.md @@ -41,7 +41,7 @@ have been imported into the current session, use the **ListImported** parameter. Without parameters, `Get-Command` gets all the cmdlets, functions, and aliases installed on the computer. `Get-Command *` gets all types of commands, including all the non-PowerShell files in the -Path environment variable (`$env:PATH`), which it lists in the Application command type. +PATH environment variable (`$Env:PATH`), which it lists in the Application command type. `Get-Command` that uses the exact name of the command, without wildcard characters, automatically imports the module that contains the command so that you can use the command immediately. To enable, @@ -114,7 +114,7 @@ This command uses the **ArgumentList** and **Syntax** parameters to get the synt the Certificate Provider adds to the session. ```powershell -Get-Command -Name Get-Childitem -Args Cert: -Syntax +Get-Command -Name Get-ChildItem -Args Cert: -Syntax ``` When you compare the syntax displayed in the output with the syntax that's displayed when you omit @@ -154,7 +154,7 @@ cmdlet by another cmdlet or a provider. ### Example 8: Get all commands of all types This command gets all commands of all types on the local computer, including executable files in the -paths of the **Path** environment variable (`$env:PATH`). +paths of the **PATH** environment variable (`$Env:PATH`). ```powershell Get-Command * @@ -262,7 +262,7 @@ code defines the **OutputType** attribute for the cmdlet. ### Example 14: Get cmdlets that take a specific object type as input ```powershell -Get-Command -ParameterType (((Get-NetAdapter)[0]).PSTypeNames) +Get-Command -ParameterType (((Get-NetAdapter)[0]).pstypenames) ``` ```Output @@ -278,11 +278,11 @@ Function Set-NetAdapter NetAdapter This command finds cmdlets that take net adapter objects as input. You can use this command format to find the cmdlets that accept the type of objects that any command returns. -The command uses the **PSTypeNames** intrinsic property of all objects, which gets the types that -describe the object. To get the **PSTypeNames** property of a net adapter, and not the -**PSTypeNames** property of a collection of net adapters, the command uses array notation to get the -first net adapter that the cmdlet returns. To get the **PSTypeNames** property of a net adapter, and -not the **PSTypeNames** property of a collection of net adapters, the command uses array notation to +The command uses the **pstypenames** intrinsic property of all objects, which gets the types that +describe the object. To get the **pstypenames** property of a net adapter, and not the +**pstypenames** property of a collection of net adapters, the command uses array notation to get the +first net adapter that the cmdlet returns. To get the **pstypenames** property of a net adapter, and +not the **pstypenames** property of a collection of net adapters, the command uses array notation to get the first net adapter that the cmdlet returns. ## PARAMETERS @@ -352,15 +352,15 @@ The acceptable values for this parameter are: - `All`: Gets all command types. This parameter value is the equivalent of `Get-Command *`. -- `Application`: Searches folders in the `$env:PATH` environment variable for non-PowerShell +- `Application`: Searches folders in the `$Env:PATH` environment variable for non-PowerShell executable files. On Windows, executable files have a file extension that is listed in the - `$env:PATHEXT` environment variable. For more information, see + `$Env:PATHEXT` environment variable. For more information, see [about_Environment_Variables](About/about_Environment_Variables.md). - `Cmdlet`: Gets all cmdlets. -- `ExternalScript`: Gets all `.ps1` files in the paths listed in the **Path** environment variable - (`$env:PATH`). +- `ExternalScript`: Gets all `.ps1` files in the paths listed in the **PATH** environment variable + (`$Env:PATH`). - `Filter` and `Function`: Gets all PowerShell advanced and simple functions and filters. diff --git a/reference/5.1/Microsoft.PowerShell.Core/Get-Help.md b/reference/5.1/Microsoft.PowerShell.Core/Get-Help.md index 201903171e4e..165245ee5bb5 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/Get-Help.md +++ b/reference/5.1/Microsoft.PowerShell.Core/Get-Help.md @@ -472,7 +472,7 @@ script, or workflow, such as `Get-Member`, a conceptual article name, such as `a alias, such as `ls`. Wildcard characters are permitted in cmdlet and provider names, but you can't use wildcard characters to find the names of function help and script help articles. -To get help for a script that isn't located in a path that's listed in the `$env:Path` environment +To get help for a script that isn't located in a path that's listed in the `$Env:PATH` environment variable, type the script's path and file name. If you enter the exact name of a help article, `Get-Help` displays the article contents. diff --git a/reference/5.1/Microsoft.PowerShell.Core/Get-History.md b/reference/5.1/Microsoft.PowerShell.Core/Get-History.md index 0219e9420438..f0d0a2b9f688 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/Get-History.md +++ b/reference/5.1/Microsoft.PowerShell.Core/Get-History.md @@ -62,7 +62,7 @@ saves it in the History.csv file. The file includes the data that is displayed w history as a list. This includes the status and start and end times of the command. ```powershell -Get-History -ID 7 -Count 5 | Export-Csv -Path History.csv +Get-History -Id 7 -Count 5 | Export-Csv -Path History.csv ``` ### Example 4: Display the most recent command diff --git a/reference/5.1/Microsoft.PowerShell.Core/Get-Job.md b/reference/5.1/Microsoft.PowerShell.Core/Get-Job.md index 50ed27f11f23..f5cf40edfce3 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/Get-Job.md +++ b/reference/5.1/Microsoft.PowerShell.Core/Get-Job.md @@ -95,7 +95,7 @@ Get-Job ```Output Id Name PSJobTypeName State HasMoreData Location Command -- ---- ------------- ----- ----------- -------- ------- -1 Job1 BackgroundJob Completed True localhost $env:COMPUTERNAME +1 Job1 BackgroundJob Completed True localhost $Env:COMPUTERNAME ``` ### Example 2: Stop a job by using an instance ID @@ -113,7 +113,7 @@ instance ID of the job. ```powershell $j = Get-Job -Name Job1 -$ID = $j.InstanceID +$ID = $j.InstanceId $ID ``` @@ -179,7 +179,7 @@ Get-Job -Name Job* ```Output Id Name PSJobTypeName State HasMoreData Location Command -- ---- ------------- ----- ----------- -------- ------- -1 Job1 BackgroundJob Completed True localhost $env:COMPUTERNAME +1 Job1 BackgroundJob Completed True localhost $Env:COMPUTERNAME ``` ### Example 7: Use a job object to represent the job in a command @@ -316,7 +316,7 @@ PS> Get-Job | Format-List -Property * HasMoreData : False StatusMessage : Location : localhost -Command : get-process +Command : Get-Process JobStateInfo : Failed Finished : System.Threading.ManualReset EventInstanceId : fb792295-1318-4f5d-8ac8-8a89c5261507 @@ -331,7 +331,7 @@ Debug : {} Warning : {} StateChanged : -PS> (Get-Job -Name job2).JobStateInfo.Reason +PS> (Get-Job -Name Job2).JobStateInfo.Reason Connecting to remote server using WSManCreateShellEx api failed. The async callback gave the following error message: Access is denied. ``` @@ -342,7 +342,7 @@ This example shows how to use the **Filter** parameter to get a workflow job. Th parameter, introduced in Windows PowerShell 3.0 is valid only on custom job types, such as workflow jobs and scheduled jobs. -The first command uses the **Workflow** keyword to create the WFProcess workflow. The second command +The first command uses the `workflow` keyword to create the WFProcess workflow. The second command uses the **AsJob** parameter of the WFProcess workflow to run the workflow as a background job. It uses the **JobName** parameter of the workflow to specify a name for the job, and the **PSPrivateMetadata** parameter of the workflow to specify a custom ID. The third command uses the @@ -350,7 +350,7 @@ uses the **JobName** parameter of the workflow to specify a name for the job, an **PSPrivateMetadata** parameter. ```powershell -PS> Workflow WFProcess {Get-Process} +PS> workflow WFProcess {Get-Process} PS> WFProcess -AsJob -JobName WFProcessJob -PSPrivateMetadata @{MyCustomId = 92107} PS> Get-Job -Filter @{MyCustomId = 92107} Id Name State HasMoreData Location Command diff --git a/reference/5.1/Microsoft.PowerShell.Core/Get-Module.md b/reference/5.1/Microsoft.PowerShell.Core/Get-Module.md index 16c491264705..c2145e2c5806 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/Get-Module.md +++ b/reference/5.1/Microsoft.PowerShell.Core/Get-Module.md @@ -48,7 +48,7 @@ The `Get-Module` cmdlet lists the PowerShell modules that have been imported, or imported, into a PowerShell session. Without parameters, `Get-Module` gets modules that have been imported into the current session. The **ListAvailable** parameter is used to list the modules that are available to be imported from the paths specified in the **PSModulePath** environment variable -(`$env:PSModulePath`). +(`$Env:PSModulePath`). The module object that `Get-Module` returns contains valuable information about the module. You can also pipe the module objects to other cmdlets, such as the `Import-Module` and `Remove-Module` @@ -80,7 +80,7 @@ These include computers that are not running the Windows operating system, and c PowerShell but do not have PowerShell remoting enabled. Start by creating a CIM session on the remote computer. A CIM session is a connection to Windows -Management Instrumentation (WMI) on the remote computer. Then use the **CIMSession** parameter of +Management Instrumentation (WMI) on the remote computer. Then use the **CimSession** parameter of `Get-Module` to get CIM modules from the CIM session. When you import a CIM module by using the `Import-Module` cmdlet and then run the imported commands, the commands run implicitly on the remote computer. You can use this WMI and CIM strategy to manage the remote computer. @@ -104,7 +104,7 @@ Get-Module -ListAvailable This command gets the modules that are installed on the computer and can be imported into the current session. -`Get-Module` looks for available modules in the path specified by the **$env:PSModulePath** +`Get-Module` looks for available modules in the path specified by the **$Env:PSModulePath** environment variable. For more information about **PSModulePath**, see [about_Modules](About/about_Modules.md) and [about_Environment_Variables](About/about_Environment_Variables.md). @@ -200,7 +200,7 @@ in Windows PowerShell 3.0. ### Example 6: Group all modules by name ```powershell -Get-Module -ListAvailable -All | Format-Table -Property Name, Moduletype, Path -Groupby Name +Get-Module -ListAvailable -All | Format-Table -Property Name, ModuleType, Path -GroupBy Name ``` ```Output @@ -248,7 +248,7 @@ information about a module, its requirements, and its contents. ```powershell # First command -$m = Get-Module -list -Name BitsTransfer +$m = Get-Module -List -Name BitsTransfer # Second command Get-Content $m.Path @@ -661,7 +661,7 @@ Windows PowerShell includes the following aliases for `Get-Module`: [CreateDefault2 Method](/dotnet/api/system.management.automation.runspaces.initialsessionstate.createdefault2). - `Get-Module` only gets modules in locations that are stored in the value of the **PSModulePath** - environment variable (`$env:PSModulePath`). The `Import-Module` cmdlet can import modules in other + environment variable (`$Env:PSModulePath`). The `Import-Module` cmdlet can import modules in other locations, but you cannot use the `Get-Module` cmdlet to get them. - Also, starting in PowerShell 3.0, new properties have been added to the object that `Get-Module` diff --git a/reference/5.1/Microsoft.PowerShell.Core/Get-PSSession.md b/reference/5.1/Microsoft.PowerShell.Core/Get-PSSession.md index d165a931c016..0cbff9815835 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/Get-PSSession.md +++ b/reference/5.1/Microsoft.PowerShell.Core/Get-PSSession.md @@ -120,7 +120,7 @@ created in the current session. Without parameters, `Get-PSSession` gets all sessions that were created in the current session. -Use the filtering parameters, including **Name**, **ID**, **InstanceID**, **State**, +Use the filtering parameters, including **Name**, **Id**, **InstanceId**, **State**, **ApplicationName**, and **ConfigurationName** to select from among the sessions that `Get-PSSession` returns. @@ -204,8 +204,8 @@ more variables than objects, the extra variables are not used. ### Example 5: Delete a session by using an instance ID ```powershell -Get-PSSession | Format-Table -Property ComputerName, InstanceID -$s = Get-PSSession -InstanceID a786be29-a6bb-40da-80fb-782c67f7db0f +Get-PSSession | Format-Table -Property ComputerName, InstanceId +$s = Get-PSSession -InstanceId a786be29-a6bb-40da-80fb-782c67f7db0f Remove-PSSession -Session $s ``` @@ -214,10 +214,10 @@ This example shows how to get a **PSSession** by using its instance ID, and then The first command gets all of the **PSSessions** that were created in the current session. It sends the **PSSessions** to the `Format-Table` cmdlet, which displays the **ComputerName** and -**InstanceID** properties of each **PSSession**. +**InstanceId** properties of each **PSSession**. The second command uses the `Get-PSSession` cmdlet to get a particular **PSSession** and to save it -in the `$s` variable. The command uses the **InstanceID** parameter to identify the **PSSession**. +in the `$s` variable. The command uses the **InstanceId** parameter to identify the **PSSession**. The third command uses the Remove-PSSession cmdlet to delete the **PSSession** in the `$s` variable. @@ -272,7 +272,7 @@ for use. Get-PSSession -Id 2 ``` -This command gets the **PSSession** with ID `2`. Because the value of the **ID** property is unique +This command gets the **PSSession** with ID `2`. Because the value of the **Id** property is unique only in the current session, the **Id** parameter is valid only for local commands. ## PARAMETERS @@ -551,11 +551,11 @@ Accept wildcard characters: False Specifies an array of session IDs. This cmdlet gets only the sessions with the specified IDs. Type one or more IDs, separated by commas, or use the range operator (`..`) to specify a range of IDs. -You cannot use the ID parameter together with the **ComputerName** parameter. +You cannot use the **Id** parameter together with the **ComputerName** parameter. An ID is an integer that uniquely identifies the user-managed sessions in the current session. It is easier to remember and type than the **InstanceId**, but it is unique only within the current -session. The ID of a session is stored in the **ID** property of the session. +session. The ID of a session is stored in the **Id** property of the session. ```yaml Type: System.Int32[] @@ -575,9 +575,9 @@ Specifies an array of instance IDs of sessions. This cmdlet gets only the sessio specified instance IDs. The instance ID is a GUID that uniquely identifies a session on a local or remote computer. The -**InstanceID** is unique, even when you have multiple sessions running in PowerShell. +**InstanceId** is unique, even when you have multiple sessions running in PowerShell. -The instance ID of a session is stored in the **InstanceID** property of the session. +The instance ID of a session is stored in the **InstanceId** property of the session. ```yaml Type: System.Guid[] @@ -818,7 +818,7 @@ Windows PowerShell includes the following aliases for `Get-PSSession`: computer and runs query commands in the session. - To get sessions that connect to a remote computer, use the **ComputerName** or **ConnectionUri** parameters to specify the remote computer. To filter the sessions that `Get-PSSession` gets, use - the **Name**, **ID**, **InstanceID**, and **State** parameters. Use the remaining parameters to + the **Name**, **Id**, **InstanceId**, and **State** parameters. Use the remaining parameters to configure the temporary session that `Get-PSSession` uses. - When you use the **ComputerName** or **ConnectionUri** parameters, `Get-PSSession` gets only sessions from computers running Windows PowerShell 3.0 and later versions of PowerShell. diff --git a/reference/7.4/Microsoft.PowerShell.Core/Disconnect-PSSession.md b/reference/7.4/Microsoft.PowerShell.Core/Disconnect-PSSession.md index 7c8b1679ed2a..681b6787af1a 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/Disconnect-PSSession.md +++ b/reference/7.4/Microsoft.PowerShell.Core/Disconnect-PSSession.md @@ -223,7 +223,7 @@ OutputBufferingMode : Block AutoRestart : false SecurityDescriptorSddl : O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD) MaxMemoryPerShellMB : 1024 -MaxIdleTimeoutms : 2147483647 +MaxIdleTimeoutMs : 2147483647 Uri : http://schemas.microsoft.com/powershell/microsoft.powershell SDKVersion : 2 Name : microsoft.powershell @@ -298,7 +298,7 @@ violation can go undetected while the session is in use. The fourth command uses the `Invoke-Command` cmdlet to run a `Get-PSSessionConfiguration` command for the `Microsoft.PowerShell` session configuration on the Server01 computer. The command uses the `Format-List` cmdlet to display all properties of the session configuration in a list.The output -shows that the **MaxIdleTimeoutMS** property, which establishes the maximum permitted +shows that the **MaxIdleTimeoutMs** property, which establishes the maximum permitted **IdleTimeout** value for sessions that use the session configuration, is `43200000` milliseconds (12 hours). @@ -323,7 +323,7 @@ which is measured in milliseconds. The output confirms that the command was succ Disconnects from sessions with the specified session ID. Type one or more IDs (separated by commas), or use the range operator (`..`) to specify a range of IDs. -To get the ID of a session, use the `Get-PSSession` cmdlet. The instance ID is stored in the **ID** +To get the ID of a session, use the `Get-PSSession` cmdlet. The instance ID is stored in the **Id** property of the session. ```yaml @@ -378,7 +378,7 @@ The instance ID is a GUID that uniquely identifies a session on a local or remot instance ID is unique, even across multiple sessions on multiple computers. To get the instance ID of a session, use the `Get-PSSession` cmdlet. The instance ID is stored in -the **InstanceID** property of the session. +the **InstanceId** property of the session. ```yaml Type: System.Guid[] diff --git a/reference/7.4/Microsoft.PowerShell.Core/Enter-PSSession.md b/reference/7.4/Microsoft.PowerShell.Core/Enter-PSSession.md index c2ed05a744c1..8b6407c19c24 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/Enter-PSSession.md +++ b/reference/7.4/Microsoft.PowerShell.Core/Enter-PSSession.md @@ -134,20 +134,20 @@ remote computer. When the session starts, the command prompt changes to include The second command gets the PowerShell process and redirects the output to the `Process.txt` file. The command is submitted to the remote computer, and the file is saved on the remote computer. -The third command uses the **Exit** keyword to end the interactive session and close the connection. +The third command uses the `exit` keyword to end the interactive session and close the connection. The fourth command confirms that the Process.txt file is on the remote computer. A `Get-ChildItem` ("dir") command on the local computer can't find the file. ```powershell PS C:\> Enter-PSSession -ComputerName Server01 [Server01]: PS C:\> -[Server01]: PS C:\> Get-Process PowerShell > C:\ps-test\Process.txt +[Server01]: PS C:\> Get-Process powershell > C:\ps-test\Process.txt [Server01]: PS C:\> exit PS C:\> PS C:\> dir C:\ps-test\Process.txt Get-ChildItem : Cannot find path 'C:\ps-test\Process.txt' because it does not exist. At line:1 char:4 -+ dir <<<< c:\ps-test\Process.txt ++ dir <<<< C:\ps-test\Process.txt ``` This command shows how to work in an interactive session with a remote computer. @@ -186,7 +186,7 @@ This example shows how to start and stop an interactive session. The first comma `Enter-PSSession` cmdlet to start an interactive session with the Server01 computer. The second command uses the `Exit-PSSession` cmdlet to end the session. You can also use the -**Exit** keyword to end the interactive session. `Exit-PSSession` and **Exit** have the same effect. +`exit` keyword to end the interactive session. `Exit-PSSession` and `exit` have the same effect. ### Example 6: Start an interactive session using SSH @@ -201,7 +201,7 @@ Otherwise, you must use key-based user authentication. ### Example 7: Start an interactive session using SSH with a port and user authentication key ```powershell -PS> Enter-PSSession -HostName UserA@LinuxServer02:22 -KeyFilePath c:\sshkeys\userAKey_rsa +PS> Enter-PSSession -HostName UserA@LinuxServer02:22 -KeyFilePath C:\sshkeys\userAKey_rsa ``` This example shows how to start an interactive session using SSH. The username and SSH port number @@ -216,7 +216,7 @@ $options = @{ User = 'UserA' Host = 'LinuxServer02' } -Enter-PSSession -KeyFilePath c:\sshkeys\userAKey_rsa -Options $options +Enter-PSSession -KeyFilePath C:\sshkeys\userAKey_rsa -Options $options ``` This example shows how to start an interactive session using SSH. The **Options** parameter takes a @@ -538,7 +538,7 @@ Accept wildcard characters: False Specifies a computer name for a Secure Shell (SSH) based connection. This is similar to the **ComputerName** parameter except that the connection to the remote computer is made using SSH rather than Windows WinRM. This parameter supports specifying the user name and/or port as part of -the host name parameter value using the form `user@hostname:port`. The user name and/or port +the **HostName** parameter value using the form `user@hostname:port`. The user name and/or port specified as part of the host name takes precedence over the `-UserName` and `-Port` parameters, if specified. This allows passing multiple computer names to this parameter where some have specific user names and/or ports, while others use the user name and/or port from the `-UserName` and `-Port` @@ -583,7 +583,7 @@ Specifies the instance ID of an existing session. `Enter-PSSession` uses the spe the interactive session. The instance ID is a GUID. To find the instance ID of a session, use the `Get-PSSession` cmdlet. You -can also use the **Session**, **Name**, or **ID** parameters to specify an existing session. Or, you +can also use the **Session**, **Name**, or **Id** parameters to specify an existing session. Or, you can use the **ComputerName** parameter to start a temporary session. ```yaml @@ -626,7 +626,7 @@ Specifies the friendly name of an existing session. `Enter-PSSession` uses the s the interactive session. If the name that you specify matches more than one session, the command fails. You can also use the -**Session**, **InstanceID**, or **ID** parameters to specify an existing session. Or, you can use +**Session**, **InstanceId**, or **Id** parameters to specify an existing session. Or, you can use the **ComputerName** parameter to start a temporary session. To establish a friendly name for a session, use the **Name** parameter of the `New-PSSession` @@ -725,7 +725,7 @@ Accept wildcard characters: False ### -Session Specifies a PowerShell session (**PSSession**) to use for the interactive session. This parameter -takes a session object. You can also use the **Name**, **InstanceID**, or **ID** parameters to +takes a session object. You can also use the **Name**, **InstanceId**, or **Id** parameters to specify a **PSSession**. Enter a variable that contains a session object or a command that creates or gets a session object, @@ -733,7 +733,7 @@ such as a `New-PSSession` or `Get-PSSession` command. You can also pipe a sessio `Enter-PSSession`. You can submit only one **PSSession** by using this parameter. If you enter a variable that contains more than one **PSSession**, the command fails. -When you use `Exit-PSSession` or the **EXIT** keyword, the interactive session ends, but the +When you use `Exit-PSSession` or the `exit` keyword, the interactive session ends, but the **PSSession** that you created remains open and available for use. ```yaml diff --git a/reference/7.4/Microsoft.PowerShell.Core/Exit-PSSession.md b/reference/7.4/Microsoft.PowerShell.Core/Exit-PSSession.md index e66fc1d1756f..0dc674370ea4 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/Exit-PSSession.md +++ b/reference/7.4/Microsoft.PowerShell.Core/Exit-PSSession.md @@ -69,7 +69,7 @@ The third command uses `Exit-PSSession` to stop the interactive session. The final command displays the **PSSession** in the `$s` variable. The **State** property shows the **PSSession** is still open and available for use. -### Example 3: Use the Exit keyword to stop a session +### Example 3: Use the `exit` keyword to stop a session ```powershell PS> Enter-PSSession -ComputerName Server01 diff --git a/reference/7.4/Microsoft.PowerShell.Core/ForEach-Object.md b/reference/7.4/Microsoft.PowerShell.Core/ForEach-Object.md index 7784e209f403..4a1202ae5163 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/ForEach-Object.md +++ b/reference/7.4/Microsoft.PowerShell.Core/ForEach-Object.md @@ -55,7 +55,7 @@ command. `Get-Process | ForEach-Object {$_.ProcessName}` `ForEach-Object` supports the `begin`, `process`, and `end` blocks as described in - [about_functions](about/about_functions.md#piping-objects-to-functions). + [about_Functions](about/about_functions.md#piping-objects-to-functions). > [!NOTE] > The script blocks run in the caller's scope. Therefore, the blocks have access to variables in @@ -73,8 +73,8 @@ command. - **Parallel running script block**. Beginning with PowerShell 7.0, a third parameter set is available that runs each script block in parallel. The **ThrottleLimit** parameter limits the number of parallel scripts running at a time. As before, use the `$_` variable to represent the - current input object in the script block. Use the `$using:` keyword to pass variable references to - the running script. + current input object in the script block. Use the `Using:` scope modifier to pass variable + references to the running script. In PowerShell 7, a new runspace is created for each loop iteration to ensure maximum isolation. This can be a large performance and resource hit if the work you are doing is small compared to @@ -115,7 +115,7 @@ Get-ChildItem $PSHOME | If the object isn't a directory, the script block gets the name of the file, divides the value of its **Length** property by 1024, and adds a space (" ") to separate it from the next entry. The -cmdlet uses the **PSISContainer** property to determine whether an object is a directory. +cmdlet uses the **PSIsContainer** property to determine whether an object is a directory. ### Example 3: Operate on the most recent System events @@ -190,7 +190,7 @@ the **MemberName** parameter of the `ForEach-Object` cmdlet. ```powershell Get-Module -ListAvailable | ForEach-Object -MemberName Path -Get-Module -ListAvailable | Foreach Path +Get-Module -ListAvailable | foreach Path ``` The second command is equivalent to the first. It uses the `Foreach` alias of the `ForEach-Object` @@ -212,7 +212,7 @@ are equivalent and interchangeable. The output is the same for all three cases. "Microsoft.PowerShell.Core", "Microsoft.PowerShell.Host" | ForEach-Object -MemberName Split -ArgumentList "." "Microsoft.PowerShell.Core", "Microsoft.PowerShell.Host" | - Foreach Split "." + foreach Split "." ``` ```Output @@ -231,7 +231,7 @@ argument. The second command uses the **MemberName** parameter to specify the **Split** method and the **ArgumentList** parameter to identify the dot (`.`) as the split delimiter. -The third command uses the **Foreach** alias of the `ForEach-Object` cmdlet and omits the names of +The third command uses the `foreach` alias of the `ForEach-Object` cmdlet and omits the names of the **MemberName** and **ArgumentList** parameters, which are optional. ### Example 8: Using ForEach-Object with two script blocks @@ -300,7 +300,7 @@ This example runs a script block that evaluates a string and sleeps for one seco $Message = "Output:" 1..8 | ForEach-Object -Parallel { - "$using:Message $_" + "$Using:Message $_" Start-Sleep 1 } -ThrottleLimit 4 ``` @@ -317,7 +317,7 @@ Output: 8 ``` The **ThrottleLimit** parameter value is set to 4 so that the input is processed in batches of four. -The `$using:` keyword is used to pass the `$Message` variable into each parallel script block. +The `Using:` scope modifier is used to pass the `$Message` variable into each parallel script block. ### Example 12: Retrieve log entries in parallel @@ -386,7 +386,7 @@ This example invokes script blocks in parallel to collect uniquely named Process ```powershell $threadSafeDictionary = [System.Collections.Concurrent.ConcurrentDictionary[string,object]]::new() Get-Process | ForEach-Object -Parallel { - $dict = $using:threadSafeDictionary + $dict = $Using:threadSafeDictionary $dict.TryAdd($_.ProcessName, $_) } @@ -453,17 +453,17 @@ Output: 5 > [!NOTE] > [PipelineVariable](About/about_CommonParameters.md) common parameter variables are _not_ -> supported in `Foreach-Object -Parallel` scenarios even with the `$using:` keyword. +> supported in `ForEach-Object -Parallel` scenarios even with the `Using:` scope modifier. ### Example 17: Passing variables in nested parallel script ScriptBlockSet -You can create a variable outside a `Foreach-Object -Parallel` scoped scriptblock and use -it inside the scriptblock with the `$using` keyword. +You can create a variable outside a `ForEach-Object -Parallel` scoped scriptblock and use +it inside the scriptblock with the `Using:` scope modifier. ```powershell $test1 = 'TestA' -1..2 | Foreach-Object -Parallel { - $using:test1 +1..2 | ForEach-Object -Parallel { + $Using:test1 } ``` @@ -476,20 +476,20 @@ TestA # You CANNOT create a variable inside a scoped scriptblock # to be used in a nested foreach parallel scriptblock. $test1 = 'TestA' -1..2 | Foreach-Object -Parallel { - $using:test1 +1..2 | ForEach-Object -Parallel { + $Using:test1 $test2 = 'TestB' - 1..2 | Foreach-Object -Parallel { - $using:test2 + 1..2 | ForEach-Object -Parallel { + $Using:test2 } } ``` ```Output Line | - 2 | 1..2 | Foreach-Object -Parallel { + 2 | 1..2 | ForEach-Object -Parallel { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ - | The value of the using variable '$using:test2' can't be retrieved because it has + | The value of the using variable '$Using:test2' can't be retrieved because it has | not been set in the local session. ``` @@ -626,7 +626,7 @@ Specifies the name of the member property to get or the member method to call. T instance members, not static members. Wildcard characters are permitted, but work only if the resulting string resolves to a unique value. -For example, if you run `Get-Process | ForEach -MemberName *Name`, the wildcard pattern matches more +For example, if you run `Get-Process | foreach -MemberName *Name`, the wildcard pattern matches more than one member causing the command to fail. This parameter was introduced in Windows PowerShell 3.0. @@ -828,12 +828,12 @@ PowerShell includes the following aliases for `ForEach-Object`: - `%` - `foreach` -The `ForEach-Object` cmdlet works much like the **Foreach** statement, except that you can't pipe -input to a **Foreach** statement. For more information about the **Foreach** statement, see +The `ForEach-Object` cmdlet works much like the `foreach` statement, except that you can't pipe +input to a `foreach` statement. For more information about the `foreach` statement, see [about_Foreach](./About/about_Foreach.md). Starting in PowerShell 4.0, `Where` and `ForEach` methods were added for use with collections. You -can read more about these new methods here [about_arrays](./About/about_Arrays.md) +can read more about these new methods here [about_Arrays](./About/about_Arrays.md) Using `ForEach-Object -Parallel`: @@ -869,18 +869,18 @@ Using `ForEach-Object -Parallel`: Terminating errors, such as exceptions, terminate the individual parallel instance of the scriptblocks in which they occur. A terminating error in one scriptblocks may not cause the - termination of the `Foreach-Object` cmdlet. The other scriptblocks, running in parallel, continue + termination of the `ForEach-Object` cmdlet. The other scriptblocks, running in parallel, continue to run unless they also encounter a terminating error. The terminating error is written to the error data stream as an **ErrorRecord** with a **FullyQualifiedErrorId** of `PSTaskException`. Terminating errors can be converted to non-terminating errors using PowerShell `try`/`catch` or `trap` blocks. - [PipelineVariable](About/about_CommonParameters.md) common parameter variables are _not_ supported - in parallel scenarios even with the `$using:` keyword. + in parallel scenarios even with the `Using:` scope modifier. > [!IMPORTANT] > The `ForEach-Object -Parallel` parameter set runs script blocks in parallel on separate process - > threads. The `$using:` keyword allows passing variable references from the cmdlet invocation + > threads. The `Using:` modifier allows passing variable references from the cmdlet invocation > thread to each running script block thread. Since the script blocks run in different threads, > the object variables passed by reference must be used safely. Generally it's safe to read from > referenced objects that don't change. If you need to modify the object state then you must diff --git a/reference/7.4/Microsoft.PowerShell.Core/Get-Command.md b/reference/7.4/Microsoft.PowerShell.Core/Get-Command.md index 1ee0f3b0ff4e..576c90714c89 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/Get-Command.md +++ b/reference/7.4/Microsoft.PowerShell.Core/Get-Command.md @@ -42,7 +42,7 @@ have been imported into the current session, use the **ListImported** parameter. Without parameters, `Get-Command` gets all the cmdlets, functions, and aliases installed on the computer. `Get-Command *` gets all types of commands, including all the non-PowerShell files in the -Path environment variable (`$env:PATH`), which it lists in the Application command type. +PATH environment variable (`$Env:PATH`), which it lists in the Application command type. `Get-Command` that uses the exact name of the command, without wildcard characters, automatically imports the module that contains the command so that you can use the command immediately. To enable, @@ -115,7 +115,7 @@ This command uses the **ArgumentList** and **Syntax** parameters to get the synt the Certificate Provider adds to the session. ```powershell -Get-Command -Name Get-Childitem -Args Cert: -Syntax +Get-Command -Name Get-ChildItem -Args Cert: -Syntax ``` When you compare the syntax displayed in the output with the syntax that's displayed when you omit @@ -155,7 +155,7 @@ cmdlet by another cmdlet or a provider. ### Example 8: Get all commands of all types This command gets all commands of all types on the local computer, including executable files in the -paths of the **Path** environment variable (`$env:PATH`). +paths of the **PATH** environment variable (`$Env:PATH`). ```powershell Get-Command * @@ -285,7 +285,7 @@ code defines the **OutputType** attribute for the cmdlet. ### Example 15: Get cmdlets that take a specific object type as input ```powershell -Get-Command -ParameterType (((Get-NetAdapter)[0]).PSTypeNames) +Get-Command -ParameterType (((Get-NetAdapter)[0]).pstypenames) ``` ```Output @@ -301,9 +301,9 @@ Function Set-NetAdapter NetAdapter This command finds cmdlets that take net adapter objects as input. You can use this command format to find the cmdlets that accept the type of objects that any command returns. -The command uses the **PSTypeNames** intrinsic property of all objects, which gets the types that -describe the object. To get the **PSTypeNames** property of a net adapter, and not the -**PSTypeNames** property of a collection of net adapters, the command uses array notation to get the +The command uses the **pstypenames** intrinsic property of all objects, which gets the types that +describe the object. To get the **pstypenames** property of a net adapter, and not the +**pstypenames** property of a collection of net adapters, the command uses array notation to get the first net adapter that the cmdlet returns. ### Example 16: Get commands using a fuzzy match @@ -391,15 +391,15 @@ The acceptable values for this parameter are: - `All`: Gets all command types. This parameter value is the equivalent of `Get-Command *`. -- `Application`: Searches folders in the `$env:PATH` environment variable for non-PowerShell +- `Application`: Searches folders in the `$Env:PATH` environment variable for non-PowerShell executable files. On Windows, executable files have a file extension that is listed in the - `$env:PATHEXT` environment variable. For more information, see + `$Env:PATHEXT` environment variable. For more information, see [about_Environment_Variables](About/about_Environment_Variables.md). - `Cmdlet`: Gets all cmdlets. -- `ExternalScript`: Gets all `.ps1` files in the paths listed in the **Path** environment variable - (`$env:PATH`). +- `ExternalScript`: Gets all `.ps1` files in the paths listed in the **PATH** environment variable + (`$Env:PATH`). - `Filter` and `Function`: Gets all PowerShell advanced and simple functions and filters. diff --git a/reference/7.4/Microsoft.PowerShell.Core/Get-Help.md b/reference/7.4/Microsoft.PowerShell.Core/Get-Help.md index 4ca1309bdb62..a3703637c601 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/Get-Help.md +++ b/reference/7.4/Microsoft.PowerShell.Core/Get-Help.md @@ -472,7 +472,7 @@ script, or workflow, such as `Get-Member`, a conceptual article name, such as `a alias, such as `ls`. Wildcard characters are permitted in cmdlet and provider names, but you can't use wildcard characters to find the names of function help and script help articles. -To get help for a script that isn't located in a path that's listed in the `$env:Path` environment +To get help for a script that isn't located in a path that's listed in the `$Env:PATH` environment variable, type the script's path and file name. If you enter the exact name of a help article, `Get-Help` displays the article contents. diff --git a/reference/7.4/Microsoft.PowerShell.Core/Get-History.md b/reference/7.4/Microsoft.PowerShell.Core/Get-History.md index 3fdcbbd5c5aa..98083a9c1f4a 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/Get-History.md +++ b/reference/7.4/Microsoft.PowerShell.Core/Get-History.md @@ -62,7 +62,7 @@ saves it in the History.csv file. The file includes the data that is displayed w history as a list. This includes the status and start and end times of the command. ```powershell -Get-History -ID 7 -Count 5 | Export-Csv -Path History.csv +Get-History -Id 7 -Count 5 | Export-Csv -Path History.csv ``` ### Example 4: Display the most recent command diff --git a/reference/7.4/Microsoft.PowerShell.Core/Get-Job.md b/reference/7.4/Microsoft.PowerShell.Core/Get-Job.md index 0d55db57dcf9..93a7c49ce559 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/Get-Job.md +++ b/reference/7.4/Microsoft.PowerShell.Core/Get-Job.md @@ -95,7 +95,7 @@ Get-Job ```Output Id Name PSJobTypeName State HasMoreData Location Command -- ---- ------------- ----- ----------- -------- ------- -1 Job1 BackgroundJob Completed True localhost $env:COMPUTERNAME +1 Job1 BackgroundJob Completed True localhost $Env:COMPUTERNAME ``` ### Example 2: Stop a job by using an instance ID @@ -113,7 +113,7 @@ instance ID of the job. ```powershell $j = Get-Job -Name Job1 -$ID = $j.InstanceID +$ID = $j.InstanceId $ID ``` @@ -179,7 +179,7 @@ Get-Job -Name Job* ```Output Id Name PSJobTypeName State HasMoreData Location Command -- ---- ------------- ----- ----------- -------- ------- -1 Job1 BackgroundJob Completed True localhost $env:COMPUTERNAME +1 Job1 BackgroundJob Completed True localhost $Env:COMPUTERNAME ``` ### Example 7: Use a job object to represent the job in a command @@ -316,7 +316,7 @@ PS> Get-Job | Format-List -Property * HasMoreData : False StatusMessage : Location : localhost -Command : get-process +Command : Get-Process JobStateInfo : Failed Finished : System.Threading.ManualReset EventInstanceId : fb792295-1318-4f5d-8ac8-8a89c5261507 @@ -331,7 +331,7 @@ Debug : {} Warning : {} StateChanged : -PS> (Get-Job -Name job2).JobStateInfo.Reason +PS> (Get-Job -Name Job2).JobStateInfo.Reason Connecting to remote server using WSManCreateShellEx api failed. The async callback gave the following error message: Access is denied. ``` @@ -342,7 +342,7 @@ This example shows how to use the **Filter** parameter to get a workflow job. Th parameter, introduced in Windows PowerShell 3.0 is valid only on custom job types, such as workflow jobs and scheduled jobs. -The first command uses the **Workflow** keyword to create the WFProcess workflow. The second command +The first command uses the `workflow` keyword to create the WFProcess workflow. The second command uses the **AsJob** parameter of the WFProcess workflow to run the workflow as a background job. It uses the **JobName** parameter of the workflow to specify a name for the job, and the **PSPrivateMetadata** parameter of the workflow to specify a custom ID. The third command uses the @@ -350,7 +350,7 @@ uses the **JobName** parameter of the workflow to specify a name for the job, an **PSPrivateMetadata** parameter. ```powershell -PS> Workflow WFProcess {Get-Process} +PS> workflow WFProcess {Get-Process} PS> WFProcess -AsJob -JobName WFProcessJob -PSPrivateMetadata @{MyCustomId = 92107} PS> Get-Job -Filter @{MyCustomId = 92107} Id Name State HasMoreData Location Command diff --git a/reference/7.4/Microsoft.PowerShell.Core/Get-Module.md b/reference/7.4/Microsoft.PowerShell.Core/Get-Module.md index ddce290ee0fe..3bb44ce89e40 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/Get-Module.md +++ b/reference/7.4/Microsoft.PowerShell.Core/Get-Module.md @@ -49,7 +49,7 @@ The `Get-Module` cmdlet lists the PowerShell modules that have been imported, or imported, into a PowerShell session. Without parameters, `Get-Module` gets modules that have been imported into the current session. The **ListAvailable** parameter is used to list the modules that are available to be imported from the paths specified in the **PSModulePath** environment variable -(`$env:PSModulePath`). +(`$Env:PSModulePath`). The module object that `Get-Module` returns contains valuable information about the module. You can also pipe the module objects to other cmdlets, such as the `Import-Module` and `Remove-Module` @@ -81,7 +81,7 @@ These include computers that are not running the Windows operating system, and c PowerShell but do not have PowerShell remoting enabled. Start by creating a CIM session on the remote computer. A CIM session is a connection to Windows -Management Instrumentation (WMI) on the remote computer. Then use the **CIMSession** parameter of +Management Instrumentation (WMI) on the remote computer. Then use the **CimSession** parameter of `Get-Module` to get CIM modules from the CIM session. When you import a CIM module by using the `Import-Module` cmdlet and then run the imported commands, the commands run implicitly on the remote computer. You can use this WMI and CIM strategy to manage the remote computer. @@ -105,7 +105,7 @@ Get-Module -ListAvailable This command gets the modules that are installed on the computer and can be imported into the current session. -`Get-Module` looks for available modules in the path specified by the **$env:PSModulePath** +`Get-Module` looks for available modules in the path specified by the **$Env:PSModulePath** environment variable. For more information about **PSModulePath**, see [about_Modules](About/about_Modules.md) and [about_Environment_Variables](About/about_Environment_Variables.md). @@ -201,7 +201,7 @@ in Windows PowerShell 3.0. ### Example 6: Group all modules by name ```powershell -Get-Module -ListAvailable -All | Format-Table -Property Name, Moduletype, Path -Groupby Name +Get-Module -ListAvailable -All | Format-Table -Property Name, ModuleType, Path -GroupBy Name ``` ```Output @@ -249,7 +249,7 @@ information about a module, its requirements, and its contents. ```powershell # First command -$m = Get-Module -list -Name BitsTransfer +$m = Get-Module -List -Name BitsTransfer # Second command Get-Content $m.Path @@ -688,7 +688,7 @@ PowerShell includes the following aliases for `Get-Module`: [CreateDefault2 Method](/dotnet/api/system.management.automation.runspaces.initialsessionstate.createdefault2). - `Get-Module` only gets modules in locations that are stored in the value of the **PSModulePath** - environment variable (`$env:PSModulePath`). The `Import-Module` cmdlet can import modules in other + environment variable (`$Env:PSModulePath`). The `Import-Module` cmdlet can import modules in other locations, but you cannot use the `Get-Module` cmdlet to get them. - Also, starting in PowerShell 3.0, new properties have been added to the object that `Get-Module` diff --git a/reference/7.4/Microsoft.PowerShell.Core/Get-PSSession.md b/reference/7.4/Microsoft.PowerShell.Core/Get-PSSession.md index 583ad83611c8..9091e007c22c 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/Get-PSSession.md +++ b/reference/7.4/Microsoft.PowerShell.Core/Get-PSSession.md @@ -120,7 +120,7 @@ created in the current session. Without parameters, `Get-PSSession` gets all sessions that were created in the current session. -Use the filtering parameters, including **Name**, **ID**, **InstanceID**, **State**, +Use the filtering parameters, including **Name**, **Id**, **InstanceId**, **State**, **ApplicationName**, and **ConfigurationName** to select from among the sessions that `Get-PSSession` returns. @@ -204,8 +204,8 @@ more variables than objects, the extra variables are not used. ### Example 5: Delete a session by using an instance ID ```powershell -Get-PSSession | Format-Table -Property ComputerName, InstanceID -$s = Get-PSSession -InstanceID a786be29-a6bb-40da-80fb-782c67f7db0f +Get-PSSession | Format-Table -Property ComputerName, InstanceId +$s = Get-PSSession -InstanceId a786be29-a6bb-40da-80fb-782c67f7db0f Remove-PSSession -Session $s ``` @@ -214,10 +214,10 @@ This example shows how to get a **PSSession** by using its instance ID, and then The first command gets all of the **PSSessions** that were created in the current session. It sends the **PSSessions** to the `Format-Table` cmdlet, which displays the **ComputerName** and -**InstanceID** properties of each **PSSession**. +**InstanceId** properties of each **PSSession**. The second command uses the `Get-PSSession` cmdlet to get a particular **PSSession** and to save it -in the `$s` variable. The command uses the **InstanceID** parameter to identify the **PSSession**. +in the `$s` variable. The command uses the **InstanceId** parameter to identify the **PSSession**. The third command uses the Remove-PSSession cmdlet to delete the **PSSession** in the `$s` variable. @@ -272,7 +272,7 @@ for use. Get-PSSession -Id 2 ``` -This command gets the **PSSession** with ID `2`. Because the value of the **ID** property is unique +This command gets the **PSSession** with ID `2`. Because the value of the **Id** property is unique only in the current session, the **Id** parameter is valid only for local commands. ## PARAMETERS @@ -551,11 +551,11 @@ Accept wildcard characters: False Specifies an array of session IDs. This cmdlet gets only the sessions with the specified IDs. Type one or more IDs, separated by commas, or use the range operator (`..`) to specify a range of IDs. -You cannot use the ID parameter together with the **ComputerName** parameter. +You cannot use the **Id** parameter together with the **ComputerName** parameter. An ID is an integer that uniquely identifies the user-managed sessions in the current session. It is easier to remember and type than the **InstanceId**, but it is unique only within the current -session. The ID of a session is stored in the **ID** property of the session. +session. The ID of a session is stored in the **Id** property of the session. ```yaml Type: System.Int32[] @@ -575,9 +575,9 @@ Specifies an array of instance IDs of sessions. This cmdlet gets only the sessio specified instance IDs. The instance ID is a GUID that uniquely identifies a session on a local or remote computer. The -**InstanceID** is unique, even when you have multiple sessions running in PowerShell. +**InstanceId** is unique, even when you have multiple sessions running in PowerShell. -The instance ID of a session is stored in the **InstanceID** property of the session. +The instance ID of a session is stored in the **InstanceId** property of the session. ```yaml Type: System.Guid[] @@ -819,7 +819,7 @@ PowerShell includes the following aliases for `Get-PSSession`: computer and runs query commands in the session. - To get sessions that connect to a remote computer, use the **ComputerName** or **ConnectionUri** parameters to specify the remote computer. To filter the sessions that `Get-PSSession` gets, use - the **Name**, **ID**, **InstanceID**, and **State** parameters. Use the remaining parameters to + the **Name**, **Id**, **InstanceId**, and **State** parameters. Use the remaining parameters to configure the temporary session that `Get-PSSession` uses. - When you use the **ComputerName** or **ConnectionUri** parameters, `Get-PSSession` gets only sessions from computers running Windows PowerShell 3.0 and later versions of PowerShell. diff --git a/reference/7.5/Microsoft.PowerShell.Core/Disconnect-PSSession.md b/reference/7.5/Microsoft.PowerShell.Core/Disconnect-PSSession.md index 276299d9da27..6978a30ebdcf 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Disconnect-PSSession.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Disconnect-PSSession.md @@ -223,7 +223,7 @@ OutputBufferingMode : Block AutoRestart : false SecurityDescriptorSddl : O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD) MaxMemoryPerShellMB : 1024 -MaxIdleTimeoutms : 2147483647 +MaxIdleTimeoutMs : 2147483647 Uri : http://schemas.microsoft.com/powershell/microsoft.powershell SDKVersion : 2 Name : microsoft.powershell @@ -298,7 +298,7 @@ violation can go undetected while the session is in use. The fourth command uses the `Invoke-Command` cmdlet to run a `Get-PSSessionConfiguration` command for the `Microsoft.PowerShell` session configuration on the Server01 computer. The command uses the `Format-List` cmdlet to display all properties of the session configuration in a list.The output -shows that the **MaxIdleTimeoutMS** property, which establishes the maximum permitted +shows that the **MaxIdleTimeoutMs** property, which establishes the maximum permitted **IdleTimeout** value for sessions that use the session configuration, is `43200000` milliseconds (12 hours). @@ -323,7 +323,7 @@ which is measured in milliseconds. The output confirms that the command was succ Disconnects from sessions with the specified session ID. Type one or more IDs (separated by commas), or use the range operator (`..`) to specify a range of IDs. -To get the ID of a session, use the `Get-PSSession` cmdlet. The instance ID is stored in the **ID** +To get the ID of a session, use the `Get-PSSession` cmdlet. The instance ID is stored in the **Id** property of the session. ```yaml @@ -378,7 +378,7 @@ The instance ID is a GUID that uniquely identifies a session on a local or remot instance ID is unique, even across multiple sessions on multiple computers. To get the instance ID of a session, use the `Get-PSSession` cmdlet. The instance ID is stored in -the **InstanceID** property of the session. +the **InstanceId** property of the session. ```yaml Type: System.Guid[] diff --git a/reference/7.5/Microsoft.PowerShell.Core/Enter-PSSession.md b/reference/7.5/Microsoft.PowerShell.Core/Enter-PSSession.md index 7e418611d4c1..c8ff8df3a8fe 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Enter-PSSession.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Enter-PSSession.md @@ -134,20 +134,20 @@ remote computer. When the session starts, the command prompt changes to include The second command gets the PowerShell process and redirects the output to the `Process.txt` file. The command is submitted to the remote computer, and the file is saved on the remote computer. -The third command uses the **Exit** keyword to end the interactive session and close the connection. +The third command uses the `exit` keyword to end the interactive session and close the connection. The fourth command confirms that the Process.txt file is on the remote computer. A `Get-ChildItem` ("dir") command on the local computer can't find the file. ```powershell PS C:\> Enter-PSSession -ComputerName Server01 [Server01]: PS C:\> -[Server01]: PS C:\> Get-Process PowerShell > C:\ps-test\Process.txt +[Server01]: PS C:\> Get-Process powershell > C:\ps-test\Process.txt [Server01]: PS C:\> exit PS C:\> PS C:\> dir C:\ps-test\Process.txt Get-ChildItem : Cannot find path 'C:\ps-test\Process.txt' because it does not exist. At line:1 char:4 -+ dir <<<< c:\ps-test\Process.txt ++ dir <<<< C:\ps-test\Process.txt ``` This command shows how to work in an interactive session with a remote computer. @@ -186,7 +186,7 @@ This example shows how to start and stop an interactive session. The first comma `Enter-PSSession` cmdlet to start an interactive session with the Server01 computer. The second command uses the `Exit-PSSession` cmdlet to end the session. You can also use the -**Exit** keyword to end the interactive session. `Exit-PSSession` and **Exit** have the same effect. +`exit` keyword to end the interactive session. `Exit-PSSession` and `exit` have the same effect. ### Example 6: Start an interactive session using SSH @@ -201,7 +201,7 @@ Otherwise, you must use key-based user authentication. ### Example 7: Start an interactive session using SSH with a port and user authentication key ```powershell -PS> Enter-PSSession -HostName UserA@LinuxServer02:22 -KeyFilePath c:\sshkeys\userAKey_rsa +PS> Enter-PSSession -HostName UserA@LinuxServer02:22 -KeyFilePath C:\sshkeys\userAKey_rsa ``` This example shows how to start an interactive session using SSH. The username and SSH port number @@ -216,7 +216,7 @@ $options = @{ User = 'UserA' Host = 'LinuxServer02' } -Enter-PSSession -KeyFilePath c:\sshkeys\userAKey_rsa -Options $options +Enter-PSSession -KeyFilePath C:\sshkeys\userAKey_rsa -Options $options ``` This example shows how to start an interactive session using SSH. The **Options** parameter takes a @@ -538,7 +538,7 @@ Accept wildcard characters: False Specifies a computer name for a Secure Shell (SSH) based connection. This is similar to the **ComputerName** parameter except that the connection to the remote computer is made using SSH rather than Windows WinRM. This parameter supports specifying the user name and/or port as part of -the host name parameter value using the form `user@hostname:port`. The user name and/or port +the **HostName** parameter value using the form `user@hostname:port`. The user name and/or port specified as part of the host name takes precedence over the `-UserName` and `-Port` parameters, if specified. This allows passing multiple computer names to this parameter where some have specific user names and/or ports, while others use the user name and/or port from the `-UserName` and `-Port` @@ -583,7 +583,7 @@ Specifies the instance ID of an existing session. `Enter-PSSession` uses the spe the interactive session. The instance ID is a GUID. To find the instance ID of a session, use the `Get-PSSession` cmdlet. You -can also use the **Session**, **Name**, or **ID** parameters to specify an existing session. Or, you +can also use the **Session**, **Name**, or **Id** parameters to specify an existing session. Or, you can use the **ComputerName** parameter to start a temporary session. ```yaml @@ -626,7 +626,7 @@ Specifies the friendly name of an existing session. `Enter-PSSession` uses the s the interactive session. If the name that you specify matches more than one session, the command fails. You can also use the -**Session**, **InstanceID**, or **ID** parameters to specify an existing session. Or, you can use +**Session**, **InstanceId**, or **Id** parameters to specify an existing session. Or, you can use the **ComputerName** parameter to start a temporary session. To establish a friendly name for a session, use the **Name** parameter of the `New-PSSession` @@ -725,7 +725,7 @@ Accept wildcard characters: False ### -Session Specifies a PowerShell session (**PSSession**) to use for the interactive session. This parameter -takes a session object. You can also use the **Name**, **InstanceID**, or **ID** parameters to +takes a session object. You can also use the **Name**, **InstanceId**, or **Id** parameters to specify a **PSSession**. Enter a variable that contains a session object or a command that creates or gets a session object, @@ -733,7 +733,7 @@ such as a `New-PSSession` or `Get-PSSession` command. You can also pipe a sessio `Enter-PSSession`. You can submit only one **PSSession** by using this parameter. If you enter a variable that contains more than one **PSSession**, the command fails. -When you use `Exit-PSSession` or the **EXIT** keyword, the interactive session ends, but the +When you use `Exit-PSSession` or the `exit` keyword, the interactive session ends, but the **PSSession** that you created remains open and available for use. ```yaml diff --git a/reference/7.5/Microsoft.PowerShell.Core/Exit-PSSession.md b/reference/7.5/Microsoft.PowerShell.Core/Exit-PSSession.md index 9b585b83569a..05831c2c6072 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Exit-PSSession.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Exit-PSSession.md @@ -69,7 +69,7 @@ The third command uses `Exit-PSSession` to stop the interactive session. The final command displays the **PSSession** in the `$s` variable. The **State** property shows the **PSSession** is still open and available for use. -### Example 3: Use the Exit keyword to stop a session +### Example 3: Use the `exit` keyword to stop a session ```powershell PS> Enter-PSSession -ComputerName Server01 diff --git a/reference/7.5/Microsoft.PowerShell.Core/ForEach-Object.md b/reference/7.5/Microsoft.PowerShell.Core/ForEach-Object.md index 259a7590b81e..c996dd80d7f8 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/ForEach-Object.md +++ b/reference/7.5/Microsoft.PowerShell.Core/ForEach-Object.md @@ -55,7 +55,7 @@ command. `Get-Process | ForEach-Object {$_.ProcessName}` `ForEach-Object` supports the `begin`, `process`, and `end` blocks as described in - [about_functions](about/about_functions.md#piping-objects-to-functions). + [about_Functions](about/about_functions.md#piping-objects-to-functions). > [!NOTE] > The script blocks run in the caller's scope. Therefore, the blocks have access to variables in @@ -73,8 +73,8 @@ command. - **Parallel running script block**. Beginning with PowerShell 7.0, a third parameter set is available that runs each script block in parallel. The **ThrottleLimit** parameter limits the number of parallel scripts running at a time. As before, use the `$_` variable to represent the - current input object in the script block. Use the `$using:` keyword to pass variable references to - the running script. + current input object in the script block. Use the `Using:` scope modifier to pass variable + references to the running script. In PowerShell 7, a new runspace is created for each loop iteration to ensure maximum isolation. This can be a large performance and resource hit if the work you are doing is small compared to @@ -115,7 +115,7 @@ Get-ChildItem $PSHOME | If the object isn't a directory, the script block gets the name of the file, divides the value of its **Length** property by 1024, and adds a space (" ") to separate it from the next entry. The -cmdlet uses the **PSISContainer** property to determine whether an object is a directory. +cmdlet uses the **PSIsContainer** property to determine whether an object is a directory. ### Example 3: Operate on the most recent System events @@ -190,7 +190,7 @@ the **MemberName** parameter of the `ForEach-Object` cmdlet. ```powershell Get-Module -ListAvailable | ForEach-Object -MemberName Path -Get-Module -ListAvailable | Foreach Path +Get-Module -ListAvailable | foreach Path ``` The second command is equivalent to the first. It uses the `Foreach` alias of the `ForEach-Object` @@ -212,7 +212,7 @@ are equivalent and interchangeable. The output is the same for all three cases. "Microsoft.PowerShell.Core", "Microsoft.PowerShell.Host" | ForEach-Object -MemberName Split -ArgumentList "." "Microsoft.PowerShell.Core", "Microsoft.PowerShell.Host" | - Foreach Split "." + foreach Split "." ``` ```Output @@ -231,7 +231,7 @@ argument. The second command uses the **MemberName** parameter to specify the **Split** method and the **ArgumentList** parameter to identify the dot (`.`) as the split delimiter. -The third command uses the **Foreach** alias of the `ForEach-Object` cmdlet and omits the names of +The third command uses the `foreach` alias of the `ForEach-Object` cmdlet and omits the names of the **MemberName** and **ArgumentList** parameters, which are optional. ### Example 8: Using ForEach-Object with two script blocks @@ -300,7 +300,7 @@ This example runs a script block that evaluates a string and sleeps for one seco $Message = "Output:" 1..8 | ForEach-Object -Parallel { - "$using:Message $_" + "$Using:Message $_" Start-Sleep 1 } -ThrottleLimit 4 ``` @@ -317,7 +317,7 @@ Output: 8 ``` The **ThrottleLimit** parameter value is set to 4 so that the input is processed in batches of four. -The `$using:` keyword is used to pass the `$Message` variable into each parallel script block. +The `Using:` scope modifier is used to pass the `$Message` variable into each parallel script block. ### Example 12: Retrieve log entries in parallel @@ -386,7 +386,7 @@ This example invokes script blocks in parallel to collect uniquely named Process ```powershell $threadSafeDictionary = [System.Collections.Concurrent.ConcurrentDictionary[string,object]]::new() Get-Process | ForEach-Object -Parallel { - $dict = $using:threadSafeDictionary + $dict = $Using:threadSafeDictionary $dict.TryAdd($_.ProcessName, $_) } @@ -453,17 +453,17 @@ Output: 5 > [!NOTE] > [PipelineVariable](About/about_CommonParameters.md) common parameter variables are _not_ -> supported in `Foreach-Object -Parallel` scenarios even with the `$using:` keyword. +> supported in `ForEach-Object -Parallel` scenarios even with the `Using:` scope modifier. ### Example 17: Passing variables in nested parallel script ScriptBlockSet -You can create a variable outside a `Foreach-Object -Parallel` scoped scriptblock and use -it inside the scriptblock with the `$using` keyword. +You can create a variable outside a `ForEach-Object -Parallel` scoped scriptblock and use +it inside the scriptblock with the `Using:` scope modifier. ```powershell $test1 = 'TestA' -1..2 | Foreach-Object -Parallel { - $using:test1 +1..2 | ForEach-Object -Parallel { + $Using:test1 } ``` @@ -476,20 +476,20 @@ TestA # You CANNOT create a variable inside a scoped scriptblock # to be used in a nested foreach parallel scriptblock. $test1 = 'TestA' -1..2 | Foreach-Object -Parallel { - $using:test1 +1..2 | ForEach-Object -Parallel { + $Using:test1 $test2 = 'TestB' - 1..2 | Foreach-Object -Parallel { - $using:test2 + 1..2 | ForEach-Object -Parallel { + $Using:test2 } } ``` ```Output Line | - 2 | 1..2 | Foreach-Object -Parallel { + 2 | 1..2 | ForEach-Object -Parallel { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ - | The value of the using variable '$using:test2' can't be retrieved because it has + | The value of the using variable '$Using:test2' can't be retrieved because it has | not been set in the local session. ``` @@ -626,7 +626,7 @@ Specifies the name of the member property to get or the member method to call. T instance members, not static members. Wildcard characters are permitted, but work only if the resulting string resolves to a unique value. -For example, if you run `Get-Process | ForEach -MemberName *Name`, the wildcard pattern matches more +For example, if you run `Get-Process | foreach -MemberName *Name`, the wildcard pattern matches more than one member causing the command to fail. This parameter was introduced in Windows PowerShell 3.0. @@ -828,12 +828,12 @@ PowerShell includes the following aliases for `ForEach-Object`: - `%` - `foreach` -The `ForEach-Object` cmdlet works much like the **Foreach** statement, except that you can't pipe -input to a **Foreach** statement. For more information about the **Foreach** statement, see +The `ForEach-Object` cmdlet works much like the `foreach` statement, except that you can't pipe +input to a `foreach` statement. For more information about the `foreach` statement, see [about_Foreach](./About/about_Foreach.md). Starting in PowerShell 4.0, `Where` and `ForEach` methods were added for use with collections. You -can read more about these new methods here [about_arrays](./About/about_Arrays.md) +can read more about these new methods here [about_Arrays](./About/about_Arrays.md) Using `ForEach-Object -Parallel`: @@ -869,18 +869,18 @@ Using `ForEach-Object -Parallel`: Terminating errors, such as exceptions, terminate the individual parallel instance of the scriptblocks in which they occur. A terminating error in one scriptblocks may not cause the - termination of the `Foreach-Object` cmdlet. The other scriptblocks, running in parallel, continue + termination of the `ForEach-Object` cmdlet. The other scriptblocks, running in parallel, continue to run unless they also encounter a terminating error. The terminating error is written to the error data stream as an **ErrorRecord** with a **FullyQualifiedErrorId** of `PSTaskException`. Terminating errors can be converted to non-terminating errors using PowerShell `try`/`catch` or `trap` blocks. - [PipelineVariable](About/about_CommonParameters.md) common parameter variables are _not_ supported - in parallel scenarios even with the `$using:` keyword. + in parallel scenarios even with the `Using:` scope modifier. > [!IMPORTANT] > The `ForEach-Object -Parallel` parameter set runs script blocks in parallel on separate process - > threads. The `$using:` keyword allows passing variable references from the cmdlet invocation + > threads. The `Using:` modifier allows passing variable references from the cmdlet invocation > thread to each running script block thread. Since the script blocks run in different threads, > the object variables passed by reference must be used safely. Generally it's safe to read from > referenced objects that don't change. If you need to modify the object state then you must diff --git a/reference/7.5/Microsoft.PowerShell.Core/Get-Command.md b/reference/7.5/Microsoft.PowerShell.Core/Get-Command.md index 2960c9a23fc7..af63f28a3137 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Get-Command.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Get-Command.md @@ -42,7 +42,7 @@ have been imported into the current session, use the **ListImported** parameter. Without parameters, `Get-Command` gets all the cmdlets, functions, and aliases installed on the computer. `Get-Command *` gets all types of commands, including all the non-PowerShell files in the -Path environment variable (`$env:PATH`), which it lists in the Application command type. +PATH environment variable (`$Env:PATH`), which it lists in the Application command type. `Get-Command` that uses the exact name of the command, without wildcard characters, automatically imports the module that contains the command so that you can use the command immediately. To enable, @@ -115,7 +115,7 @@ This command uses the **ArgumentList** and **Syntax** parameters to get the synt the Certificate Provider adds to the session. ```powershell -Get-Command -Name Get-Childitem -Args Cert: -Syntax +Get-Command -Name Get-ChildItem -Args Cert: -Syntax ``` When you compare the syntax displayed in the output with the syntax that's displayed when you omit @@ -155,7 +155,7 @@ cmdlet by another cmdlet or a provider. ### Example 8: Get all commands of all types This command gets all commands of all types on the local computer, including executable files in the -paths of the **Path** environment variable (`$env:PATH`). +paths of the **PATH** environment variable (`$Env:PATH`). ```powershell Get-Command * @@ -285,7 +285,7 @@ code defines the **OutputType** attribute for the cmdlet. ### Example 15: Get cmdlets that take a specific object type as input ```powershell -Get-Command -ParameterType (((Get-NetAdapter)[0]).PSTypeNames) +Get-Command -ParameterType (((Get-NetAdapter)[0]).pstypenames) ``` ```Output @@ -301,9 +301,9 @@ Function Set-NetAdapter NetAdapter This command finds cmdlets that take net adapter objects as input. You can use this command format to find the cmdlets that accept the type of objects that any command returns. -The command uses the **PSTypeNames** intrinsic property of all objects, which gets the types that -describe the object. To get the **PSTypeNames** property of a net adapter, and not the -**PSTypeNames** property of a collection of net adapters, the command uses array notation to get the +The command uses the **pstypenames** intrinsic property of all objects, which gets the types that +describe the object. To get the **pstypenames** property of a net adapter, and not the +**pstypenames** property of a collection of net adapters, the command uses array notation to get the first net adapter that the cmdlet returns. ### Example 16: Get commands using a fuzzy match @@ -391,15 +391,15 @@ The acceptable values for this parameter are: - `All`: Gets all command types. This parameter value is the equivalent of `Get-Command *`. -- `Application`: Searches folders in the `$env:PATH` environment variable for non-PowerShell +- `Application`: Searches folders in the `$Env:PATH` environment variable for non-PowerShell executable files. On Windows, executable files have a file extension that is listed in the - `$env:PATHEXT` environment variable. For more information, see + `$Env:PATHEXT` environment variable. For more information, see [about_Environment_Variables](About/about_Environment_Variables.md). - `Cmdlet`: Gets all cmdlets. -- `ExternalScript`: Gets all `.ps1` files in the paths listed in the **Path** environment variable - (`$env:PATH`). +- `ExternalScript`: Gets all `.ps1` files in the paths listed in the **PATH** environment variable + (`$Env:PATH`). - `Filter` and `Function`: Gets all PowerShell advanced and simple functions and filters. diff --git a/reference/7.5/Microsoft.PowerShell.Core/Get-Help.md b/reference/7.5/Microsoft.PowerShell.Core/Get-Help.md index 7db0e48f5321..2819484c2eed 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Get-Help.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Get-Help.md @@ -472,7 +472,7 @@ script, or workflow, such as `Get-Member`, a conceptual article name, such as `a alias, such as `ls`. Wildcard characters are permitted in cmdlet and provider names, but you can't use wildcard characters to find the names of function help and script help articles. -To get help for a script that isn't located in a path that's listed in the `$env:Path` environment +To get help for a script that isn't located in a path that's listed in the `$Env:PATH` environment variable, type the script's path and file name. If you enter the exact name of a help article, `Get-Help` displays the article contents. diff --git a/reference/7.5/Microsoft.PowerShell.Core/Get-History.md b/reference/7.5/Microsoft.PowerShell.Core/Get-History.md index 111252c8357a..2136f025ea1a 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Get-History.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Get-History.md @@ -63,7 +63,7 @@ saves it in the History.csv file. The file includes the data that is displayed w history as a list. This includes the status and start and end times of the command. ```powershell -Get-History -ID 7 -Count 5 | Export-Csv -Path History.csv +Get-History -Id 7 -Count 5 | Export-Csv -Path History.csv ``` ### Example 4: Display the most recent command diff --git a/reference/7.5/Microsoft.PowerShell.Core/Get-Job.md b/reference/7.5/Microsoft.PowerShell.Core/Get-Job.md index 9a228bf5b4bd..affc88b4f681 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Get-Job.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Get-Job.md @@ -95,7 +95,7 @@ Get-Job ```Output Id Name PSJobTypeName State HasMoreData Location Command -- ---- ------------- ----- ----------- -------- ------- -1 Job1 BackgroundJob Completed True localhost $env:COMPUTERNAME +1 Job1 BackgroundJob Completed True localhost $Env:COMPUTERNAME ``` ### Example 2: Stop a job by using an instance ID @@ -113,7 +113,7 @@ instance ID of the job. ```powershell $j = Get-Job -Name Job1 -$ID = $j.InstanceID +$ID = $j.InstanceId $ID ``` @@ -180,7 +180,7 @@ Get-Job -Name Job* ```Output Id Name PSJobTypeName State HasMoreData Location Command -- ---- ------------- ----- ----------- -------- ------- -1 Job1 BackgroundJob Completed True localhost $env:COMPUTERNAME +1 Job1 BackgroundJob Completed True localhost $Env:COMPUTERNAME ``` ### Example 7: Use a job object to represent the job in a command @@ -316,7 +316,7 @@ PS> Get-Job | Format-List -Property * HasMoreData : False StatusMessage : Location : localhost -Command : get-process +Command : Get-Process JobStateInfo : Failed Finished : System.Threading.ManualReset EventInstanceId : fb792295-1318-4f5d-8ac8-8a89c5261507 @@ -331,7 +331,7 @@ Debug : {} Warning : {} StateChanged : -PS> (Get-Job -Name job2).JobStateInfo.Reason +PS> (Get-Job -Name Job2).JobStateInfo.Reason Connecting to remote server using WSManCreateShellEx api failed. The async callback gave the following error message: Access is denied. ``` @@ -342,7 +342,7 @@ This example shows how to use the **Filter** parameter to get a workflow job. Th parameter, introduced in Windows PowerShell 3.0 is valid only on custom job types, such as workflow jobs and scheduled jobs. -The first command uses the **Workflow** keyword to create the WFProcess workflow. The second command +The first command uses the `workflow` keyword to create the WFProcess workflow. The second command uses the **AsJob** parameter of the WFProcess workflow to run the workflow as a background job. It uses the **JobName** parameter of the workflow to specify a name for the job, and the **PSPrivateMetadata** parameter of the workflow to specify a custom ID. The third command uses the @@ -350,7 +350,7 @@ uses the **JobName** parameter of the workflow to specify a name for the job, an **PSPrivateMetadata** parameter. ```powershell -PS> Workflow WFProcess {Get-Process} +PS> workflow WFProcess {Get-Process} PS> WFProcess -AsJob -JobName WFProcessJob -PSPrivateMetadata @{MyCustomId = 92107} PS> Get-Job -Filter @{MyCustomId = 92107} Id Name State HasMoreData Location Command diff --git a/reference/7.5/Microsoft.PowerShell.Core/Get-Module.md b/reference/7.5/Microsoft.PowerShell.Core/Get-Module.md index a4febae3cae6..e253f803558c 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Get-Module.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Get-Module.md @@ -49,7 +49,7 @@ The `Get-Module` cmdlet lists the PowerShell modules that have been imported, or imported, into a PowerShell session. Without parameters, `Get-Module` gets modules that have been imported into the current session. The **ListAvailable** parameter is used to list the modules that are available to be imported from the paths specified in the **PSModulePath** environment variable -(`$env:PSModulePath`). +(`$Env:PSModulePath`). The module object that `Get-Module` returns contains valuable information about the module. You can also pipe the module objects to other cmdlets, such as the `Import-Module` and `Remove-Module` @@ -81,7 +81,7 @@ These include computers that are not running the Windows operating system, and c PowerShell but do not have PowerShell remoting enabled. Start by creating a CIM session on the remote computer. A CIM session is a connection to Windows -Management Instrumentation (WMI) on the remote computer. Then use the **CIMSession** parameter of +Management Instrumentation (WMI) on the remote computer. Then use the **CimSession** parameter of `Get-Module` to get CIM modules from the CIM session. When you import a CIM module by using the `Import-Module` cmdlet and then run the imported commands, the commands run implicitly on the remote computer. You can use this WMI and CIM strategy to manage the remote computer. @@ -105,7 +105,7 @@ Get-Module -ListAvailable This command gets the modules that are installed on the computer and can be imported into the current session. -`Get-Module` looks for available modules in the path specified by the **$env:PSModulePath** +`Get-Module` looks for available modules in the path specified by the **$Env:PSModulePath** environment variable. For more information about **PSModulePath**, see [about_Modules](About/about_Modules.md) and [about_Environment_Variables](About/about_Environment_Variables.md). @@ -688,7 +688,7 @@ PowerShell includes the following aliases for `Get-Module`: [CreateDefault2 Method](/dotnet/api/system.management.automation.runspaces.initialsessionstate.createdefault2). - `Get-Module` only gets modules in locations that are stored in the value of the **PSModulePath** - environment variable (`$env:PSModulePath`). The `Import-Module` cmdlet can import modules in other + environment variable (`$Env:PSModulePath`). The `Import-Module` cmdlet can import modules in other locations, but you cannot use the `Get-Module` cmdlet to get them. - Also, starting in PowerShell 3.0, new properties have been added to the object that `Get-Module` diff --git a/reference/7.5/Microsoft.PowerShell.Core/Get-PSSession.md b/reference/7.5/Microsoft.PowerShell.Core/Get-PSSession.md index 984e49be9999..413ac530222a 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Get-PSSession.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Get-PSSession.md @@ -120,7 +120,7 @@ created in the current session. Without parameters, `Get-PSSession` gets all sessions that were created in the current session. -Use the filtering parameters, including **Name**, **ID**, **InstanceID**, **State**, +Use the filtering parameters, including **Name**, **Id**, **InstanceId**, **State**, **ApplicationName**, and **ConfigurationName** to select from among the sessions that `Get-PSSession` returns. @@ -204,8 +204,8 @@ more variables than objects, the extra variables are not used. ### Example 5: Delete a session by using an instance ID ```powershell -Get-PSSession | Format-Table -Property ComputerName, InstanceID -$s = Get-PSSession -InstanceID a786be29-a6bb-40da-80fb-782c67f7db0f +Get-PSSession | Format-Table -Property ComputerName, InstanceId +$s = Get-PSSession -InstanceId a786be29-a6bb-40da-80fb-782c67f7db0f Remove-PSSession -Session $s ``` @@ -214,10 +214,10 @@ This example shows how to get a **PSSession** by using its instance ID, and then The first command gets all of the **PSSessions** that were created in the current session. It sends the **PSSessions** to the `Format-Table` cmdlet, which displays the **ComputerName** and -**InstanceID** properties of each **PSSession**. +**InstanceId** properties of each **PSSession**. The second command uses the `Get-PSSession` cmdlet to get a particular **PSSession** and to save it -in the `$s` variable. The command uses the **InstanceID** parameter to identify the **PSSession**. +in the `$s` variable. The command uses the **InstanceId** parameter to identify the **PSSession**. The third command uses the Remove-PSSession cmdlet to delete the **PSSession** in the `$s` variable. @@ -272,7 +272,7 @@ for use. Get-PSSession -Id 2 ``` -This command gets the **PSSession** with ID `2`. Because the value of the **ID** property is unique +This command gets the **PSSession** with ID `2`. Because the value of the **Id** property is unique only in the current session, the **Id** parameter is valid only for local commands. ## PARAMETERS @@ -551,11 +551,11 @@ Accept wildcard characters: False Specifies an array of session IDs. This cmdlet gets only the sessions with the specified IDs. Type one or more IDs, separated by commas, or use the range operator (`..`) to specify a range of IDs. -You cannot use the ID parameter together with the **ComputerName** parameter. +You cannot use the **Id** parameter together with the **ComputerName** parameter. An ID is an integer that uniquely identifies the user-managed sessions in the current session. It is easier to remember and type than the **InstanceId**, but it is unique only within the current -session. The ID of a session is stored in the **ID** property of the session. +session. The ID of a session is stored in the **Id** property of the session. ```yaml Type: System.Int32[] @@ -575,9 +575,9 @@ Specifies an array of instance IDs of sessions. This cmdlet gets only the sessio specified instance IDs. The instance ID is a GUID that uniquely identifies a session on a local or remote computer. The -**InstanceID** is unique, even when you have multiple sessions running in PowerShell. +**InstanceId** is unique, even when you have multiple sessions running in PowerShell. -The instance ID of a session is stored in the **InstanceID** property of the session. +The instance ID of a session is stored in the **InstanceId** property of the session. ```yaml Type: System.Guid[] @@ -819,7 +819,7 @@ PowerShell includes the following aliases for `Get-PSSession`: computer and runs query commands in the session. - To get sessions that connect to a remote computer, use the **ComputerName** or **ConnectionUri** parameters to specify the remote computer. To filter the sessions that `Get-PSSession` gets, use - the **Name**, **ID**, **InstanceID**, and **State** parameters. Use the remaining parameters to + the **Name**, **Id**, **InstanceId**, and **State** parameters. Use the remaining parameters to configure the temporary session that `Get-PSSession` uses. - When you use the **ComputerName** or **ConnectionUri** parameters, `Get-PSSession` gets only sessions from computers running Windows PowerShell 3.0 and later versions of PowerShell. diff --git a/reference/7.6/Microsoft.PowerShell.Core/Disconnect-PSSession.md b/reference/7.6/Microsoft.PowerShell.Core/Disconnect-PSSession.md index dac222ce5535..d0df7a503d5b 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/Disconnect-PSSession.md +++ b/reference/7.6/Microsoft.PowerShell.Core/Disconnect-PSSession.md @@ -223,7 +223,7 @@ OutputBufferingMode : Block AutoRestart : false SecurityDescriptorSddl : O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD) MaxMemoryPerShellMB : 1024 -MaxIdleTimeoutms : 2147483647 +MaxIdleTimeoutMs : 2147483647 Uri : http://schemas.microsoft.com/powershell/microsoft.powershell SDKVersion : 2 Name : microsoft.powershell @@ -298,7 +298,7 @@ violation can go undetected while the session is in use. The fourth command uses the `Invoke-Command` cmdlet to run a `Get-PSSessionConfiguration` command for the `Microsoft.PowerShell` session configuration on the Server01 computer. The command uses the `Format-List` cmdlet to display all properties of the session configuration in a list.The output -shows that the **MaxIdleTimeoutMS** property, which establishes the maximum permitted +shows that the **MaxIdleTimeoutMs** property, which establishes the maximum permitted **IdleTimeout** value for sessions that use the session configuration, is `43200000` milliseconds (12 hours). @@ -323,7 +323,7 @@ which is measured in milliseconds. The output confirms that the command was succ Disconnects from sessions with the specified session ID. Type one or more IDs (separated by commas), or use the range operator (`..`) to specify a range of IDs. -To get the ID of a session, use the `Get-PSSession` cmdlet. The instance ID is stored in the **ID** +To get the ID of a session, use the `Get-PSSession` cmdlet. The instance ID is stored in the **Id** property of the session. ```yaml @@ -378,7 +378,7 @@ The instance ID is a GUID that uniquely identifies a session on a local or remot instance ID is unique, even across multiple sessions on multiple computers. To get the instance ID of a session, use the `Get-PSSession` cmdlet. The instance ID is stored in -the **InstanceID** property of the session. +the **InstanceId** property of the session. ```yaml Type: System.Guid[] diff --git a/reference/7.6/Microsoft.PowerShell.Core/Enter-PSSession.md b/reference/7.6/Microsoft.PowerShell.Core/Enter-PSSession.md index b70e675c34a7..6d43cd25911c 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/Enter-PSSession.md +++ b/reference/7.6/Microsoft.PowerShell.Core/Enter-PSSession.md @@ -134,20 +134,20 @@ remote computer. When the session starts, the command prompt changes to include The second command gets the PowerShell process and redirects the output to the `Process.txt` file. The command is submitted to the remote computer, and the file is saved on the remote computer. -The third command uses the **Exit** keyword to end the interactive session and close the connection. +The third command uses the `exit` keyword to end the interactive session and close the connection. The fourth command confirms that the Process.txt file is on the remote computer. A `Get-ChildItem` ("dir") command on the local computer can't find the file. ```powershell PS C:\> Enter-PSSession -ComputerName Server01 [Server01]: PS C:\> -[Server01]: PS C:\> Get-Process PowerShell > C:\ps-test\Process.txt +[Server01]: PS C:\> Get-Process powershell > C:\ps-test\Process.txt [Server01]: PS C:\> exit PS C:\> PS C:\> dir C:\ps-test\Process.txt Get-ChildItem : Cannot find path 'C:\ps-test\Process.txt' because it does not exist. At line:1 char:4 -+ dir <<<< c:\ps-test\Process.txt ++ dir <<<< C:\ps-test\Process.txt ``` This command shows how to work in an interactive session with a remote computer. @@ -186,7 +186,7 @@ This example shows how to start and stop an interactive session. The first comma `Enter-PSSession` cmdlet to start an interactive session with the Server01 computer. The second command uses the `Exit-PSSession` cmdlet to end the session. You can also use the -**Exit** keyword to end the interactive session. `Exit-PSSession` and **Exit** have the same effect. +`exit` keyword to end the interactive session. `Exit-PSSession` and `exit` have the same effect. ### Example 6: Start an interactive session using SSH @@ -201,7 +201,7 @@ Otherwise, you must use key-based user authentication. ### Example 7: Start an interactive session using SSH with a port and user authentication key ```powershell -PS> Enter-PSSession -HostName UserA@LinuxServer02:22 -KeyFilePath c:\sshkeys\userAKey_rsa +PS> Enter-PSSession -HostName UserA@LinuxServer02:22 -KeyFilePath C:\sshkeys\userAKey_rsa ``` This example shows how to start an interactive session using SSH. The username and SSH port number @@ -216,7 +216,7 @@ $options = @{ User = 'UserA' Host = 'LinuxServer02' } -Enter-PSSession -KeyFilePath c:\sshkeys\userAKey_rsa -Options $options +Enter-PSSession -KeyFilePath C:\sshkeys\userAKey_rsa -Options $options ``` This example shows how to start an interactive session using SSH. The **Options** parameter takes a @@ -538,7 +538,7 @@ Accept wildcard characters: False Specifies a computer name for a Secure Shell (SSH) based connection. This is similar to the **ComputerName** parameter except that the connection to the remote computer is made using SSH rather than Windows WinRM. This parameter supports specifying the user name and/or port as part of -the host name parameter value using the form `user@hostname:port`. The user name and/or port +the **HostName** parameter value using the form `user@hostname:port`. The user name and/or port specified as part of the host name takes precedence over the `-UserName` and `-Port` parameters, if specified. This allows passing multiple computer names to this parameter where some have specific user names and/or ports, while others use the user name and/or port from the `-UserName` and `-Port` @@ -583,7 +583,7 @@ Specifies the instance ID of an existing session. `Enter-PSSession` uses the spe the interactive session. The instance ID is a GUID. To find the instance ID of a session, use the `Get-PSSession` cmdlet. You -can also use the **Session**, **Name**, or **ID** parameters to specify an existing session. Or, you +can also use the **Session**, **Name**, or **Id** parameters to specify an existing session. Or, you can use the **ComputerName** parameter to start a temporary session. ```yaml @@ -626,7 +626,7 @@ Specifies the friendly name of an existing session. `Enter-PSSession` uses the s the interactive session. If the name that you specify matches more than one session, the command fails. You can also use the -**Session**, **InstanceID**, or **ID** parameters to specify an existing session. Or, you can use +**Session**, **InstanceId**, or **Id** parameters to specify an existing session. Or, you can use the **ComputerName** parameter to start a temporary session. To establish a friendly name for a session, use the **Name** parameter of the `New-PSSession` @@ -725,7 +725,7 @@ Accept wildcard characters: False ### -Session Specifies a PowerShell session (**PSSession**) to use for the interactive session. This parameter -takes a session object. You can also use the **Name**, **InstanceID**, or **ID** parameters to +takes a session object. You can also use the **Name**, **InstanceId**, or **Id** parameters to specify a **PSSession**. Enter a variable that contains a session object or a command that creates or gets a session object, @@ -733,7 +733,7 @@ such as a `New-PSSession` or `Get-PSSession` command. You can also pipe a sessio `Enter-PSSession`. You can submit only one **PSSession** by using this parameter. If you enter a variable that contains more than one **PSSession**, the command fails. -When you use `Exit-PSSession` or the **EXIT** keyword, the interactive session ends, but the +When you use `Exit-PSSession` or the `exit` keyword, the interactive session ends, but the **PSSession** that you created remains open and available for use. ```yaml diff --git a/reference/7.6/Microsoft.PowerShell.Core/Exit-PSSession.md b/reference/7.6/Microsoft.PowerShell.Core/Exit-PSSession.md index ae03a75ce560..67c458027797 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/Exit-PSSession.md +++ b/reference/7.6/Microsoft.PowerShell.Core/Exit-PSSession.md @@ -69,7 +69,7 @@ The third command uses `Exit-PSSession` to stop the interactive session. The final command displays the **PSSession** in the `$s` variable. The **State** property shows the **PSSession** is still open and available for use. -### Example 3: Use the Exit keyword to stop a session +### Example 3: Use the `exit` keyword to stop a session ```powershell PS> Enter-PSSession -ComputerName Server01 diff --git a/reference/7.6/Microsoft.PowerShell.Core/ForEach-Object.md b/reference/7.6/Microsoft.PowerShell.Core/ForEach-Object.md index 64c8ce1a25db..79a6c6e71d98 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/ForEach-Object.md +++ b/reference/7.6/Microsoft.PowerShell.Core/ForEach-Object.md @@ -55,7 +55,7 @@ command. `Get-Process | ForEach-Object {$_.ProcessName}` `ForEach-Object` supports the `begin`, `process`, and `end` blocks as described in - [about_functions](about/about_functions.md#piping-objects-to-functions). + [about_Functions](about/about_functions.md#piping-objects-to-functions). > [!NOTE] > The script blocks run in the caller's scope. Therefore, the blocks have access to variables in @@ -73,8 +73,8 @@ command. - **Parallel running script block**. Beginning with PowerShell 7.0, a third parameter set is available that runs each script block in parallel. The **ThrottleLimit** parameter limits the number of parallel scripts running at a time. As before, use the `$_` variable to represent the - current input object in the script block. Use the `$using:` keyword to pass variable references to - the running script. + current input object in the script block. Use the `Using:` scope modifier to pass variable + references to the running script. In PowerShell 7, a new runspace is created for each loop iteration to ensure maximum isolation. This can be a large performance and resource hit if the work you are doing is small compared to @@ -115,7 +115,7 @@ Get-ChildItem $PSHOME | If the object isn't a directory, the script block gets the name of the file, divides the value of its **Length** property by 1024, and adds a space (" ") to separate it from the next entry. The -cmdlet uses the **PSISContainer** property to determine whether an object is a directory. +cmdlet uses the **PSIsContainer** property to determine whether an object is a directory. ### Example 3: Operate on the most recent System events @@ -190,7 +190,7 @@ the **MemberName** parameter of the `ForEach-Object` cmdlet. ```powershell Get-Module -ListAvailable | ForEach-Object -MemberName Path -Get-Module -ListAvailable | Foreach Path +Get-Module -ListAvailable | foreach Path ``` The second command is equivalent to the first. It uses the `Foreach` alias of the `ForEach-Object` @@ -212,7 +212,7 @@ are equivalent and interchangeable. The output is the same for all three cases. "Microsoft.PowerShell.Core", "Microsoft.PowerShell.Host" | ForEach-Object -MemberName Split -ArgumentList "." "Microsoft.PowerShell.Core", "Microsoft.PowerShell.Host" | - Foreach Split "." + foreach Split "." ``` ```Output @@ -231,7 +231,7 @@ argument. The second command uses the **MemberName** parameter to specify the **Split** method and the **ArgumentList** parameter to identify the dot (`.`) as the split delimiter. -The third command uses the **Foreach** alias of the `ForEach-Object` cmdlet and omits the names of +The third command uses the `foreach` alias of the `ForEach-Object` cmdlet and omits the names of the **MemberName** and **ArgumentList** parameters, which are optional. ### Example 8: Using ForEach-Object with two script blocks @@ -300,7 +300,7 @@ This example runs a script block that evaluates a string and sleeps for one seco $Message = "Output:" 1..8 | ForEach-Object -Parallel { - "$using:Message $_" + "$Using:Message $_" Start-Sleep 1 } -ThrottleLimit 4 ``` @@ -317,7 +317,7 @@ Output: 8 ``` The **ThrottleLimit** parameter value is set to 4 so that the input is processed in batches of four. -The `$using:` keyword is used to pass the `$Message` variable into each parallel script block. +The `Using:` scope modifier is used to pass the `$Message` variable into each parallel script block. ### Example 12: Retrieve log entries in parallel @@ -386,7 +386,7 @@ This example invokes script blocks in parallel to collect uniquely named Process ```powershell $threadSafeDictionary = [System.Collections.Concurrent.ConcurrentDictionary[string,object]]::new() Get-Process | ForEach-Object -Parallel { - $dict = $using:threadSafeDictionary + $dict = $Using:threadSafeDictionary $dict.TryAdd($_.ProcessName, $_) } @@ -453,17 +453,17 @@ Output: 5 > [!NOTE] > [PipelineVariable](About/about_CommonParameters.md) common parameter variables are _not_ -> supported in `Foreach-Object -Parallel` scenarios even with the `$using:` keyword. +> supported in `ForEach-Object -Parallel` scenarios even with the `Using:` scope modifier. ### Example 17: Passing variables in nested parallel script ScriptBlockSet -You can create a variable outside a `Foreach-Object -Parallel` scoped scriptblock and use -it inside the scriptblock with the `$using` keyword. +You can create a variable outside a `ForEach-Object -Parallel` scoped scriptblock and use +it inside the scriptblock with the `Using:` scope modifier. ```powershell $test1 = 'TestA' -1..2 | Foreach-Object -Parallel { - $using:test1 +1..2 | ForEach-Object -Parallel { + $Using:test1 } ``` @@ -476,20 +476,20 @@ TestA # You CANNOT create a variable inside a scoped scriptblock # to be used in a nested foreach parallel scriptblock. $test1 = 'TestA' -1..2 | Foreach-Object -Parallel { - $using:test1 +1..2 | ForEach-Object -Parallel { + $Using:test1 $test2 = 'TestB' - 1..2 | Foreach-Object -Parallel { - $using:test2 + 1..2 | ForEach-Object -Parallel { + $Using:test2 } } ``` ```Output Line | - 2 | 1..2 | Foreach-Object -Parallel { + 2 | 1..2 | ForEach-Object -Parallel { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ - | The value of the using variable '$using:test2' can't be retrieved because it has + | The value of the using variable '$Using:test2' can't be retrieved because it has | not been set in the local session. ``` @@ -626,7 +626,7 @@ Specifies the name of the member property to get or the member method to call. T instance members, not static members. Wildcard characters are permitted, but work only if the resulting string resolves to a unique value. -For example, if you run `Get-Process | ForEach -MemberName *Name`, the wildcard pattern matches more +For example, if you run `Get-Process | foreach -MemberName *Name`, the wildcard pattern matches more than one member causing the command to fail. This parameter was introduced in Windows PowerShell 3.0. @@ -828,12 +828,12 @@ PowerShell includes the following aliases for `ForEach-Object`: - `%` - `foreach` -The `ForEach-Object` cmdlet works much like the **Foreach** statement, except that you can't pipe -input to a **Foreach** statement. For more information about the **Foreach** statement, see +The `ForEach-Object` cmdlet works much like the `foreach` statement, except that you can't pipe +input to a `foreach` statement. For more information about the `foreach` statement, see [about_Foreach](./About/about_Foreach.md). Starting in PowerShell 4.0, `Where` and `ForEach` methods were added for use with collections. You -can read more about these new methods here [about_arrays](./About/about_Arrays.md) +can read more about these new methods here [about_Arrays](./About/about_Arrays.md) Using `ForEach-Object -Parallel`: @@ -869,18 +869,18 @@ Using `ForEach-Object -Parallel`: Terminating errors, such as exceptions, terminate the individual parallel instance of the scriptblocks in which they occur. A terminating error in one scriptblocks may not cause the - termination of the `Foreach-Object` cmdlet. The other scriptblocks, running in parallel, continue + termination of the `ForEach-Object` cmdlet. The other scriptblocks, running in parallel, continue to run unless they also encounter a terminating error. The terminating error is written to the error data stream as an **ErrorRecord** with a **FullyQualifiedErrorId** of `PSTaskException`. Terminating errors can be converted to non-terminating errors using PowerShell `try`/`catch` or `trap` blocks. - [PipelineVariable](About/about_CommonParameters.md) common parameter variables are _not_ supported - in parallel scenarios even with the `$using:` keyword. + in parallel scenarios even with the `Using:` scope modifier. > [!IMPORTANT] > The `ForEach-Object -Parallel` parameter set runs script blocks in parallel on separate process - > threads. The `$using:` keyword allows passing variable references from the cmdlet invocation + > threads. The `Using:` modifier allows passing variable references from the cmdlet invocation > thread to each running script block thread. Since the script blocks run in different threads, > the object variables passed by reference must be used safely. Generally it's safe to read from > referenced objects that don't change. If you need to modify the object state then you must diff --git a/reference/7.6/Microsoft.PowerShell.Core/Get-Command.md b/reference/7.6/Microsoft.PowerShell.Core/Get-Command.md index 38df5f93f470..c0f5c18c12b9 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/Get-Command.md +++ b/reference/7.6/Microsoft.PowerShell.Core/Get-Command.md @@ -42,7 +42,7 @@ have been imported into the current session, use the **ListImported** parameter. Without parameters, `Get-Command` gets all the cmdlets, functions, and aliases installed on the computer. `Get-Command *` gets all types of commands, including all the non-PowerShell files in the -Path environment variable (`$env:PATH`), which it lists in the Application command type. +PATH environment variable (`$Env:PATH`), which it lists in the Application command type. `Get-Command` that uses the exact name of the command, without wildcard characters, automatically imports the module that contains the command so that you can use the command immediately. To enable, @@ -155,7 +155,7 @@ cmdlet by another cmdlet or a provider. ### Example 8: Get all commands of all types This command gets all commands of all types on the local computer, including executable files in the -paths of the **Path** environment variable (`$env:PATH`). +paths of the **PATH** environment variable (`$Env:PATH`). ```powershell Get-Command * @@ -285,7 +285,7 @@ code defines the **OutputType** attribute for the cmdlet. ### Example 15: Get cmdlets that take a specific object type as input ```powershell -Get-Command -ParameterType (((Get-NetAdapter)[0]).PSTypeNames) +Get-Command -ParameterType (((Get-NetAdapter)[0]).pstypenames) ``` ```Output @@ -301,9 +301,9 @@ Function Set-NetAdapter NetAdapter This command finds cmdlets that take net adapter objects as input. You can use this command format to find the cmdlets that accept the type of objects that any command returns. -The command uses the **PSTypeNames** intrinsic property of all objects, which gets the types that -describe the object. To get the **PSTypeNames** property of a net adapter, and not the -**PSTypeNames** property of a collection of net adapters, the command uses array notation to get the +The command uses the **pstypenames** intrinsic property of all objects, which gets the types that +describe the object. To get the **pstypenames** property of a net adapter, and not the +**pstypenames** property of a collection of net adapters, the command uses array notation to get the first net adapter that the cmdlet returns. ### Example 16: Get commands using a fuzzy match @@ -403,15 +403,15 @@ The acceptable values for this parameter are: - `All`: Gets all command types. This parameter value is the equivalent of `Get-Command *`. -- `Application`: Searches folders in the `$env:PATH` environment variable for non-PowerShell +- `Application`: Searches folders in the `$Env:PATH` environment variable for non-PowerShell executable files. On Windows, executable files have a file extension that is listed in the - `$env:PATHEXT` environment variable. For more information, see + `$Env:PATHEXT` environment variable. For more information, see [about_Environment_Variables](About/about_Environment_Variables.md). - `Cmdlet`: Gets all cmdlets. -- `ExternalScript`: Gets all `.ps1` files in the paths listed in the **Path** environment variable - (`$env:PATH`). +- `ExternalScript`: Gets all `.ps1` files in the paths listed in the **PATH** environment variable + (`$Env:PATH`). - `Filter` and `Function`: Gets all PowerShell advanced and simple functions and filters. diff --git a/reference/7.6/Microsoft.PowerShell.Core/Get-Help.md b/reference/7.6/Microsoft.PowerShell.Core/Get-Help.md index 710796c49a09..f3af2b7c5d60 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/Get-Help.md +++ b/reference/7.6/Microsoft.PowerShell.Core/Get-Help.md @@ -472,7 +472,7 @@ script, or workflow, such as `Get-Member`, a conceptual article name, such as `a alias, such as `ls`. Wildcard characters are permitted in cmdlet and provider names, but you can't use wildcard characters to find the names of function help and script help articles. -To get help for a script that isn't located in a path that's listed in the `$env:Path` environment +To get help for a script that isn't located in a path that's listed in the `$Env:PATH` environment variable, type the script's path and file name. If you enter the exact name of a help article, `Get-Help` displays the article contents. diff --git a/reference/7.6/Microsoft.PowerShell.Core/Get-History.md b/reference/7.6/Microsoft.PowerShell.Core/Get-History.md index d2b46e67ea9d..213a82928991 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/Get-History.md +++ b/reference/7.6/Microsoft.PowerShell.Core/Get-History.md @@ -62,7 +62,7 @@ saves it in the History.csv file. The file includes the data that is displayed w history as a list. This includes the status and start and end times of the command. ```powershell -Get-History -ID 7 -Count 5 | Export-Csv -Path History.csv +Get-History -Id 7 -Count 5 | Export-Csv -Path History.csv ``` ### Example 4: Display the most recent command diff --git a/reference/7.6/Microsoft.PowerShell.Core/Get-Job.md b/reference/7.6/Microsoft.PowerShell.Core/Get-Job.md index a0e6ae92b00c..eb9e3d5f9553 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/Get-Job.md +++ b/reference/7.6/Microsoft.PowerShell.Core/Get-Job.md @@ -95,7 +95,7 @@ Get-Job ```Output Id Name PSJobTypeName State HasMoreData Location Command -- ---- ------------- ----- ----------- -------- ------- -1 Job1 BackgroundJob Completed True localhost $env:COMPUTERNAME +1 Job1 BackgroundJob Completed True localhost $Env:COMPUTERNAME ``` ### Example 2: Stop a job by using an instance ID @@ -113,7 +113,7 @@ instance ID of the job. ```powershell $j = Get-Job -Name Job1 -$ID = $j.InstanceID +$ID = $j.InstanceId $ID ``` @@ -179,7 +179,7 @@ Get-Job -Name Job* ```Output Id Name PSJobTypeName State HasMoreData Location Command -- ---- ------------- ----- ----------- -------- ------- -1 Job1 BackgroundJob Completed True localhost $env:COMPUTERNAME +1 Job1 BackgroundJob Completed True localhost $Env:COMPUTERNAME ``` ### Example 7: Use a job object to represent the job in a command @@ -315,7 +315,7 @@ PS> Get-Job | Format-List -Property * HasMoreData : False StatusMessage : Location : localhost -Command : get-process +Command : Get-Process JobStateInfo : Failed Finished : System.Threading.ManualReset EventInstanceId : fb792295-1318-4f5d-8ac8-8a89c5261507 @@ -330,7 +330,7 @@ Debug : {} Warning : {} StateChanged : -PS> (Get-Job -Name job2).JobStateInfo.Reason +PS> (Get-Job -Name Job2).JobStateInfo.Reason Connecting to remote server using WSManCreateShellEx api failed. The async callback gave the following error message: Access is denied. ``` @@ -341,7 +341,7 @@ This example shows how to use the **Filter** parameter to get a workflow job. Th parameter, introduced in Windows PowerShell 3.0 is valid only on custom job types, such as workflow jobs and scheduled jobs. -The first command uses the **Workflow** keyword to create the WFProcess workflow. The second command +The first command uses the `workflow` keyword to create the WFProcess workflow. The second command uses the **AsJob** parameter of the WFProcess workflow to run the workflow as a background job. It uses the **JobName** parameter of the workflow to specify a name for the job, and the **PSPrivateMetadata** parameter of the workflow to specify a custom ID. The third command uses the @@ -349,7 +349,7 @@ uses the **JobName** parameter of the workflow to specify a name for the job, an **PSPrivateMetadata** parameter. ```powershell -PS> Workflow WFProcess {Get-Process} +PS> workflow WFProcess {Get-Process} PS> WFProcess -AsJob -JobName WFProcessJob -PSPrivateMetadata @{MyCustomId = 92107} PS> Get-Job -Filter @{MyCustomId = 92107} Id Name State HasMoreData Location Command diff --git a/reference/7.6/Microsoft.PowerShell.Core/Get-Module.md b/reference/7.6/Microsoft.PowerShell.Core/Get-Module.md index 9be3fa121b60..879712f7ffaa 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/Get-Module.md +++ b/reference/7.6/Microsoft.PowerShell.Core/Get-Module.md @@ -49,7 +49,7 @@ The `Get-Module` cmdlet lists the PowerShell modules that have been imported, or imported, into a PowerShell session. Without parameters, `Get-Module` gets modules that have been imported into the current session. The **ListAvailable** parameter is used to list the modules that are available to be imported from the paths specified in the **PSModulePath** environment variable -(`$env:PSModulePath`). +(`$Env:PSModulePath`). The module object that `Get-Module` returns contains valuable information about the module. You can also pipe the module objects to other cmdlets, such as the `Import-Module` and `Remove-Module` @@ -81,7 +81,7 @@ These include computers that are not running the Windows operating system, and c PowerShell but do not have PowerShell remoting enabled. Start by creating a CIM session on the remote computer. A CIM session is a connection to Windows -Management Instrumentation (WMI) on the remote computer. Then use the **CIMSession** parameter of +Management Instrumentation (WMI) on the remote computer. Then use the **CimSession** parameter of `Get-Module` to get CIM modules from the CIM session. When you import a CIM module by using the `Import-Module` cmdlet and then run the imported commands, the commands run implicitly on the remote computer. You can use this WMI and CIM strategy to manage the remote computer. @@ -105,7 +105,7 @@ Get-Module -ListAvailable This command gets the modules that are installed on the computer and can be imported into the current session. -`Get-Module` looks for available modules in the path specified by the **$env:PSModulePath** +`Get-Module` looks for available modules in the path specified by the **$Env:PSModulePath** environment variable. For more information about **PSModulePath**, see [about_Modules](About/about_Modules.md) and [about_Environment_Variables](About/about_Environment_Variables.md). @@ -249,7 +249,7 @@ information about a module, its requirements, and its contents. ```powershell # First command -$m = Get-Module -list -Name BitsTransfer +$m = Get-Module -List -Name BitsTransfer # Second command Get-Content $m.Path @@ -688,7 +688,7 @@ PowerShell includes the following aliases for `Get-Module`: [CreateDefault2 Method](/dotnet/api/system.management.automation.runspaces.initialsessionstate.createdefault2). - `Get-Module` only gets modules in locations that are stored in the value of the **PSModulePath** - environment variable (`$env:PSModulePath`). The `Import-Module` cmdlet can import modules in other + environment variable (`$Env:PSModulePath`). The `Import-Module` cmdlet can import modules in other locations, but you cannot use the `Get-Module` cmdlet to get them. - Also, starting in PowerShell 3.0, new properties have been added to the object that `Get-Module` diff --git a/reference/7.6/Microsoft.PowerShell.Core/Get-PSSession.md b/reference/7.6/Microsoft.PowerShell.Core/Get-PSSession.md index 5a3aec62baef..75b93eebbb46 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/Get-PSSession.md +++ b/reference/7.6/Microsoft.PowerShell.Core/Get-PSSession.md @@ -120,7 +120,7 @@ created in the current session. Without parameters, `Get-PSSession` gets all sessions that were created in the current session. -Use the filtering parameters, including **Name**, **ID**, **InstanceID**, **State**, +Use the filtering parameters, including **Name**, **Id**, **InstanceId**, **State**, **ApplicationName**, and **ConfigurationName** to select from among the sessions that `Get-PSSession` returns. @@ -204,8 +204,8 @@ more variables than objects, the extra variables are not used. ### Example 5: Delete a session by using an instance ID ```powershell -Get-PSSession | Format-Table -Property ComputerName, InstanceID -$s = Get-PSSession -InstanceID a786be29-a6bb-40da-80fb-782c67f7db0f +Get-PSSession | Format-Table -Property ComputerName, InstanceId +$s = Get-PSSession -InstanceId a786be29-a6bb-40da-80fb-782c67f7db0f Remove-PSSession -Session $s ``` @@ -214,10 +214,10 @@ This example shows how to get a **PSSession** by using its instance ID, and then The first command gets all of the **PSSessions** that were created in the current session. It sends the **PSSessions** to the `Format-Table` cmdlet, which displays the **ComputerName** and -**InstanceID** properties of each **PSSession**. +**InstanceId** properties of each **PSSession**. The second command uses the `Get-PSSession` cmdlet to get a particular **PSSession** and to save it -in the `$s` variable. The command uses the **InstanceID** parameter to identify the **PSSession**. +in the `$s` variable. The command uses the **InstanceId** parameter to identify the **PSSession**. The third command uses the Remove-PSSession cmdlet to delete the **PSSession** in the `$s` variable. @@ -272,7 +272,7 @@ for use. Get-PSSession -Id 2 ``` -This command gets the **PSSession** with ID `2`. Because the value of the **ID** property is unique +This command gets the **PSSession** with ID `2`. Because the value of the **Id** property is unique only in the current session, the **Id** parameter is valid only for local commands. ## PARAMETERS @@ -551,11 +551,11 @@ Accept wildcard characters: False Specifies an array of session IDs. This cmdlet gets only the sessions with the specified IDs. Type one or more IDs, separated by commas, or use the range operator (`..`) to specify a range of IDs. -You cannot use the ID parameter together with the **ComputerName** parameter. +You cannot use the **Id** parameter together with the **ComputerName** parameter. An ID is an integer that uniquely identifies the user-managed sessions in the current session. It is easier to remember and type than the **InstanceId**, but it is unique only within the current -session. The ID of a session is stored in the **ID** property of the session. +session. The ID of a session is stored in the **Id** property of the session. ```yaml Type: System.Int32[] @@ -575,9 +575,9 @@ Specifies an array of instance IDs of sessions. This cmdlet gets only the sessio specified instance IDs. The instance ID is a GUID that uniquely identifies a session on a local or remote computer. The -**InstanceID** is unique, even when you have multiple sessions running in PowerShell. +**InstanceId** is unique, even when you have multiple sessions running in PowerShell. -The instance ID of a session is stored in the **InstanceID** property of the session. +The instance ID of a session is stored in the **InstanceId** property of the session. ```yaml Type: System.Guid[] @@ -819,7 +819,7 @@ PowerShell includes the following aliases for `Get-PSSession`: computer and runs query commands in the session. - To get sessions that connect to a remote computer, use the **ComputerName** or **ConnectionUri** parameters to specify the remote computer. To filter the sessions that `Get-PSSession` gets, use - the **Name**, **ID**, **InstanceID**, and **State** parameters. Use the remaining parameters to + the **Name**, **Id**, **InstanceId**, and **State** parameters. Use the remaining parameters to configure the temporary session that `Get-PSSession` uses. - When you use the **ComputerName** or **ConnectionUri** parameters, `Get-PSSession` gets only sessions from computers running Windows PowerShell 3.0 and later versions of PowerShell.