From 1b0b1c4aee8a9f042ec511913c0cb3ba3474194a Mon Sep 17 00:00:00 2001 From: Sergey Vasin Date: Wed, 2 May 2018 03:37:06 +0300 Subject: [PATCH 1/6] Add about_CimSession.md. (#2373) * Add about_CimSession.md. * Implement requested changes. --- .../About/about_CimSession.md | 64 +++++++++++++++++++ .../About/about_CimSession.md | 64 +++++++++++++++++++ .../About/about_CimSession.md | 64 +++++++++++++++++++ .../About/about_CimSession.md | 64 +++++++++++++++++++ .../About/about_CimSession.md | 64 +++++++++++++++++++ 5 files changed, 320 insertions(+) create mode 100644 reference/3.0/Microsoft.PowerShell.Core/About/about_CimSession.md create mode 100644 reference/4.0/Microsoft.PowerShell.Core/About/about_CimSession.md create mode 100644 reference/5.0/Microsoft.PowerShell.Core/About/about_CimSession.md create mode 100644 reference/5.1/Microsoft.PowerShell.Core/About/about_CimSession.md create mode 100644 reference/6/Microsoft.PowerShell.Core/About/about_CimSession.md diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_CimSession.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_CimSession.md new file mode 100644 index 000000000000..e2c14bd72198 --- /dev/null +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_CimSession.md @@ -0,0 +1,64 @@ +--- +ms.date: 04/28/2018 +schema: 2.0.0 +locale: en-us +keywords: powershell,cmdlet +title: about_CimSession +--- + +# About CimSession + +## SHORT DESCRIPTION + +Describes a CimSession object and the difference between CIM sessions and +PowerShell sessions. + +## LONG DESCRIPTION + +A Common Information Model (CIM) session is a client-side object that +represents a connection to a local computer or a remote computer. You can +use CIM sessions as an alternative to PowerShell sessions +(PSSessions). Both approaches have advantages. + +You can use the New-CimSession cmdlet to create a CIM session that contains +information about a connection, such as computer name, the protocol used +for the connection, session ID, and instance ID. + +After you create a CimSession object that specifies information required to +establish a connection, PowerShell does not establish the +connection immediately. When a cmdlet uses the CIM session, +PowerShell connects to the specified computer, and then, when the +cmdlet finishes, PowerShell terminates the connection. + +If you create a PSSession instead of using a CIM session, +PowerShell validates connection settings, and then establishes and +maintains the connection. If you use CIM sessions, PowerShell +does not open a network connection until needed. For more information about +PowerShell sessions, see [about_PSSessions](about_PSSessions.md). + +### When to Use a CIM Session + +Only cmdlets that work with a Windows Management Instrumentation (WMI) +provider or CIM over WS-Man accept CIM sessions. +For other cmdlets, use PSSessions. + +When you use a CIM session, PowerShell runs the cmdlet on the +local client. It connects to the WMI provider by using the CIM session. +The target computer does not require PowerShell, or even any +version of the Windows operating system. + +In contrast, a cmdlet run by using a PSSession runs on the target +computer. It requires PowerShell on the target system. +Furthermore, the cmdlet sends data back to the local computer. +PowerShell manages the data sent over the connection, and keeps +the size within the limits set by Windows Remote Management (WinRM). CIM +sessions do not impose the WinRM limits. + +CIM-based Cmdlet Definition XML (CDXML) cmdlets can be written to use any +WMI Provider. All WMI providers use CimSession objects. + +## SEE ALSO + +New-CimSession + +[about_PSSessions](about_PSSessions.md) \ No newline at end of file diff --git a/reference/4.0/Microsoft.PowerShell.Core/About/about_CimSession.md b/reference/4.0/Microsoft.PowerShell.Core/About/about_CimSession.md new file mode 100644 index 000000000000..e2c14bd72198 --- /dev/null +++ b/reference/4.0/Microsoft.PowerShell.Core/About/about_CimSession.md @@ -0,0 +1,64 @@ +--- +ms.date: 04/28/2018 +schema: 2.0.0 +locale: en-us +keywords: powershell,cmdlet +title: about_CimSession +--- + +# About CimSession + +## SHORT DESCRIPTION + +Describes a CimSession object and the difference between CIM sessions and +PowerShell sessions. + +## LONG DESCRIPTION + +A Common Information Model (CIM) session is a client-side object that +represents a connection to a local computer or a remote computer. You can +use CIM sessions as an alternative to PowerShell sessions +(PSSessions). Both approaches have advantages. + +You can use the New-CimSession cmdlet to create a CIM session that contains +information about a connection, such as computer name, the protocol used +for the connection, session ID, and instance ID. + +After you create a CimSession object that specifies information required to +establish a connection, PowerShell does not establish the +connection immediately. When a cmdlet uses the CIM session, +PowerShell connects to the specified computer, and then, when the +cmdlet finishes, PowerShell terminates the connection. + +If you create a PSSession instead of using a CIM session, +PowerShell validates connection settings, and then establishes and +maintains the connection. If you use CIM sessions, PowerShell +does not open a network connection until needed. For more information about +PowerShell sessions, see [about_PSSessions](about_PSSessions.md). + +### When to Use a CIM Session + +Only cmdlets that work with a Windows Management Instrumentation (WMI) +provider or CIM over WS-Man accept CIM sessions. +For other cmdlets, use PSSessions. + +When you use a CIM session, PowerShell runs the cmdlet on the +local client. It connects to the WMI provider by using the CIM session. +The target computer does not require PowerShell, or even any +version of the Windows operating system. + +In contrast, a cmdlet run by using a PSSession runs on the target +computer. It requires PowerShell on the target system. +Furthermore, the cmdlet sends data back to the local computer. +PowerShell manages the data sent over the connection, and keeps +the size within the limits set by Windows Remote Management (WinRM). CIM +sessions do not impose the WinRM limits. + +CIM-based Cmdlet Definition XML (CDXML) cmdlets can be written to use any +WMI Provider. All WMI providers use CimSession objects. + +## SEE ALSO + +New-CimSession + +[about_PSSessions](about_PSSessions.md) \ No newline at end of file diff --git a/reference/5.0/Microsoft.PowerShell.Core/About/about_CimSession.md b/reference/5.0/Microsoft.PowerShell.Core/About/about_CimSession.md new file mode 100644 index 000000000000..e2c14bd72198 --- /dev/null +++ b/reference/5.0/Microsoft.PowerShell.Core/About/about_CimSession.md @@ -0,0 +1,64 @@ +--- +ms.date: 04/28/2018 +schema: 2.0.0 +locale: en-us +keywords: powershell,cmdlet +title: about_CimSession +--- + +# About CimSession + +## SHORT DESCRIPTION + +Describes a CimSession object and the difference between CIM sessions and +PowerShell sessions. + +## LONG DESCRIPTION + +A Common Information Model (CIM) session is a client-side object that +represents a connection to a local computer or a remote computer. You can +use CIM sessions as an alternative to PowerShell sessions +(PSSessions). Both approaches have advantages. + +You can use the New-CimSession cmdlet to create a CIM session that contains +information about a connection, such as computer name, the protocol used +for the connection, session ID, and instance ID. + +After you create a CimSession object that specifies information required to +establish a connection, PowerShell does not establish the +connection immediately. When a cmdlet uses the CIM session, +PowerShell connects to the specified computer, and then, when the +cmdlet finishes, PowerShell terminates the connection. + +If you create a PSSession instead of using a CIM session, +PowerShell validates connection settings, and then establishes and +maintains the connection. If you use CIM sessions, PowerShell +does not open a network connection until needed. For more information about +PowerShell sessions, see [about_PSSessions](about_PSSessions.md). + +### When to Use a CIM Session + +Only cmdlets that work with a Windows Management Instrumentation (WMI) +provider or CIM over WS-Man accept CIM sessions. +For other cmdlets, use PSSessions. + +When you use a CIM session, PowerShell runs the cmdlet on the +local client. It connects to the WMI provider by using the CIM session. +The target computer does not require PowerShell, or even any +version of the Windows operating system. + +In contrast, a cmdlet run by using a PSSession runs on the target +computer. It requires PowerShell on the target system. +Furthermore, the cmdlet sends data back to the local computer. +PowerShell manages the data sent over the connection, and keeps +the size within the limits set by Windows Remote Management (WinRM). CIM +sessions do not impose the WinRM limits. + +CIM-based Cmdlet Definition XML (CDXML) cmdlets can be written to use any +WMI Provider. All WMI providers use CimSession objects. + +## SEE ALSO + +New-CimSession + +[about_PSSessions](about_PSSessions.md) \ No newline at end of file diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_CimSession.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_CimSession.md new file mode 100644 index 000000000000..e2c14bd72198 --- /dev/null +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_CimSession.md @@ -0,0 +1,64 @@ +--- +ms.date: 04/28/2018 +schema: 2.0.0 +locale: en-us +keywords: powershell,cmdlet +title: about_CimSession +--- + +# About CimSession + +## SHORT DESCRIPTION + +Describes a CimSession object and the difference between CIM sessions and +PowerShell sessions. + +## LONG DESCRIPTION + +A Common Information Model (CIM) session is a client-side object that +represents a connection to a local computer or a remote computer. You can +use CIM sessions as an alternative to PowerShell sessions +(PSSessions). Both approaches have advantages. + +You can use the New-CimSession cmdlet to create a CIM session that contains +information about a connection, such as computer name, the protocol used +for the connection, session ID, and instance ID. + +After you create a CimSession object that specifies information required to +establish a connection, PowerShell does not establish the +connection immediately. When a cmdlet uses the CIM session, +PowerShell connects to the specified computer, and then, when the +cmdlet finishes, PowerShell terminates the connection. + +If you create a PSSession instead of using a CIM session, +PowerShell validates connection settings, and then establishes and +maintains the connection. If you use CIM sessions, PowerShell +does not open a network connection until needed. For more information about +PowerShell sessions, see [about_PSSessions](about_PSSessions.md). + +### When to Use a CIM Session + +Only cmdlets that work with a Windows Management Instrumentation (WMI) +provider or CIM over WS-Man accept CIM sessions. +For other cmdlets, use PSSessions. + +When you use a CIM session, PowerShell runs the cmdlet on the +local client. It connects to the WMI provider by using the CIM session. +The target computer does not require PowerShell, or even any +version of the Windows operating system. + +In contrast, a cmdlet run by using a PSSession runs on the target +computer. It requires PowerShell on the target system. +Furthermore, the cmdlet sends data back to the local computer. +PowerShell manages the data sent over the connection, and keeps +the size within the limits set by Windows Remote Management (WinRM). CIM +sessions do not impose the WinRM limits. + +CIM-based Cmdlet Definition XML (CDXML) cmdlets can be written to use any +WMI Provider. All WMI providers use CimSession objects. + +## SEE ALSO + +New-CimSession + +[about_PSSessions](about_PSSessions.md) \ No newline at end of file diff --git a/reference/6/Microsoft.PowerShell.Core/About/about_CimSession.md b/reference/6/Microsoft.PowerShell.Core/About/about_CimSession.md new file mode 100644 index 000000000000..3f472f3b9ce5 --- /dev/null +++ b/reference/6/Microsoft.PowerShell.Core/About/about_CimSession.md @@ -0,0 +1,64 @@ +--- +ms.date: 04/28/2018 +schema: 2.0.0 +locale: en-us +keywords: powershell,cmdlet +title: about_CimSession +--- + +# About CimSession + +## SHORT DESCRIPTION + +Describes a CimSession object and the difference between CIM sessions and +PowerShell sessions. + +## LONG DESCRIPTION + +A Common Information Model (CIM) session is a client-side object that +represents a connection to a local computer or a remote computer. You can +use CIM sessions as an alternative to PowerShell sessions +(PSSessions). Both approaches have advantages. + +You can use the [New-CimSession](../../CimCmdlets/New-CimSession.md) cmdlet to create a CIM session that contains +information about a connection, such as computer name, the protocol used +for the connection, session ID, and instance ID. + +After you create a CimSession object that specifies information required to +establish a connection, PowerShell does not establish the +connection immediately. When a cmdlet uses the CIM session, +PowerShell connects to the specified computer, and then, when the +cmdlet finishes, PowerShell terminates the connection. + +If you create a PSSession instead of using a CIM session, +PowerShell validates connection settings, and then establishes and +maintains the connection. If you use CIM sessions, PowerShell +does not open a network connection until needed. For more information about +PowerShell sessions, see [about_PSSessions](about_PSSessions.md). + +### When to Use a CIM Session + +Only cmdlets that work with a Windows Management Instrumentation (WMI) +provider or CIM over WS-Man accept CIM sessions. +For other cmdlets, use PSSessions. + +When you use a CIM session, PowerShell runs the cmdlet on the +local client. It connects to the WMI provider by using the CIM session. +The target computer does not require PowerShell, or even any +version of the Windows operating system. + +In contrast, a cmdlet run by using a PSSession runs on the target +computer. It requires PowerShell on the target system. +Furthermore, the cmdlet sends data back to the local computer. +PowerShell manages the data sent over the connection, and keeps +the size within the limits set by Windows Remote Management (WinRM). CIM +sessions do not impose the WinRM limits. + +CIM-based Cmdlet Definition XML (CDXML) cmdlets can be written to use any +WMI Provider. All WMI providers use CimSession objects. + +## SEE ALSO + +[New-CimSession](../../CimCmdlets/New-CimSession.md) + +[about_PSSessions](about_PSSessions.md) \ No newline at end of file From c49fdefeee3ef441e0c09a551d07f9764c1c4683 Mon Sep 17 00:00:00 2001 From: Bobby Reed Date: Wed, 2 May 2018 07:02:33 -0700 Subject: [PATCH 2/6] Batch automation: Formatting fixes (#2384) * Fixing issue with faulty links from issue (2322) * Trying smaller pull requests to test Script Automation * Testing script automation with a smaller batch of files (#2359) * Fixing issue with faulty links from issue (2322) * Trying smaller pull requests to test Script Automation * Git Batch testing 15 files (#2371) * Git Batch testing 15 files * re run automation to fix bad link replacement * Batch automation: Formatting fixes (#2372) * Batch automation: Formatting fixes * re-running automation to fix bad link replacement * Batch automation: Formatting fixes (#2377) * Batch automation: Formatting fixes * Fixing two broken links that were broken by my code * Batch automation: Formatting fixes --- .../About/about_Methods.md | 23 +++--- .../About/about_Modules.md | 26 +++---- .../About/about_Object_Creation.md | 21 +++-- .../About/about_Objects.md | 5 +- .../About/about_Operator_Precedence.md | 22 +++--- .../About/about_Operators.md | 17 ++-- .../About/about_PSSession_Details.md | 3 +- .../About/about_PSSessions.md | 3 +- .../About/about_PSSnapins.md | 17 ++-- .../About/about_Parameters.md | 15 ++-- .../About/about_Parameters_Default_Values.md | 25 +++--- .../About/about_Parsing.md | 3 +- .../About/about_Path_Syntax.md | 3 +- .../About/about_PowerShell_Ise_exe.md | 5 +- .../About/about_PowerShell_exe.md | 2 +- .../About/about_Preference_Variables.md | 77 ++++++++++--------- .../About/about_Prompts.md | 27 ++++--- .../About/about_Properties.md | 27 ++++--- .../About/about_Providers.md | 23 +++--- .../About/about_Quoting_Rules.md | 6 +- .../About/about_Redirection.md | 5 +- .../About/about_Ref.md | 7 +- .../About/about_Regular_Expressions.md | 4 +- .../About/about_pipelines.md | 11 ++- .../About/about_profiles.md | 6 +- 25 files changed, 186 insertions(+), 197 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Methods.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Methods.md index 9350c6d7358d..d567a10e3f33 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Methods.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Methods.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Methods --- - # About methods ## SHORT DESCRIPTION @@ -30,7 +29,7 @@ To get the methods of any object, use the `Get-Member` cmdlet. Use its the methods of process objects. ```powershell -PS C:\> Get-Process | Get-Member -MemberType Method +PS> Get-Process | Get-Member -MemberType Method ``` ```output @@ -68,8 +67,8 @@ takes a delimiter character argument that tells the method where to split the string. ```powershell -PS C:\> $a = "Try-Catch-Finally" -PS C:\> $a.Split("-") +PS> $a = "Try-Catch-Finally" +PS> $a.Split("-") Try Catch Finally @@ -155,15 +154,15 @@ command uses the `Get-Process` command to get all three instance of the Notepad process and save them in the \$p variable. ```powershell -PS C:\> Notepad; Notepad; Notepad -PS C:\> $p = Get-Process Notepad +PS> Notepad; Notepad; Notepad +PS> $p = Get-Process Notepad ``` The third command uses the Count property of all collections to verify that there are three processes in the \$p variable. ```powershell -PS C:\> $p.Count +PS> $p.Count 3 ``` @@ -174,18 +173,18 @@ This command works even though a collection of processes does not have a `Kill` method. ``` -PS C:\> $p.Kill() +PS> $p.Kill() ``` The fifth command uses the Get-Process command to confirm that the `Kill` command worked. ```powershell -PS C:\> Get-Process Notepad +PS> Get-Process Notepad Get-Process : Cannot find a process with the name "notepad". Verify the proc ess name and call the cmdlet again. At line:1 char:12 -+ get-process <<<< notepad ++ Get-Process <<<< notepad + CategoryInfo : ObjectNotFound: (notepad:String) [Get-Process] , ProcessCommandException + FullyQualifiedErrorId : NoProcessFoundForGivenName,Microsoft.PowerShel @@ -196,7 +195,7 @@ To perform the same task on PowerShell 2.0, use the `Foreach-Object` cmdlet to run the method on each object in the collection. ```powershell -PS C:\> $p | Foreach-Object {$_.Kill()} +PS> $p | ForEach-Object {$_.Kill()} ``` ## SEE ALSO diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Modules.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Modules.md index 46e665267afe..e96678b30d74 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Modules.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Modules.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 11/29/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Modules --- - # About Modules ## Short Description @@ -43,6 +42,7 @@ gets all commands in all installed modules, even if they are not yet in the session, so you can find a command and use it without importing. Any of the following commands will import a module into your session. + ### Run the Command ```powershell @@ -486,17 +486,17 @@ NOTE: Remote sessions, including sessions that are started by using the commands are packaged in snap-ins. The following modules (or snap-ins) are installed with PowerShell. -* Microsoft.PowerShell.Core -* Microsoft.PowerShell.Diagnostics -* Microsoft.PowerShell.Host -* Microsoft.PowerShell.Management -* Microsoft.PowerShell.Security -* Microsoft.PowerShell.Utility -* Microsoft.WSMan.Management -* PSScheduledJob -* PSWorkflow -* PSWorkflowUtility -* ISE +- Microsoft.PowerShell.Core +- Microsoft.PowerShell.Diagnostics +- Microsoft.PowerShell.Host +- Microsoft.PowerShell.Management +- Microsoft.PowerShell.Security +- Microsoft.PowerShell.Utility +- Microsoft.WSMan.Management +- PSScheduledJob +- PSWorkflow +- PSWorkflowUtility +- ISE ## Logging Module Events diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Object_Creation.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Object_Creation.md index 29c9ae7663fc..98fbf4f7799e 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Object_Creation.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Object_Creation.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 11/30/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Object_Creation --- - # About Object Creation ## SHORT DESCRIPTION @@ -43,8 +42,8 @@ ProgID of a COM object. For example, the following command creates a Version object. ```powershell -PS C:\> $v = New-Object -TypeName System.Version -ArgumentList 2.0.0.1 -PS C:\> $v +PS> $v = New-Object -TypeName System.Version -ArgumentList 2.0.0.1 +PS> $v ``` ```Output @@ -54,7 +53,7 @@ Major Minor Build Revision ``` ```powershell -PS C:\> $v | Get-Member +PS> $v | Get-Member TypeName: System.Version ``` @@ -118,7 +117,7 @@ The output of this function is a collection of custom objects formatted as a table by default. ```powershell -PS C:\> Test-Object +PS> Test-Object ModuleName UICulture Version --------- --------- ------- @@ -130,7 +129,7 @@ Users can manage the properties of the custom objects just as they do with standard objects. ```powershell -PS C:\> (Test-Object).ModuleName +PS> (Test-Object).ModuleName PSScheduledJob PSWorkflow ``` @@ -202,8 +201,8 @@ AssetID, Name, OS, Department ``` ```powershell -PS C:\> $a = Import-Csv Servers.csv -PS C:\> $a +PS> $a = Import-Csv Servers.csv +PS> $a AssetID Name OS Department ------- ---- -- ---------- @@ -215,7 +214,7 @@ AssetID Name OS Department Use the Get-Member cmdlet to confirm the object type. ```powershell -PS C:\> $a | Get-Member +PS> $a | Get-Member ``` ```Output @@ -236,7 +235,7 @@ OS NoteProperty System.String OS=Windows Server 2012 You can use the custom objects just as you would standard objects. ```powershell -PS C:\> $a | where {$_.OS -eq "Windows 8"} +PS> $a | Where-Object {$_.OS -eq "Windows 8"} ``` ```output diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Objects.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Objects.md index ad7b6fce21a8..8b992bfda1b1 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Objects.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Objects.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 11/30/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Objects --- - # About Objects ## Short Description @@ -49,7 +48,7 @@ The following example demonstrates how objects are passed from one command to the next: ```powershell -Get-ChildItem C: | where { $_.PsIsContainer -eq $false } | Format-List +Get-ChildItem C: | Where-Object { $_.PsIsContainer -eq $false } | Format-List ``` The first command `Get-ChildItem C:` returns a file or directory object diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Operator_Precedence.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Operator_Precedence.md index da59b03104b7..ad34beb99f94 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Operator_Precedence.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Operator_Precedence.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 11/30/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Operator_Precedence --- - # About Operator Precedence ## SHORT DESCRIPTION @@ -91,10 +90,10 @@ using parentheses to force PowerShell to evaluate the enclosed part of the expression first. ```powershell -C:\PS> 2 + 3 * 4 +PS> 2 + 3 * 4 14 -C:\PS> (2 + 3) * 4 +PS> (2 + 3) * 4 20 ``` @@ -102,12 +101,13 @@ The following example gets the read-only text files from the local directory and saves them in the `$read_only` variable. ```powershell -$read_only = get-childitem *.txt | where-object {$_.isReadOnly} +$read_only = Get-ChildItem *.txt | Where-Object {$_.isReadOnly} ``` + It is equivalent to the following example. ```powershell -$read_only = ( get-childitem *.txt | where-object {$_.isReadOnly} ) +$read_only = ( Get-ChildItem *.txt | Where-Object {$_.isReadOnly} ) ``` Because the pipeline operator (|) has a higher precedence than the assignment @@ -124,7 +124,7 @@ which is the first string. Finally, it casts the selected object as a string. In this case, the cast has no effect. ```powershell -C:\PS> [string]@('Windows','PowerShell','2.0')[0] +PS> [string]@('Windows','PowerShell','2.0')[0] Windows ``` @@ -134,7 +134,7 @@ before the index selection. As a result, the entire array is cast as a array, which is the first character. ```powershell -C:\PS> ([string]@('Windows','PowerShell','2.0'))[0] +PS> ([string]@('Windows','PowerShell','2.0'))[0] W ``` @@ -143,21 +143,21 @@ precedence than the -and (logical AND) operator, the result of the expression is FALSE. ```powershell -C:\PS> 2 -gt 4 -and 1 +PS> 2 -gt 4 -and 1 False ``` It is equivalent to the following expression. ```powershell -C:\PS> (2 -gt 4) -and 1 +PS> (2 -gt 4) -and 1 False ``` If the -and operator had higher precedence, the answer would be TRUE. ```powershell -C:\PS> 2 -gt (4 -and 1) +PS> 2 -gt (4 -and 1) True ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Operators.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Operators.md index ef067bf32d11..e703fca0a81a 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Operators.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Operators.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Operators --- - # About Operators ## SHORT DESCRIPTION @@ -113,7 +112,7 @@ Returns the result of one or more statements as an array. If there is only one item, the array has only one member. ```powershell -@(Get-WMIObject win32_logicalDisk) +@(Get-WmiObject win32_logicalDisk) ``` `&` Call operator @@ -209,7 +208,7 @@ $a[-1] ``` ```powershell -(get-hotfix | sort installedOn)[-1] +(Get-HotFix | Sort-Object installedOn)[-1] ``` ```powershell @@ -235,8 +234,8 @@ that follows it. When the output includes more than one object (a "collection"), the pipeline operator sends the objects one at a time. ```powershell -get-process | get-member -get-pssnapin | where {$_.vendor -ne "Microsoft"} +Get-Process | Get-Member +Get-PSSnapin | Where-Object {$_.vendor -ne "Microsoft"} ``` `.` Property dereference operator @@ -245,7 +244,7 @@ Accesses the properties and methods of an object. ```powershell $myProcess.peakWorkingSet -(get-process PowerShell).kill() +(Get-Process PowerShell).kill() ``` `..` Range operator @@ -256,7 +255,7 @@ lower boundary. ```powershell 1..10 10..1 -foreach ($a in 1..$max) {write-host $a} +foreach ($a in 1..$max) {Write-Host $a} ``` `::` Static member operator @@ -276,7 +275,7 @@ a scalar. For multiple results, returns an array. ```powershell $($x * 23) -$(Get-WMIObject win32_Directory) +$(Get-WmiObject win32_Directory) ``` ## SEE ALSO diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_PSSession_Details.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_PSSession_Details.md index ec35fe1a8f05..36c4e898444b 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_PSSession_Details.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_PSSession_Details.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_PSSession_Details --- - # About PSSession Details ## Short Description diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_PSSessions.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_PSSessions.md index 73030eed6e2f..c1debfd07619 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_PSSessions.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_PSSessions.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 01/03/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_PSSessions --- - # About PSSessions ## Short Description diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_PSSnapins.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_PSSnapins.md index 81c279d63a03..f10d5eb337c5 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_PSSnapins.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_PSSnapins.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 01/03/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_PSSnapins --- - # About PSSnapins ## SHORT DESCRIPTION @@ -41,19 +40,19 @@ in the MSDN library. To get a list of the Windows PowerShell snap-ins on your computer, type: ```powershell -get-pssnapin +Get-PSSnapin ``` To get the snap-in for each Windows PowerShell provider, type: ```powershell -get-psprovider | format-list name, pssnapin +Get-PSProvider | Format-List name, pssnapin ``` To get a list of the cmdlets in a Windows PowerShell snap-in, type: ```powershell -get-command -module +Get-Command -Module ``` ### INSTALLING A SNAP-IN @@ -79,7 +78,7 @@ To get all the registered snap-ins on your system or to verify that a snap-in is registered, type: ```powershell -get-pssnapin -registered +Get-PSSnapin -registered ``` ### ADDING THE SNAP-IN TO THE CURRENT SESSION @@ -89,7 +88,7 @@ cmdlet. For example, to add the Microsoft SQL Server snap-in to the session, type: ```powershell -add-pssnapin sql +Add-PSSnapin sql ``` After the command is completed, the providers and cmdlets in the snap-in are @@ -116,7 +115,7 @@ session configuration to the NewConsole.psc1 file in the current directory, type: ```powershell -export-console NewConsole +Export-Console NewConsole ``` For more information, see Export-Console. @@ -142,7 +141,7 @@ Remove-PsSnapin cmdlet. For example, to remove the SQL Server snap-in from the current session, type: ```powershell -remove-pssnapin sql +Remove-PSSnapin sql ``` This cmdlet removes the snap-in from the session. The snap-in is still loaded, diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Parameters.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Parameters.md index c69c6289a369..972adee38a73 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Parameters.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Parameters.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 01/03/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Parameters --- - # About Parameters ## SHORT DESCRIPTION @@ -140,10 +139,10 @@ you can use any of the following commands: ```powershell -Get-ChildItem -path c:\techdocs -exclude *.ppt -Get-ChildItem c:\techdocs -exclude *.ppt -Get-ChildItem -exclude *.ppt -path c:\techdocs -Get-ChildItem -exclude *.ppt c:\techdocs +Get-ChildItem -Path c:\techdocs -Exclude *.ppt +Get-ChildItem c:\techdocs -Exclude *.ppt +Get-ChildItem -Exclude *.ppt -Path c:\techdocs +Get-ChildItem -Exclude *.ppt c:\techdocs ``` If you were to include another positional parameter without including the @@ -178,12 +177,12 @@ For example, the ServiceName parameter of the Get-Service cmdlet accepts multiple values. The following commands are both valid: ```powershell -get-service -servicename winrm, netlogon +Get-Service -servicename winrm, netlogon ``` ```powershell $s = "winrm", "netlogon" -get-service -servicename $s +Get-Service -servicename $s ``` #### Accepts Pipeline Input? diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Parameters_Default_Values.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Parameters_Default_Values.md index fee48e6edea7..c41435058230 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Parameters_Default_Values.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Parameters_Default_Values.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 11/30/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Parameters_Default_Values --- - # About Parameters Default Values ## SHORT DESCRIPTION @@ -142,7 +141,7 @@ braces, the enclosed script block is passed to the `Invoke-Command` cmdlet. ```powershell $PSDefaultParameterValues=@{ - "Invoke-Command:ScriptBlock"={{Get-EventLog -Log System}} + "Invoke-Command:ScriptBlock"={{Get-EventLog -LogName System}} } ``` @@ -173,7 +172,7 @@ For example, the first command sets the value of \$PSDefaultParameterValues. The second command gets the value of \$PSDefaultParameterValues. ```powershell -PS C:\> $PSDefaultParameterValues = @{ +PS> $PSDefaultParameterValues = @{ "Send-MailMessage:SmtpServer"="Server01AB234x5" "Get-WinEvent:LogName"="Microsoft-Windows-PrintService/Operational" "Get-*:Verbose"=$true @@ -181,7 +180,7 @@ PS C:\> $PSDefaultParameterValues = @{ ``` ```powershell -PS C:\> $PSDefaultParameterValues +PS> $PSDefaultParameterValues Name Value ---- ----- @@ -200,7 +199,7 @@ $PSDefaultParameterValues[""] For example: ```powershell -PS C:\> $PSDefaultParameterValues["Send-MailMessage:SmtpServer"] +PS> $PSDefaultParameterValues["Send-MailMessage:SmtpServer"] Server01AB234x5 ``` @@ -241,7 +240,7 @@ $PSDefaultParameterValues.Add("Get-Process:Name", "PowerShell") The following example shows the effect of this command. ```powershell -PS C:\> $PSDefaultParameterValues +PS> $PSDefaultParameterValues Name Value ---- ----- @@ -251,11 +250,11 @@ Get*:Verbose True ``` ```powershell -PS C:\> $PSDefaultParameterValues.Add("Get-Process:Name", "PowerShell") +PS> $PSDefaultParameterValues.Add("Get-Process:Name", "PowerShell") ``` ```powershell -PS C:\> $PSDefaultParameterValues +PS> $PSDefaultParameterValues Name Value ---- ----- @@ -293,7 +292,7 @@ $PSDefaultParameterValues.Remove("Get-Process:Name") The following example shows the effect of this command. ```powershell -PS C:\> $PSDefaultParameterValues +PS> $PSDefaultParameterValues Name Value ---- ----- @@ -304,11 +303,11 @@ Get*:Verbose True ``` ```powershell -PS C:\> $PSDefaultParameterValues.Remove("Get-Process:Name") +PS> $PSDefaultParameterValues.Remove("Get-Process:Name") ``` ```powershell -PS C:\> $PSDefaultParameterValues +PS> $PSDefaultParameterValues Name Value ---- ----- @@ -377,7 +376,7 @@ The other values in \$PSDefaultParameterValues are preserved, but not effective. ```powershell -PS C:\> $PSDefaultParameterValues +PS> $PSDefaultParameterValues Name Value ---- ----- diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Parsing.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Parsing.md index 5fd8e10debf5..1e83a3c9a007 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Parsing.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Parsing.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Parsing --- - # About Parsing ## SHORT DESCRIPTION diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Path_Syntax.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Path_Syntax.md index 1ce18117d707..037d9a817f1a 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Path_Syntax.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Path_Syntax.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Path_Syntax --- - # About Path Syntax ## SHORT DESCRIPTION diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_PowerShell_Ise_exe.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_PowerShell_Ise_exe.md index 30d0834662b6..80a3daa15f17 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_PowerShell_Ise_exe.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_PowerShell_Ise_exe.md @@ -1,12 +1,12 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_PowerShell_Ise_exe --- - # About PowerShell Ise.exe + ## about_PowerShell_Ise.exe @@ -74,6 +74,7 @@ and can be used interchangeably. PS C:> PowerShell_ISE.exe PS C:> PowerShell_ISE + # PS C:>ISE diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_PowerShell_exe.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_PowerShell_exe.md index eaf5edd1ea0f..30c587a98c4b 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_PowerShell_exe.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_PowerShell_exe.md @@ -1,3 +1,4 @@ + --- ms.date: 01/03/2018 schema: 2.0.0 @@ -5,7 +6,6 @@ locale: en-us keywords: powershell,cmdlet title: about_PowerShell_exe --- - # About PowerShell.exe ## SHORT DESCRIPTION diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Preference_Variables.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Preference_Variables.md index f171a5281f94..c1c59e0dd71a 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Preference_Variables.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Preference_Variables.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 12/21/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Preference_Variables --- - # About Preference Variables ## SHORT DESCRIPTION @@ -206,6 +205,7 @@ PS> ``` #### \$DebugPreference + Determines how PowerShell responds to debugging messages generated by a script, cmdlet or provider, or by a Write-Debug command at the command line. @@ -284,15 +284,15 @@ single command. ```powershell PS> $debugpreference = "Stop" #Change the value to "Stop" -PS> write-debug "Hello, World" +PS> Write-Debug "Hello, World" DEBUG: Hello, World Write-Debug : Command execution stopped because the shell variable "Debug Preference" is set to Stop. At line:1 char:12 -+ write-debug <<<< "Hello, World" ++ Write-Debug <<<< "Hello, World" PS> # Use the Debug parameter with $false -PS> write-debug "Hello, World" -Debug:$false +PS> Write-Debug "Hello, World" -Debug:$false PS> # The debug message is not displayed and processing is not stopped. ``` @@ -378,14 +378,14 @@ PS> # Change the value of the preference. PS> $ErrorActionPreference = "SilentlyContinue" PS> # Generate an error message. -PS> write-error "Hello, World" +PS> Write-Error "Hello, World" PS> # Error message is suppressed. PS> # Use the ErrorAction parameter with a value of "Continue". -PS> write-error "Hello, World" -erroraction:continue +PS> Write-Error "Hello, World" -erroraction:continue PS> # The error message is displayed and execution continues. -write-error "Hello, World" -erroraction:continue : Hello, World +Write-Error "Hello, World" -erroraction:continue : Hello, World ``` This example shows the effect of a real error. In this case, the command gets @@ -396,24 +396,24 @@ parameter to override the preference. PS> $erroractionpreference SilentlyContinue # Display the value of the preference. -PS> get-childitem -path nofile.txt +PS> Get-ChildItem -path nofile.txt PS> # Error message is suppressed. PS> # Change the value to Continue. PS> $ErrorActionPreference = "Continue" -PS> get-childitem -path nofile.txt +PS> Get-ChildItem -path nofile.txt Get-ChildItem : Cannot find path 'C:\nofile.txt' because it does not exist. At line:1 char:4 -+ get-childitem <<<< nofile.txt ++ Get-ChildItem <<<< nofile.txt PS> # Use the ErrorAction parameter -PS> get-childitem -path nofile.txt -erroraction SilentlyContinue +PS> Get-ChildItem -path nofile.txt -erroraction SilentlyContinue PS> # Error message is suppressed. PS> # Change the value to Inquire. PS> $ErrorActionPreference = "Inquire" -PS> get-childitem -path nofile.txt +PS> Get-ChildItem -path nofile.txt Confirm Cannot find path 'C:\nofile.txt' because it does not exist. @@ -422,7 +422,7 @@ Cannot find path 'C:\nofile.txt' because it does not exist. Get-ChildItem : Cannot find path 'C:\nofile.txt' because it does not exist. At line:1 char:4 -+ get-childitem <<<< nofile.txt ++ Get-ChildItem <<<< nofile.txt PS> # Change the value to Continue. PS> $ErrorActionPreference = "Continue" @@ -465,10 +465,10 @@ non-existent file. PS> $ErrorView # Verify the value. NormalView -PS> get-childitem nofile.txt # Find a non-existent file. +PS> Get-ChildItem nofile.txt # Find a non-existent file. Get-ChildItem : Cannot find path 'C:\nofile.txt' because it does not exist. At line:1 char:14 -+ get-childitem <<<< nofile.txt ++ Get-ChildItem <<<< nofile.txt ``` This example shows how the same error appears when the value of @@ -493,7 +493,7 @@ error in the error array (element 0) and formats all of the properties of the error object in a list. ```powershell -PS> $error[0] | format-list -property * -force +PS> $error[0] | Format-List -Property * -force Exception : System.Management.Automation.ItemNotFoundException: Cannot find path 'C:\nofile.txt' because it does not exist. @@ -551,7 +551,7 @@ PS> $formatenumerationlimit # Find the current value 4 PS> # List all services grouped by status -PS> get-service | group-object -property status +PS> get-service | Group-Object -Property status Count Name Group ----- ---- ----- @@ -561,7 +561,7 @@ PS> # The list is truncated after 4 items. PS> # Increase the limit to 1000. PS> $formatenumerationlimit = 1000 -PS> get-service | group-object -property status +PS> get-service | Group-Object -Property status Count Name Group ----- ---- ----- @@ -569,7 +569,7 @@ Count Name Group 41 Stopped {Alerter, AppMgmt, aspnet_state, ATI Smart, Browser, CiSvc... PS> # Add the Wrap parameter. -PS> get-service | group-object -property status | format-table -wrap +PS> get-service | Group-Object -Property status | Format-Table -wrap Count Name Group ----- ---- ----- @@ -683,7 +683,7 @@ Default: 4096 To count the aliases on your system, type: ```powershell -(get-alias).count +(Get-Alias).count ``` #### \$MaximumDriveCount @@ -699,7 +699,7 @@ Default: 4096 To count the aliases on your system, type: ```powershell -(get-psdrive).count +(Get-PSDrive).count ``` #### \$MaximumErrorCount @@ -738,7 +738,7 @@ $Error[($Error.Count -1] To display the properties of the ErrorRecord object, type: ```powershell -$Error[0] | format-list -property * -force +$Error[0] | Format-List -Property * -force ``` In this command, the Force parameter overrides the special formatting of @@ -777,13 +777,13 @@ the Function provider, type "get-help function"). To list the functions in the current session, type: ```powershell -get-childitem function: +Get-ChildItem function: ``` To count the functions in the current session, type: ```powershell -(get-childitem function:).count +(Get-ChildItem function:).count ``` #### \$MaximumHistoryCount @@ -799,7 +799,7 @@ To determine the number of commands current saved in the command history, type: ```powershell -(get-history).count +(Get-History).count ``` To see the command saved in your session history, use the Get-History @@ -823,7 +823,7 @@ variable". To find the current number of variables on the system, type: ```powershell -(get-variable).count +(Get-Variable).count ``` #### \$OFS @@ -961,6 +961,7 @@ PS> # Set the value equal to the OutputEncoding property of the console. PS> $OutputEncoding.EncodingName OEM United States ``` + As a result of this change, the FINDSTR command finds the characters. ```powershell @@ -1306,12 +1307,12 @@ PS> Write-Warning "This action can delete data." PS> # Write a warning message. PS> # Use the WarningAction to stop when a warning is generated. -PS> Write-Warning "This step can delete data." -warningaction stop +PS> Write-Warning "This step can delete data." -WarningAction stop WARNING: This action can delete data. Write-Warning : Command execution stopped because the shell variable "WarningPreference" is set to Stop. At line:1 char:14 -+ Write-Warning <<<< "This action can delete data." -warningaction stop ++ Write-Warning <<<< "This action can delete data." -WarningAction stop ``` This example shows the effect of the Inquire value. @@ -1402,18 +1403,18 @@ PS> $whatifpreference 0 # Check the current value. PS> # Verify that the file exists. -PS> get-childitem test.txt | format-list FullName +PS> Get-ChildItem test.txt | Format-List FullName FullName : C:\test.txt PS> remove-item test.txt PS> # Delete the file. PS> # Verify that the file is deleted. -PS> get-childitem test.txt | format-list -property FullName +PS> Get-ChildItem test.txt | Format-List -Property FullName Get-ChildItem : Cannot find path 'C:\test.txt' because it does not exist. At line:1 char:14 -+ get-childitem <<<< test.txt | format-list fullname ++ Get-ChildItem <<<< test.txt | Format-List fullname ``` This example shows the effect of using the WhatIf parameter when the value @@ -1421,7 +1422,7 @@ of \$WhatIfPreference is 0. ```powershell PS> # Verify that the file exists. -PS> get-childitem test2.txt | format-list -property FullName +PS> get-childitem test2.txt | Format-List -Property FullName FullName : C:\test2.txt PS> # Use the WhatIf parameter @@ -1429,7 +1430,7 @@ PS> remove-item test2.txt -whatif What if: Performing operation "Remove File" on Target "C:\test2.txt". PS> # Verify that the file was not deleted -PS> get-childitem test2.txt | format-list -property FullName +PS> get-childitem test2.txt | Format-List -Property FullName FullName : C:\test2.txt ``` @@ -1447,7 +1448,7 @@ PS> remove-item test.txt What if: Performing operation "Remove File" on Target "C:\test.txt". PS> # Verify that the file exists. -PS> get-childitem test.txt | format-list FullName +PS> get-childitem test.txt | Format-List FullName FullName : C:\test.txt ``` @@ -1470,7 +1471,7 @@ a value of \$false. PS> # Change the value to 1. PS> $whatifpreference = 1 -PS> get-process winword +PS> Get-Process winword A Get-Process command completes. Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName @@ -1485,11 +1486,11 @@ PS> stop-process -name winword -whatif:$false PS> # WhatIf:$false overrides the preference. PS> # Verify that the process is stopped. -PS> get-process winword +PS> Get-Process winword Get-Process : Cannot find a process with the name 'winword'. Verify the process name and call the cmdlet again. At line:1 char:12 -+ get-process <<<< winword ++ Get-Process <<<< winword ``` ## SEE ALSO diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Prompts.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Prompts.md index c1e6a23471f2..ce2ef0c8cfcb 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Prompts.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Prompts.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 11/30/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Prompts --- - # About Prompts ## SHORT DESCRIPTION @@ -19,7 +18,7 @@ The PowerShell command prompt indicates that PowerShell is ready to run a command: ``` -PS C:\> +PS> ``` The PowerShell prompt is determined by the built-in Prompt function. You can @@ -46,7 +45,7 @@ For example, the following prompt function returns a "Hello, World" string followed by a caret (>). ```powershell -PS C:\> function prompt {"Hello, World > "} +PS> function prompt {"Hello, World > "} Hello, World > ``` @@ -58,7 +57,7 @@ cmdlet in the Function drive. For example: ```powershell -PS C:\> Get-Command Prompt +PS> Get-Command Prompt CommandType Name ModuleName ----------- ---- ---------- @@ -71,7 +70,7 @@ the ScriptBlock property of the Prompt function. For example: ```powershell -PS C:\> (Get-Command Prompt).ScriptBlock +PS> (Get-Command Prompt).ScriptBlock "PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPr omptLevel + 1)) " @@ -103,7 +102,7 @@ For example, the following command sets the Prompt function to $null, which is invalid. As a result, the default prompt appears. ```powershell -PS C:\> function prompt {$null} +PS> function prompt {$null} PS> ``` @@ -116,7 +115,7 @@ PowerShell includes a built-in prompt function. ```powershell function prompt { - $(if (test-path variable:/PSDebugContext) { '[DBG]: ' } + $(if (Test-Path variable:/PSDebugContext) { '[DBG]: ' } else { '' }) + 'PS ' + $(Get-Location) ` + $(if ($nestedpromptlevel -ge 1) { '>>' }) + '> ' } @@ -199,7 +198,7 @@ PS [Server01] > The following prompt function includes the current date and time: ```powershell -function prompt {"$(get-date)> "} +function prompt {"$(Get-Date)> "} ``` The prompt resembles the following prompt: @@ -219,7 +218,7 @@ function prompt { $identity = [Security.Principal.WindowsIdentity]::GetCurrent() $principal = [Security.Principal.WindowsPrincipal] $identity - $(if (test-path variable:/PSDebugContext) { '[DBG]: ' } + $(if (Test-Path variable:/PSDebugContext) { '[DBG]: ' } elseif($principal.IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { "[ADMIN]: " } else { '' } @@ -241,7 +240,7 @@ view the command history, use the `Get-History` cmdlet. ```powershell function prompt { # The at sign creates an array in case only one history item exists. - $history = @(get-history) + $history = @(Get-History) if($history.Count -gt 0) { $lastItem = $history[$history.Count - 1] @@ -249,7 +248,7 @@ function prompt { } $nextCommand = $lastId + 1 - $currentDirectory = get-location + $currentDirectory = Get-Location "PS: $nextCommand $currentDirectory >" } ``` @@ -261,8 +260,8 @@ Return statement. Without it, PowerShell uses the default prompt, "PS>". ```powershell function prompt { - $color = Get-Random -Min 1 -Max 16 - Write-Host ("PS " + $(Get-Location) +">") -NoNewLine ` + $color = Get-Random -Minimum 1 -Maximum 16 + Write-Host ("PS " + $(Get-Location) +">") -NoNewline ` -ForegroundColor $Color return " " } diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Properties.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Properties.md index f868429fc8b3..7adb1c15a0ad 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Properties.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Properties.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 12/01/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Properties --- - # About Properties ## SHORT DESCRIPTION @@ -102,7 +101,7 @@ are accessed. The `Get-ChildItem` command is followed by a dot and the name of the CreationTime property, as follows: ```powershell -C:\PS> (Get-ChildItem $pshome\PowerShell.exe).creationtime +PS> (Get-ChildItem $pshome\PowerShell.exe).creationtime Tuesday, March 18, 2008 12:07:52 AM ``` @@ -110,8 +109,8 @@ You can also save an object in a variable and then get its properties by using the dot method, as shown in the following example: ```powershell -C:\PS> $a = Get-ChildItem $pshome\PowerShell.exe -C:\PS> $a.CreationTime +PS> $a = Get-ChildItem $pshome\PowerShell.exe +PS> $a.CreationTime Tuesday, March 18, 2008 12:07:52 AM ``` @@ -125,7 +124,7 @@ For example, the following command displays the values of all the properties of the PowerShell.exe file. ```powershell -C:\PS> Get-ChildItem $pshome\PowerShell.exe | Format-List -property * +PS> Get-ChildItem $pshome\PowerShell.exe | Format-List -Property * ``` ```Output @@ -248,7 +247,7 @@ For example, each service has a DisplayName property. The following command gets the value of the DisplayName property of the Audiosrv service. ```powershell -PS C:\> (Get-Service Audiosrv).DisplayName +PS> (Get-Service Audiosrv).DisplayName Windows Audio ``` @@ -257,15 +256,15 @@ The following command tries to get the DisplayName property of all services in PowerShell 2.0. ```powershell -PS C:\> (Get-Service).DisplayName -PS C:\> +PS> (Get-Service).DisplayName +PS> ``` Beginning in PowerShell 3.0, the same command returns the value of the **DisplayName** property of every service that `Get-Service` returns. ```powershell -PS C:\> (Get-Service).DisplayName +PS> (Get-Service).DisplayName Application Experience Application Layer Gateway Service Windows All-User Install Agent @@ -278,7 +277,7 @@ Conversely, a collection of two or more services has a **Count** property, which contains the number of objects in the collection. ```powershell -PS C:\> (Get-Service).Count +PS> (Get-Service).Count 176 ``` @@ -286,14 +285,14 @@ Individual services do not have a Count or Length property, as shown in this command in PowerShell 2.0. ```powershell -PS C:\> (Get-Service Audiosrv).Count -PS C:\> +PS> (Get-Service Audiosrv).Count +PS> ``` Beginning in PowerShell 3.0, the command returns the correct Count value. ```powershell -PS C:\> (Get-Service Audiosrv).Count +PS> (Get-Service Audiosrv).Count 1 ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Providers.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Providers.md index eb657df5b593..90dc0de3f896 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Providers.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Providers.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 01/03/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Providers --- - # About Providers ## SHORT DESCRIPTION @@ -81,7 +80,7 @@ longer available in that session. To view the Windows PowerShell providers on your computer, type: ```powershell -get-psprovider +Get-PSProvider ``` The output lists the built-in providers and the providers that you added to @@ -191,7 +190,7 @@ cmdlets. Type the drive name followed by a colon (:). For example, to view the contents of the Alias: drive, type: ```powershell -get-item alias: +Get-Item alias: ``` You can view and manage the data in any drive from another drive by @@ -199,7 +198,7 @@ including the drive name in the path. For example, to view the HKLM\Software registry key in the HKLM: drive from another drive, type: ```powershell -get-childitem hklm:\software +Get-ChildItem hklm:\software ``` To open the drive, use the Set-Location cmdlet. Remember the colon @@ -207,13 +206,13 @@ when you specify the drive path. For example, to change your location to the root directory of the Cert: drive, type: ```powershell -set-location cert: +Set-Location cert: ``` Then, to view the contents of the Cert: drive, type: ```powershell -get-childitem +Get-ChildItem ``` ## MOVING THROUGH HIERARCHICAL DATA @@ -230,7 +229,7 @@ For example, to change your location to the HKLM\Software registry key, type a Set-Location command, such as: ```powershell -set-location hklm:\software +Set-Location hklm:\software ``` You can also use relative references to locations. A dot (.) represents the @@ -239,7 +238,7 @@ registry key, and you want to list the registry subkeys in the HKLM:\Software\Microsoft\PowerShell key, type the following command: ```powershell -get-childitem .\PowerShell +Get-ChildItem .\PowerShell ``` ## FINDING DYNAMIC PARAMETERS @@ -262,7 +261,7 @@ get-help For example: ```powershell -get-help certificate +Get-Help certificate ``` ## LEARNING ABOUT PROVIDERS @@ -281,13 +280,13 @@ get-help For example: ```powershell -get-help registry +Get-Help registry ``` For a list of Help topics about the providers, type: ```powershell -get-help * -category provider +Get-Help * -Category provider ``` ## SEE ALSO diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md index c7366b99753f..a67475efa242 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Quoting_Rules.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 01/03/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Quoting_Rules --- - # About Quoting Rules ## SHORT DESCRIPTION @@ -175,7 +174,7 @@ PowerShell does not recognize the escape character. Instead, it interprets the second quotation mark as the end of the string. ```output -PS C:\> 'Use a quotation mark (`') to begin a string.' +PS> 'Use a quotation mark (`') to begin a string.' Unexpected token ')' in expression or statement. At line:1 char:27 + 'Use a quotation mark (`') <<<< to begin a string.' @@ -214,6 +213,7 @@ Double-quotes: ``` Single-quotes: + ``` @' [string] ... diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Redirection.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Redirection.md index 79fc8f560417..79cbd190020e 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Redirection.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Redirection.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 12/01/2017 schema: 2.0.0 locale: en-us keywords: PowerShell,cmdlet title: about_Redirection --- - # About Redirection ## SHORT DESCRIPTION @@ -38,7 +37,7 @@ The PowerShell redirection operators use the following characters to represent each output type: ``` -* All output +- All output 1 Success output 2 Errors 3 Warning messages diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Ref.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Ref.md index 56388029b6c9..8b169d8e9c14 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Ref.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Ref.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Ref --- - # About Ref ## SHORT DESCRIPTION @@ -52,8 +51,8 @@ PS C:\ps-test> function double >> param ([ref]$x) $x.value = $x.value * 2 >> } -PS C:> $number = 8 -PS C:> $number +PS> $number = 8 +PS> $number 8 PS C> double ([ref]$number) PS C> $number diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md index 8ead15af0db0..d886c35307ab 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Regular_Expressions.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 12/01/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Regular_Expressions --- - # About Regular Expressions ## SHORT DESCRIPTION @@ -106,6 +105,7 @@ Logic: Matches any nondigit. Equivalent to \P{Nd} for Unicode and [^0-9] for non-Unicode behavior. Example: "abcd" -match "\D+" ``` + Windows PowerShell supports the quantifiers available in .NET Framework regular expressions. The following are some examples of quantifiers. diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_pipelines.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_pipelines.md index 1e43cd547d40..695d1b545b34 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_pipelines.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_pipelines.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 02/14/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_pipelines --- - # About Pipelines ## Short Description @@ -42,6 +41,7 @@ Here is a simple example. The following command gets the Notepad process and then stops it. For example, + ```powershell Get-Process notepad | Stop-Process ``` @@ -130,6 +130,7 @@ be restarted in this way). This command pipeline starts the WMI service on the computer: For example, + ```powershell Get-Service wmi | Start-Service ``` @@ -143,6 +144,7 @@ This command adds a new registry entry, NoOfEmployees, with a value of 8124, to the MyCompany registry key. For example, + ```powershell Get-Item -Path HKLM:\Software\MyCompany | New-ItemProperty -Name NoOfEmployees -Value 8124 @@ -519,14 +521,15 @@ For example, ```powershell Get-Item -Path HKLM:\software\mycompany\design | -Move-ItemProperty -Dest HKLM:\software\mycompany\sales -Name product +Move-ItemProperty -Destination HKLM:\software\mycompany\sales -Name product ``` To verify that the command worked, use a `Get-ItemProperty` command: For example, + ```powershell -Get-Itemproperty HKLM:\software\mycompany\sales +Get-ItemProperty HKLM:\software\mycompany\sales ``` The results show that the Product registry entry was moved to the Sales key. diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_profiles.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_profiles.md index 42a69462d3ce..304967e524db 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_profiles.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_profiles.md @@ -1,10 +1,9 @@ ---- +--- ms.date: 11/30/2017 schema: 2.0.0 keywords: powershell,cmdlet title: about_Profiles --- - # About Profiles ## SHORT DESCRIPTION @@ -98,7 +97,7 @@ in each PowerShell host application that you use. To see the current values of the `$Profile` variable, type: ```powershell -$profile | Get-Member -Type NoteProperty +$profile | Get-Member -MemberType NoteProperty ``` You can use the `$Profile` variable in many commands. For example, the @@ -214,6 +213,7 @@ function Pro {notepad $profile.CurrentUserAllHosts} ``` ### Add a function that opens PowerShell Help in a compiled HTML + Help file (.chm) ```powershell From 06555c75c086303796f6d86e0b2fa98ac6352356 Mon Sep 17 00:00:00 2001 From: Bobby Reed Date: Wed, 2 May 2018 07:11:31 -0700 Subject: [PATCH 3/6] Release bobbytreed b005 (#2385) * Fixing issue with faulty links from issue (2322) * Trying smaller pull requests to test Script Automation * Testing script automation with a smaller batch of files (#2359) * Fixing issue with faulty links from issue (2322) * Trying smaller pull requests to test Script Automation * Git Batch testing 15 files (#2371) * Git Batch testing 15 files * re run automation to fix bad link replacement * Batch automation: Formatting fixes (#2372) * Batch automation: Formatting fixes * re-running automation to fix bad link replacement * Batch automation: Formatting fixes (#2377) * Batch automation: Formatting fixes * Fixing two broken links that were broken by my code * Batch automation: Formatting fixes * fixing small formatting error --- .../About/about_Remote.md | 3 +- .../about_Remote_Disconnected_Sessions.md | 79 +++++++++---------- .../About/about_Remote_FAQ.md | 8 +- .../About/about_Remote_Jobs.md | 39 +++++---- .../About/about_Remote_Output.md | 26 +++--- .../About/about_Remote_Requirements.md | 3 +- .../About/about_Remote_Troubleshooting.md | 21 +++-- .../About/about_Remote_Variables.md | 5 +- .../About/about_Requires.md | 3 +- .../About/about_Reserved_Words.md | 3 +- .../About/about_Return.md | 5 +- .../About/about_Run_With_PowerShell.md | 3 +- .../About/about_Script_Blocks.md | 19 +++-- .../about_Script_Internationalization.md | 27 +++---- .../About/about_Scripts.md | 45 ++++++----- .../about_Session_Configuration_Files.md | 7 +- .../About/about_Session_Configurations.md | 25 +++--- .../About/about_Signing.md | 5 +- .../About/about_Special_Characters.md | 3 +- .../About/about_Splatting.md | 3 +- .../About/about_Split.md | 27 +++---- .../About/about_Switch.md | 6 +- .../About/about_Throw.md | 19 +++-- .../About/about_scopes.md | 31 ++++---- .../About/about_simplified_syntax.md | 3 +- 25 files changed, 195 insertions(+), 223 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote.md index 6bf622ac5323..1644d5d78bd3 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 01/03/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Remote --- - # About Remote ## SHORT DESCRIPTION diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Disconnected_Sessions.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Disconnected_Sessions.md index 396c15a85728..4cfc0f3b7e74 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Disconnected_Sessions.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Disconnected_Sessions.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 12/01/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Remote_Disconnected_Sessions --- - # About Remote Disconnected Sessions ## Short Description @@ -44,12 +43,12 @@ location. The following cmdlets support the Disconnected Sessions feature: -* `Connect-PSSession`: Connects to a disconnected PSSession -* `Disconnect-PSSession`: Disconnects a PSSession -* `Get-PSSession`: Gets PSSessions on the local computer or on remote computers -* `Receive-PSSession`: Gets the results of commands that ran in disconnected +- `Connect-PSSession`: Connects to a disconnected PSSession +- `Disconnect-PSSession`: Disconnects a PSSession +- `Get-PSSession`: Gets PSSessions on the local computer or on remote computers +- `Receive-PSSession`: Gets the results of commands that ran in disconnected sessions -* `Invoke-Command`: **InDisconnectedSession** parameter creates a PSSession and +- `Invoke-Command`: **InDisconnectedSession** parameter creates a PSSession and disconnects immediately ## How the Disconnected Sessions Feature Works @@ -113,7 +112,7 @@ The first command creates a session to the Server01 computer. The session resides on the Server01 computer. ```powershell -PS C:\> New-PSSession -ComputerName Server01 +PS> New-PSSession -ComputerName Server01 Id Name ComputerName State ConfigurationName Availability -- ---- ------------ ----- ----------------- ------------ @@ -124,7 +123,7 @@ To get the session, use the **ComputerName** parameter of `Get-PSSession` with a value of Server01. ```powershell -PS C:\> Get-PSSession -ComputerName Server01 +PS> Get-PSSession -ComputerName Server01 Id Name ComputerName State ConfigurationName Availability -- ---- ------------ ----- ----------------- ------------ @@ -137,8 +136,8 @@ maintained on the local computer. It does not get PSSessions on the Server01 computer, even if they were started on the local computer. ```powershell -PS C:\> Get-PSSession -ComputerName localhost -PS C:\> +PS> Get-PSSession -ComputerName localhost +PS> ``` To get sessions that were created in the current session, use the @@ -146,7 +145,7 @@ To get sessions that were created in the current session, use the that was created in the current session and connects to the Server01 computer. ```powershell -PS C:\> Get-PSSession +PS> Get-PSSession Id Name ComputerName State ConfigurationName Availability -- ---- ------------ ----- ----------------- ------------ @@ -164,7 +163,7 @@ Notice that the value of the State property is Disconnected and the Availability is None. ```powershell -PS C:\> Get-PSSession -ComputerName Server01 | Disconnect-PSSession +PS> Get-PSSession -ComputerName Server01 | Disconnect-PSSession Id Name ComputerName State ConfigurationName Availability -- ---- ------------ ----- ----------------- ------------ @@ -179,7 +178,7 @@ The following command runs a `Get-WinEvent` command in a disconnected session on the Server02 remote computer. ```powershell -PS C:\> Invoke-Command -ComputerName Server02 -InDisconnectedSession ` +PS> Invoke-Command -ComputerName Server02 -InDisconnectedSession ` -ScriptBlock { Get-WinEvent -LogName "Windows PowerShell" } Id Name ComputerName State ConfigurationName Availability @@ -207,7 +206,7 @@ The following command gets the sessions on the Server02 computer. The output includes two disconnected sessions, both of which are available. ```powershell -PS C:\> Get-PSSession -ComputerName Server02 +PS> Get-PSSession -ComputerName Server02 Id Name ComputerName State ConfigurationName Availability -- ---- ------------ ----- ----------------- ------------ @@ -219,7 +218,7 @@ The following command connects to Session2. The PSSession is now open and available. ```powershell -PS C:\> Connect-PSSession -ComputerName Server02 -Name Session2 +PS> Connect-PSSession -ComputerName Server02 -Name Session2 Id Name ComputerName State ConfigurationName Availability -- ---- ------------ ----- ----------------- ------------ @@ -250,7 +249,7 @@ command that ran in the Session3 session. The command uses the **OutTarget** parameter to get the results in a job. ```powershell -PS C:\> Receive-PSSession -ComputerName Server02 -Name Session3 ` +PS> Receive-PSSession -ComputerName Server02 -Name Session3 ` -OutTarget Job Id Name PSJobTypeName State HasMoreData Location @@ -261,7 +260,7 @@ Id Name PSJobTypeName State HasMoreData Location To get the results of the job, use the `Receive-Job` cmdlet. ```powershell -PS C:\> Get-Job | Receive-Job -Keep +PS> Get-Job | Receive-Job -Keep ProviderName: PowerShell @@ -299,21 +298,21 @@ reconnected. ```powershell # Session 1 -PS C:\> New-PSSession -ComputerName Server30 -Name Test +PS> New-PSSession -ComputerName Server30 -Name Test Id Name ComputerName State ConfigurationName Availability -- ---- ------------ ----- ----------------- ------------ 1 Test Server30 Opened Microsoft.PowerShell Available # Session 2 -PS C:\> Get-PSSession -ComputerName Server30 -Name Test +PS> Get-PSSession -ComputerName Server30 -Name Test Id Name ComputerName State ConfigurationName Availability -- ---- ------------ ----- ----------------- ------------ 1 Test Server30 Disconnected Microsoft.PowerShell Busy # Session 1 -PS C:\> Get-PSSession -ComputerName Server30 -Name Test | +PS> Get-PSSession -ComputerName Server30 -Name Test | >> Disconnect-PSSession Id Name ComputerName State ConfigurationName Availability @@ -321,21 +320,19 @@ Id Name ComputerName State ConfigurationName Availability 1 Test Server30 Disconnected Microsoft.PowerShell None # Session 2 -PS C:\> Get-PSSession -ComputerName Server30 +PS> Get-PSSession -ComputerName Server30 Id Name ComputerName State ConfigurationName Availability -- ---- ------------ ----- ----------------- ------------ 1 Test Server30 Disconnected Microsoft.PowerShell None # Session 2 -PS C:\> Connect-PSSession -ComputerName Server01 -Name Test +PS> Connect-PSSession -ComputerName Server01 -Name Test Id Name ComputerName State ConfigurationName Availability -- ---- ------------ ----- ----------------- ------------ -3 Test Server30 Opened Microsoft.PowerShell Available - -# Session 1 -PS C:\> Get-PSSession -ComputerName Server30 +3 Test Server30 Opened Microsoft.PowerShell Available# Session 1 +PS> Get-PSSession -ComputerName Server30 Id Name ComputerName State ConfigurationName Availability -- ---- ------------ ----- ----------------- ------------ @@ -398,7 +395,7 @@ in SessionOption object and the IdleTimeout value in the $PSSessionOption preference variable do not change the value of the IdleTimeout of the PSSession in a `Connect-PSSession` or `Receive-PSSession` command. -* To create a PSSession with a particular idle timeout value, create +- To create a PSSession with a particular idle timeout value, create a $PSSessionOption preference variable. Set the value of the IdleTimeout property to the desired value (in milliseconds). @@ -411,7 +408,7 @@ PSSession in a `Connect-PSSession` or `Receive-PSSession` command. $PSSessionOption = New-PSSessionOption -IdleTimeoutMSec 172800000 ``` -* To create a PSSession with a particular idle timeout value, use +- To create a PSSession with a particular idle timeout value, use the **IdleTimeoutMSec** parameter of the `New-PSSessionOption` cmdlet. Then, use the session option in the value of the **SessionOption** parameter of the `New-PSSession` or `Invoke-Command` cmdlets. @@ -427,7 +424,7 @@ $o = New-PSSessionOption -IdleTimeoutMSec 172800000 New-PSSession -SessionOption $o ``` -* To change a the idle timeout of a PSSession when disconnecting, +- To change a the idle timeout of a PSSession when disconnecting, use the **IdleTimeoutSec** parameter of the `Disconnect-PSSession` cmdlet. @@ -437,7 +434,7 @@ New-PSSession -SessionOption $o Disconnect-PSSession -IdleTimeoutSec 172800 ``` -* To create a session configuration with a particular idle timeout +- To create a session configuration with a particular idle timeout and maximum idle timeout, use the **IdleTimeoutSec** and **MaxIdleTimeoutSec** parameters of the `New-PSTransportOption` cmdlet. Then, use the transport option in the value of the **TransportOption** parameter @@ -450,7 +447,7 @@ $o = New-PSTransportOption -IdleTimeoutSec 172800 -MaxIdleTimeoutSec 259200 Register-PSSessionConfiguration -Name Test -TransportOption $o ``` -* To change the default idle timeout and maximum idle timeout of +- To change the default idle timeout and maximum idle timeout of a session configuration, use the **IdleTimeoutSec** and **MaxIdleTimeoutSec** parameters of the `New-PSTransportOption` cmdlet. Then, use the transport option in the value of the **TransportOption** parameter @@ -473,12 +470,12 @@ whether the command continues to run while the session is disconnected. Valid values: -* Block +- Block When the output buffer is full, execution is suspended until the buffer is clear. -* Drop +- Drop When the output buffer is full, execution continues. As new output is generated, the oldest output is discarded. @@ -513,7 +510,7 @@ If you are a member of the Administrators group on the remote computer, you can also create and change the output buffering mode of session configurations. -* To create a PSSession with an output buffering mode of Drop, create +- To create a PSSession with an output buffering mode of Drop, create a $PSSessionOption preference variable in which the value of the OutputBufferingMode property is Drop. @@ -526,7 +523,7 @@ configurations. $PSSessionOption = New-PSSessionOption -OutputBufferingMode Drop ``` -* To create a PSSession with an output buffering mode of Drop, use +- To create a PSSession with an output buffering mode of Drop, use the **OutputBufferingMode** parameter of the `New-PSSessionOption` cmdlet to create a session option with a value of Drop. Then, use the session option in the value of the **SessionOption** parameter of @@ -543,7 +540,7 @@ $o = New-PSSessionOption -OutputBufferingMode Drop New-PSSession -SessionOption $o ``` -* To change a the output buffering mode of a PSSession when +- To change a the output buffering mode of a PSSession when disconnecting, use the **OutputBufferingMode** parameter of the `Disconnect-PSSession` cmdlet. @@ -553,7 +550,7 @@ New-PSSession -SessionOption $o Disconnect-PSSession -OutputBufferingMode Drop ``` -* To change a the output buffering mode of a PSSession when +- To change a the output buffering mode of a PSSession when reconnecting, use the **OutputBufferingMode** parameter of the `New-PSSessionOption` cmdlet to create a session option with a value of Drop. Then, use the session option in the value of the @@ -563,10 +560,10 @@ Disconnect-PSSession -OutputBufferingMode Drop ```powershell $o = New-PSSessionOption -OutputBufferingMode Drop -Connect-PSSession -Cn Server01 -Name Test -SessionOption $o +Connect-PSSession -ComputerName Server01 -Name Test -SessionOption $o ``` -* To create a session configuration with a default output buffering +- To create a session configuration with a default output buffering mode of Drop, use the **OutputBufferingMode** parameter of the `New-PSTransportOption` cmdlet to create a transport option object with a value of Drop. Then, use the transport option in the value of @@ -579,7 +576,7 @@ $o = New-PSTransportOption -OutputBufferingMode Drop Register-PSSessionConfiguration -Name Test -TransportOption $o ``` -* To change the default output buffering mode of a session +- To change the default output buffering mode of a session configuration, use the **OutputBufferingMode** parameter of the `New-PSTransportOption` cmdlet to create a transport option with a value of Drop. Then, use the Transport option in the value of the diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_FAQ.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_FAQ.md index dd14949a0e16..e140b759fa74 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_FAQ.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_FAQ.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 12/01/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Remote_FAQ --- - # About Remote FAQ ## SHORT DESCRIPTION @@ -53,7 +52,7 @@ session on the local computer. To transmit the commands and receive the output, Windows PowerShell uses the WS-Management protocol. For information about the WS-Management protocol, see -[WS-Management Protocol](http://go.microsoft.com\/fwlink/?LinkId=144634) in +[WS-Management Protocol](http://go.microsoft.com/fwlink/?LinkId=144634) in the MSDN library. Beginning in Windows PowerShell 3.0, remote sessions are stored on the remote @@ -468,7 +467,8 @@ changes. You can use the following Windows PowerShell command to add this entry: - ```powershell + +```powershell $parameters = @{ Path='HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' Name='LocalAccountTokenFilterPolicy' diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md index 36f61eac5bfe..808c1008fd5c 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Jobs.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 12/01/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Remote_Jobs --- - # About Remote Jobs ## SHORT DESCRIPTION @@ -65,7 +64,7 @@ session (PSSession). The following command starts an interactive session on the Server01 computer. ```powershell -C:\PS> Enter-PSSession -computername Server01 +PS> Enter-PSSession -computername Server01 ``` The command prompt changes to show that you are now connected to the Server01 @@ -87,7 +86,7 @@ This command saves the job object in the \$job variable. ```powershell Server01\C:> $job = start-job -scriptblock { - get-eventlog "Windows PowerShell" + Get-EventLog "Windows PowerShell" } ``` @@ -134,7 +133,7 @@ computer. ```powershell Server01\C:> Exit-PSSession -C:\PS> +PS> ``` #### STEP 6: INVOKE-COMMAND: GET-CONTENT @@ -151,9 +150,9 @@ to run a Get-Content command in the PSSession to view the contents of the file. ```powershell -$s = new-pssession -computername Server01 -invoke-command -session $s -scriptblock { - get-content c:\logs\pslog.txt} +$s = New-PSSession -ComputerName Server01 +Invoke-Command -Session $s -ScriptBlock { + Get-Content c:\logs\pslog.txt} ``` ### START A REMOTE JOB THAT RETURNS THE RESULTS TO THE LOCAL COMPUTER \(ASJOB\) @@ -180,8 +179,8 @@ that gets the events in the System log. You can use the JobName parameter to assign a display name to the job. ```powershell -invoke-command -computername Server01 -scriptblock { - get-eventlog system} -asjob +Invoke-Command -ComputerName Server01 -ScriptBlock { + Get-EventLog system} -asjob ``` The results of the command resemble the following sample output. @@ -210,7 +209,7 @@ To determine whether the job is complete, use a Get-Job command. The following command gets all of the jobs that were started in the current session. ```powershell -get-job +Get-Job ``` Because the remote job was started in the current session, a local Get-Job @@ -234,7 +233,7 @@ job. It uses the session ID to identify the job. This command saves the job results in the $results variable. You can also redirect the results to a file. ```powershell -$results = receive-job -id 1 +$results = Receive-Job -Id 1 ``` ### START A REMOTE JOB THAT KEEPS THE RESULTS ON THE REMOTE COMPUTER @@ -264,7 +263,7 @@ is connected to the Server01 computer. The command saves the PSSession in the \$s variable. ```powershell -$s = new-pssession -computername Server01 +$s = New-PSSession -ComputerName Server01 ``` The next command uses the Invoke-Command cmdlet to run a Start-Job command in @@ -272,8 +271,8 @@ the PSSession. The Start-Job command and the Get-Eventlog command are enclosed in braces. ```powershell -invoke-command -session $s -scriptblock { - start-job -scriptblock {get-eventlog system}} +Invoke-Command -Session $s -ScriptBlock { + Start-Job -ScriptBlock {Get-EventLog system}} ``` The results resemble the following sample output. @@ -303,7 +302,7 @@ To see if the job is complete, use an Invoke-Command command to run a Get-Job command in the PSSession that is connected to the Server01 computer. ```powershell -invoke-command -session $s -scriptblock {get-job} +Invoke-Command -Session $s -ScriptBlock {Get-Job} ``` The command returns a job object. The State property of the job object shows @@ -327,8 +326,8 @@ results in the \$results variable. It uses the Keep parameter of Receive-Job to keep the result in the job cache on the remote computer. ```powershell -$results = invoke-command -session $s -scriptblock { - receive-job -sessionid 2 -keep} +$results = Invoke-Command -Session $s -ScriptBlock { + Receive-Job -sessionid 2 -keep} ``` You can also redirect the results to a file on the local or remote computer. @@ -336,8 +335,8 @@ The following command uses a redirection operator to save the results in a file on the Server01 computer. ```powershell -invoke-command -session $s -command { - receive-job -sessionid 2 > c:\logs\pslog.txt} +Invoke-Command -Session $s -ScriptBlock { + Receive-Job -sessionid 2 > c:\logs\pslog.txt} ``` ## SEE ALSO diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Output.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Output.md index 0d11ff6ea68d..331fec4403bf 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Output.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Output.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 12/01/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Remote_Output --- - # About Remote Output # SHORT DESCRIPTION @@ -35,7 +34,7 @@ below, includes the names of the remote computers on which the command ran. ```powershell -C:\PS> invoke-command -script {get-culture} -comp Server01, Server02 +PS> invoke-command -script {Get-Culture} -comp Server01, Server02 LCID Name DisplayName PSComputerName ---- ---- ----------- -------------- @@ -52,7 +51,7 @@ remote computer. It uses the HideComputerName parameter to hide the PSComputerName property and related properties. ```powershell -C:\PS> invoke-command -scr {get-culture} -comp Server01 -HideComputerName +PS> invoke-command -scr {Get-Culture} -comp Server01 -HideComputerName LCID Name DisplayName ---- ---- ----------- @@ -66,9 +65,8 @@ For example, the following commands use the Format-Table cmdlet to add the PSComputerName property to the output of a remote Get-Date command. ```powershell -$dates = invoke-command -script {get-date} -computername Server01, Server02 -$dates | format-table DateTime, PSComputerName -auto - +$dates = Invoke-Command -ScriptBlock {Get-Date} -ComputerName Server01, Server02 +$dates | Format-Table DateTime, PSComputerName -AutoSize DateTime PSComputerName -------- -------------- Monday, July 21, 2008 7:16:58 PM Server01 @@ -92,7 +90,7 @@ Server02 remote computers. The default display does not include the MachineName property. ```powershell -C:\PS> get-process PowerShell -computername server01, server02 +PS> get-process PowerShell -computername server01, server02 Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- @@ -110,9 +108,8 @@ Format-Table command. The command uses the Property parameter of Format-Table to include the MachineName property in the display. ```powershell -C:\PS> $p = get-process PowerShell -comp Server01, Server02 -C:\PS> $P | format-table -property ID, ProcessName, MachineName -auto - +PS> $p = get-process PowerShell -comp Server01, Server02 +PS> $P | Format-Table -Property ID, ProcessName, MachineName -AutoSize Id ProcessName MachineName -- ----------- ----------- 2648 PowerShell Server02 @@ -127,16 +124,15 @@ properties. Fortunately, you do not have to understand it to use it. (Note that the backtick [`] is the continuation character.) ```powershell -C:\PS> $p = get-process PowerShell -comp Server01, Server02 +PS> $p = get-process PowerShell -comp Server01, Server02 -C:\PS> $p | format-table -property Handles, ` +PS> $p | Format-Table -Property Handles, ` @{Label="NPM(K)";Expression={int}}, ` @{Label="PM(K)";Expression={int}}, ` @{Label="WS(K)";Expression={int}}, ` @{Label="VM(M)";Expression={int}}, ` @{Label="CPU(s)";Expression={if ($.CPU -ne $()){ $.CPU.ToString("N")}}}, ` -Id, ProcessName, MachineName -auto - +Id, ProcessName, MachineName -AutoSize Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName MachineName ------- ------ ----- ----- ----- ------ -- ----------- ----------- 920 38 97560 114532 576 2648 PowerShell Server02 diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md index 07d053a421a9..1511809979b8 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Requirements.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 01/03/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Remote_Requirements --- - # About Remote Requirements ## SHORT DESCRIPTION diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md index 38c89c13fe51..b77c6beedb70 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Troubleshooting.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 12/01/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Remote_Troubleshooting --- - # About Remote Troubleshooting ## SHORT DESCRIPTION @@ -220,8 +219,8 @@ Servers.txt file and then sets the startup type of the WinRM service on all of the computers to Automatic. ```powershell -C:\PS> $servers = Get-Content servers.txt -C:\PS> Set-Service WinRM -ComputerName $servers -startuptype Automatic +PS> $servers = Get-Content servers.txt +PS> Set-Service WinRM -ComputerName $servers -startuptype Automatic ``` To see the results use the Get-WMIObject cmdlet with the Win32_Service object. @@ -339,7 +338,7 @@ To change the policy, use the following command to set the value of the LocalAccountTokenFilterPolicy registry entry to 1. ```powershell -C:\PS> New-ItemProperty -Name LocalAccountTokenFilterPolicy -Path ` +PS> New-ItemProperty -Name LocalAccountTokenFilterPolicy -Path ` HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System ` -PropertyType DWord -Value 1 ``` @@ -555,10 +554,10 @@ For example, the following command creates a session option object with proxy session options and then uses the object to create a remote session. ```powershell -C:\PS> $SessionOption = New-PSSessionOption -ProxyAccessType IEConfig ` +PS> $SessionOption = New-PSSessionOption -ProxyAccessType IEConfig ` -ProxyAuthentication Negotiate -ProxyCredential Domain01\User01 -C:\PS> New-PSSession -ConnectionURI https://www.fabrikam.com +PS> New-PSSession -ConnectionURI https://www.fabrikam.com ``` For more information about the New-PSSessionOption cmdlet, see @@ -597,8 +596,8 @@ following command finds the processor architecture of the session in the \$s variable. ```powershell -$s = New-PSSession -ComputerName Server01 -configurationName CustomShell -invoke-command -session $s {$env:PROCESSOR_ARCHITECTURE} +$s = New-PSSession -ComputerName Server01 -ConfigurationName CustomShell +Invoke-Command -Session $s {$env:PROCESSOR_ARCHITECTURE} x86 ``` @@ -732,9 +731,9 @@ create a session option object with an OperationTimeout value of 4 minutes (in MS) and then use the session option object to create a remote session. ```powershell -C:\PS> $pso = New-PSSessionoption -OperationTimeout 240000 +PS> $pso = New-PSSessionoption -OperationTimeout 240000 -C:\PS> New-PSSession -ComputerName Server01 -sessionOption $pso +PS> New-PSSession -ComputerName Server01 -sessionOption $pso ``` For more information about the WS-Management timeouts, see the Help topic for diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Variables.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Variables.md index 45660395783e..cb22996109e9 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Variables.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Remote_Variables.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 01/03/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Remote_Variables --- - # About Remote Variables ## SHORT DESCRIPTION @@ -105,7 +104,7 @@ parameter name and the local variable, $ps, as its value. $ps = "Windows PowerShell" Invoke-Command -ComputerName S1 -ScriptBlock { param($log) - Get-WinEvent -logname $log + Get-WinEvent -LogName $log } -ArgumentList $ps ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Requires.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Requires.md index 8b17b445cbaf..d896ba8c7de7 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Requires.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Requires.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 01/03/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Requires --- - # About Requires ## SHORT DESCRIPTION diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Reserved_Words.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Reserved_Words.md index 46ba31199105..26c6b46d2913 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Reserved_Words.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Reserved_Words.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Reserved_Words --- - # About Reserved Words ## SHORT DESCRIPTION diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Return.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Return.md index 15fd437fe0a9..2ec83cbd52e3 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Return.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Return.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 01/03/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Return --- - # About Return ## SHORT DESCRIPTION @@ -102,7 +101,7 @@ The "Please wait. Working on calculation..." string is not displayed. Instead, it is assigned to the $a variable, as in the following example: ```output -C:\PS> $a +PS> $a Please wait. Working on calculation... 87 ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Run_With_PowerShell.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Run_With_PowerShell.md index db84fc679557..a0f94acd3f21 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Run_With_PowerShell.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Run_With_PowerShell.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 01/03/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Run_With_PowerShell --- - # About Run With PowerShell ## SHORT DESCRIPTION diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Script_Blocks.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Script_Blocks.md index 7d2d38616340..29de61703e3b 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Script_Blocks.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Script_Blocks.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Script_Blocks --- - # About Script Blocks ## SHORT DESCRIPTION @@ -55,7 +54,7 @@ block parameter values. For example, the `Invoke-Command` cmdlet has a example: ```powershell -PS C:\> Invoke-Command -ScriptBlock { Get-Process } +PS> Invoke-Command -ScriptBlock { Get-Process } Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- @@ -68,7 +67,7 @@ The script block that is used as a value can be more complicated, as shown in the following example: ```powershell -PS C:\> Invoke-Command -ScriptBlock { Param($uu = "Parameter"); +PS> Invoke-Command -ScriptBlock { Param($uu = "Parameter"); "$uu assigned." } Parameter assigned. ``` @@ -79,7 +78,7 @@ the **Args** parameter of the `Invoke-Command` cmdlet to assign a different value to the parameter: ```powershell -PS C:\> Invoke-Command -ScriptBlock { Param($uu = "Parameter"); +PS> Invoke-Command -ScriptBlock { Param($uu = "Parameter"); "$uu assigned."} -Args "Other value" Other value assigned. ``` @@ -95,7 +94,7 @@ You can use the variable with a cmdlet such as `Invoke-Command`, as shown in the following example: ```powershell -PS C:\> Invoke-Command -ScriptBlock $a -Args "Other value" +PS> Invoke-Command -ScriptBlock $a -Args "Other value" Other value assigned. ``` @@ -103,7 +102,7 @@ You can run a script block that is assigned to a variable by using the call operator (&), as shown in the following example: ```powershell -PS C:\> & $a +PS> & $a Parameter assigned. ``` @@ -111,7 +110,7 @@ You can also provide a parameter to the script block, as shown in the following example: ```powershell -PS C:\> & $a "Other value" +PS> & $a "Other value" Other value assigned. ``` @@ -120,8 +119,8 @@ variable, use the call operator to run the script block directly, as shown in the following example: ```powershell -PS C:\> $a = & { Param($uu = "Parameter"); "$uu assigned." } -PS C:\> $a +PS> $a = & { Param($uu = "Parameter"); "$uu assigned." } +PS> $a Parameter assigned. ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Script_Internationalization.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Script_Internationalization.md index 387fb3593652..24316977e109 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Script_Internationalization.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Script_Internationalization.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 01/03/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Script_Internationalization --- - # About Script Internationalization ## Short Description @@ -30,24 +29,24 @@ tables to facilitate translation. To support international Help text, Windows PowerShell includes the following features: -* A Data section that separates text strings from code instructions. For more +- A Data section that separates text strings from code instructions. For more information about the Data section, see [aout_Data_Sections](about_Data_Sections.md). -* New automatic variables, \$PSCulture and \$PSUICulture. \$PSCulture stores the +- New automatic variables, \$PSCulture and \$PSUICulture. \$PSCulture stores the name of the UI language used on the system for elements such as the date, time, and currency. The $PSUICulture variable stores the name of the UI language used on the system for user interface elements such as menus and text strings. -* A cmdlet, `ConvertFrom-StringData`, that converts text strings into +- A cmdlet, `ConvertFrom-StringData`, that converts text strings into dictionary-like hash tables to facilitate translation. For more information, see [ConvertFrom-StringData](../../Microsoft.PowerShell.Utility/ConvertFrom-StringData.md). -* A new file type, .psd1, that stores translated text strings. The .psd1 files +- A new file type, .psd1, that stores translated text strings. The .psd1 files are stored in language-specific subdirectories of the script directory. -* A cmdlet, `Import-LocalizedData`, that imports translated text strings for a +- A cmdlet, `Import-LocalizedData`, that imports translated text strings for a specified language into a script at runtime. This cmdlet recognizes and imports strings in any Windows-supported language. For more information see [Import-LocalizedData](../../Microsoft.PowerShell.Utility/Import-LocalizedData.md). @@ -211,7 +210,7 @@ $a = $Day.d0, $Day.d1, $Day.d2, $Day.d3, $Day.d4, $Day.d5, $Day.d6 # Index into $a to get the name of the day. # Use string formatting to build a sentence. -"{0} {1}" -f $Day.messageDate, $a[(Get-Date -uformat %u)] | Out-Host +"{0} {1}" -f $Day.messageDate, $a[(Get-Date -UFormat %u)] | Out-Host ``` The .psd1 files that support the script are saved in subdirectories of @@ -242,9 +241,9 @@ Today is Friday (in German) ## See also -* [about_Data_Sections](about_Data_Sections.md) -* [about_Automatic_Variables](about_Automatic_Variables.md) -* [about_Hash_Tables](about_Hash_Tables.md) -* [about_Quoting_Rules](about_Quoting_Rules.md) -* [ConvertFrom-StringData](../../Microsoft.PowerShell.Utility/ConvertFrom-StringData.md) -* [Import-LocalizedData](../../Microsoft.PowerShell.Utility/Import-LocalizedData.md) \ No newline at end of file +- [about_Data_Sections](about_Data_Sections.md) +- [about_Automatic_Variables](about_Automatic_Variables.md) +- [about_Hash_Tables](about_Hash_Tables.md) +- [about_Quoting_Rules](about_Quoting_Rules.md) +- [ConvertFrom-StringData](../../Microsoft.PowerShell.Utility/ConvertFrom-StringData.md) +- [Import-LocalizedData](../../Microsoft.PowerShell.Utility/Import-LocalizedData.md) \ No newline at end of file diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Scripts.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Scripts.md index 50140030130b..c5f8fc04d517 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Scripts.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Scripts.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 12/01/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Scripts --- - # About Scripts ## SHORT DESCRIPTION @@ -133,7 +132,7 @@ path is in your Path environment variable, you can omit the path. For example, to get help for the ServicesLog.ps1 script, type: ```powershell -get-help C:\admin\scripts\ServicesLog.ps1 +Get-Help C:\admin\scripts\ServicesLog.ps1 ``` ### HOW TO WRITE A SCRIPT @@ -152,8 +151,8 @@ running on the current system and saves them to a log file. The log file name is created from the current date. ```powershell -$date = (get-date).dayofyear -get-service | out-file "$date.log" +$date = (Get-Date).dayofyear +Get-Service | Out-File "$date.log" ``` To create this script, open a text editor or a script editor, type these @@ -182,21 +181,21 @@ param ($ComputerName = $(throw "ComputerName parameter is required.")) function CanPing { $error.clear() - $tmp = test-connection $computername -erroraction SilentlyContinue + $tmp = Test-Connection $computername -ErrorAction SilentlyContinue if (!$?) - {write-host "Ping failed: $ComputerName."; return $false} + {Write-Host "Ping failed: $ComputerName."; return $false} else - {write-host "Ping succeeded: $ComputerName"; return $true} + {Write-Host "Ping succeeded: $ComputerName"; return $true} } function CanRemote { - $s = new-pssession $computername -erroraction SilentlyContinue + $s = New-PSSession $computername -ErrorAction SilentlyContinue if ($s -is [System.Management.Automation.Runspaces.PSSession]) - {write-host "Remote test succeeded: $ComputerName."} + {Write-Host "Remote test succeeded: $ComputerName."} else - {write-host "Remote test failed: $ComputerName."} + {Write-Host "Remote test failed: $ComputerName."} } if (CanPing $computername) {CanRemote $computername} @@ -205,7 +204,7 @@ if (CanPing $computername) {CanRemote $computername} To run this script, type the parameter name after the script name. For example: ```powershell -C:\PS> .\test-remote.ps1 -computername Server01 +PS> .\test-remote.ps1 -computername Server01 Ping succeeded: Server01 Remote test failed: Server01 @@ -281,12 +280,12 @@ and the $ProfileName variable. function New-Profile { Write-Host "Running New-Profile function" - $profileName = split-path $profile -leaf + $profileName = Split-Path $profile -leaf - if (test-path $profile) - {write-error "Profile $profileName already exists on this computer."} + if (Test-Path $profile) + {Write-Error "Profile $profileName already exists on this computer."} else - {new-item -type file -path $profile -force } + {New-Item -type file -Path $profile -Force } } ``` @@ -296,9 +295,9 @@ is running. When the script exits, the function and variable are removed, as shown in the following example. ```powershell -C:\PS> .\UtilityFunctions.ps1 +PS> .\UtilityFunctions.ps1 -C:\PS> New-Profile +PS> New-Profile The term 'new-profile' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again. At line:1 char:12 @@ -306,8 +305,8 @@ At line:1 char:12 + CategoryInfo : ObjectNotFound: (new-profile:String) [], + FullyQualifiedErrorId : CommandNotFoundException -C:\PS> $profileName -C:\PS> +PS> $profileName +PS> ``` When you dot source the script and run it, the script creates the New-Profile @@ -316,9 +315,9 @@ the script runs, you can use the New-Profile function in your session, as shown in the following example. ```powershell -C:\PS> . .\UtilityFunctions.ps1 +PS> . .\UtilityFunctions.ps1 -C:\PS> New-Profile +PS> New-Profile Directory: C:\Users\juneb\Documents\WindowsPowerShell @@ -326,7 +325,7 @@ C:\PS> New-Profile ---- ------------- ------ ---- -a--- 1/14/2009 3:08 PM 0 Microsoft.PowerShellISE_profile.ps1 -C:\PS> $profileName +PS> $profileName Microsoft.PowerShellISE_profile.ps1 ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Session_Configuration_Files.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Session_Configuration_Files.md index 24b56e3f814b..b324286083a8 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Session_Configuration_Files.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Session_Configuration_Files.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 01/03/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Session_Configuration_Files --- - # About Session Configuration Files ## SHORT DESCRIPTION @@ -354,7 +353,7 @@ session configurations. ```powershell Get-PSSessionConfiguration | -where {$_.ExecutionPolicy -eq "RemoteSigned"} +Where-Object {$_.ExecutionPolicy -eq "RemoteSigned"} ``` The following command gets session configurations in which the RunAsUser is @@ -362,7 +361,7 @@ the Exchange administrator. ```powershell Get-PSSessionConfiguration | -where {$_.RunAsUser -eq "Exchange01\Admin01"} +Where-Object {$_.RunAsUser -eq "Exchange01\Admin01"} ``` To view information about the role definitions associated with a configuration diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Session_Configurations.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Session_Configurations.md index c902878e0c6f..67f1eb6f2b5b 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Session_Configurations.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Session_Configurations.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 12/091/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Session_Configurations --- - # About Session Configurations ## SHORT DESCRIPTION @@ -102,7 +101,7 @@ Get-PSSessionConfiguration cmdlet. For example, type: ```powershell -PS C:> Get-PSSessionConfiguration | Format-List -Property Name, Permission +PS> Get-PSSessionConfiguration | Format-List -Property Name, Permission Name : microsoft.powershell Permission : BUILTIN\Administrators AccessAllowed @@ -122,7 +121,7 @@ For example, to see all of the properties of a session configuration object, type: ```powershell -PS C:> Get-PSSessionConfiguration | Format-List -Property * +PS> Get-PSSessionConfiguration | Format-List -Property * ``` You can also use the WSMan provider in PowerShell to view session @@ -136,7 +135,7 @@ For example, to view the session configurations on the local computer, type: ```powershell -PS C:> dir wsman:\localhost\plugin\microsoft* +PS> dir wsman:\localhost\plugin\microsoft* WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Plugin @@ -157,7 +156,7 @@ For example, the following command adds a node for the Server01 remote computer to the WSMAN: drive on the local computer. ```powershell -PS C:> Connect-WSMan server01.corp.fabrikam.com +PS> Connect-WSMan server01.corp.fabrikam.com ``` When the command is complete, you can navigate to the node for the Server01 @@ -166,7 +165,7 @@ computer to view the session configurations. For example: ```powershell -PS C:> cd wsman: +PS> cd wsman: PS WSMan:> dir @@ -212,7 +211,7 @@ the security descriptor for the Microsoft.PowerShell default session configuration. ```powershell -Set-PSSessionConfiguration -name Microsoft.PowerShell ` +Set-PSSessionConfiguration -Name Microsoft.PowerShell ` -ShowSecurityDescriptorUI ``` @@ -221,7 +220,7 @@ use the Disable-PSSessionConfiguration cmdlet. For example, the following command disables the default session configurations on the computer. ```powershell -PS C:> Disable-PSSessionConfiguration -Name Microsoft.PowerShell +PS> Disable-PSSessionConfiguration -Name Microsoft.PowerShell ``` To prevent remote users from connecting to the computer, but allow local users @@ -229,7 +228,7 @@ to connect, use the Disable-PSRemoting cmdlet. Disable-PSRemoting adds a "Network_Deny_All" entry to all session configurations on the computer. ```powershell -PS C:> Disable-PSRemoting +PS> Disable-PSRemoting ``` To allow remote users to use all session configurations on the computer, use @@ -238,7 +237,7 @@ the following command enables remote access to the built-in session configurations. ```powershell -PS C:> Enable-PSSessionConfiguration -name Microsoft.Power* +PS> Enable-PSSessionConfiguration -name Microsoft.Power* ``` To make other changes to the security descriptor of a session configuration, @@ -283,7 +282,7 @@ Unregister-PSSessionConfiguration cmdlet. For example, the following command removes the NewConfig session configuration from the computer. ```powershell -PS C:> Unregister-PSSessionConfiguration -Name NewConfig +PS> Unregister-PSSessionConfiguration -Name NewConfig ``` For more information, see Unregister-PSSessionConfiguration. @@ -312,7 +311,7 @@ on the Server01 computer. The command uses the ConfigurationName parameter to select the WithProfile configuration on the Server01 computer. ```powershell -PS C:> New-PSSession -ComputerName Server01 -ConfigurationName WithProfile +PS> New-PSSession -ComputerName Server01 -ConfigurationName WithProfile ``` This command will succeed only if the current user has permission to use the diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Signing.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Signing.md index bda83708f566..02facc9a0e6d 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Signing.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Signing.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 01/03/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Signing --- - # About Signing ## SHORT DESCRIPTION @@ -186,7 +185,7 @@ will not find a certificate file in the file system directory.) At the PowerShell prompt, type: ```powershell -get-childitem cert:\CurrentUser\my -codesigning +Get-ChildItem cert:\CurrentUser\my -codesigning ``` This command uses the PowerShell Certificate provider to view information diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Special_Characters.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Special_Characters.md index 7e5de57b95cb..89d7e1815bcc 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Special_Characters.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Special_Characters.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Special_Characters --- - # About Special Characters # SHORT DESCRIPTION diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Splatting.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Splatting.md index 8db566e6bcd8..cf4bd292ec29 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Splatting.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Splatting.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 01/03/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Splatting --- - # About Splatting ## SHORT DESCRIPTION diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Split.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Split.md index 63ec14e5915f..2ffb51d90a29 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Split.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Split.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 12/20/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Split --- - # About Split ## SHORT DESCRIPTION @@ -18,14 +17,14 @@ substrings. The Split operator splits one or more strings into substrings. You can change the following elements of the Split operation: -* Delimiter. The default is whitespace, but you can specify characters, +- Delimiter. The default is whitespace, but you can specify characters, strings, patterns, or script blocks that specify the delimiter. The Split operator in Windows PowerShell uses a regular expression in the delimiter, rather than a simple character. -* Maximum number of substrings. The default is to return all substrings. If +- Maximum number of substrings. The default is to return all substrings. If you specify a number less than the number of substrings, the remaining substrings are concatenated in the last substring. -* Options that specify the conditions under which the delimiter is matched, +- Options that specify the conditions under which the delimiter is matched, such as SimpleMatch and Multiline. ## SYNTAX @@ -188,28 +187,28 @@ The syntax for the Options parameter is: The SimpleMatch options are: -* **SimpleMatch**: Use simple string comparison when evaluating the +- **SimpleMatch**: Use simple string comparison when evaluating the delimiter. Cannot be used with RegexMatch. -* **IgnoreCase**: Forces case-insensitive matching, even if the -cSplit +- **IgnoreCase**: Forces case-insensitive matching, even if the -cSplit operator is specified. The RegexMatch options are: -* **RegexMatch**: Use regular expression matching to evaluate the +- **RegexMatch**: Use regular expression matching to evaluate the delimiter. This is the default behavior. Cannot be used with SimpleMatch. -* **IgnoreCase**: Forces case-insensitive matching, even if the -cSplit +- **IgnoreCase**: Forces case-insensitive matching, even if the -cSplit operator is specified. -* **CultureInvariant**: Ignores cultural differences in language +- **CultureInvariant**: Ignores cultural differences in language when evaluting the delimiter. Valid only with RegexMatch. -* IgnorePatternWhitespace: Ignores unescaped whitespace and +- IgnorePatternWhitespace: Ignores unescaped whitespace and comments marked with the number sign (#). Valid only with RegexMatch. -* **Multiline**: Multiline mode recognizes the start and end of lines +- **Multiline**: Multiline mode recognizes the start and end of lines and strings. Valid only with RegexMatch. Singleline is the default. -* **Singleline**: Singleline mode recognizes only the start and end of +- **Singleline**: Singleline mode recognizes only the start and end of strings. Valid only with RegexMatch. Singleline is the default. -* **ExplicitCapture**: Ignores non-named match groups so that only +- **ExplicitCapture**: Ignores non-named match groups so that only explicit capture groups are returned in the result list. Valid only with RegexMatch. diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Switch.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Switch.md index 54eccc88f218..f8af51eb9069 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Switch.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Switch.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 12/06/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Switch --- - # About Switch ## SHORT DESCRIPTION @@ -198,7 +197,8 @@ For the word "fourteen" to match a case you must use the **-Wildcard** or Result: - ```Output + +```Output That's too many. ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Throw.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Throw.md index 6145c14b6535..aecc933a5a14 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Throw.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Throw.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 12/01/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Throw --- - # About Throw ## SHORT DESCRIPTION @@ -38,7 +37,7 @@ not appear in a Catch block, and it does not include an expression, it generates a ScriptHalted error. ```powershell -C:\PS> throw +PS> throw ScriptHalted At line:1 char:6 @@ -57,7 +56,7 @@ The optional expression in a Throw statement can be a string, as shown in the following example: ```powershell -C:\PS> throw "This is an error." +PS> throw "This is an error." This is an error. At line:1 char:6 @@ -73,11 +72,11 @@ The expression can also be an object that throws the object that represents the PowerShell process, as shown in the following example: ```powershell -C:\PS> throw (get-process PowerShell) +PS> throw (Get-Process PowerShell) System.Diagnostics.Process (PowerShell) At line:1 char:6 -+ throw <<<< (get-process PowerShell) ++ throw <<<< (Get-Process PowerShell) + CategoryInfo : OperationStopped: (System.Diagnostics.Process (Pow erShell):Process) [], RuntimeException @@ -88,7 +87,7 @@ You can use the TargetObject property of the ErrorRecord object in the $error automatic variable to examine the error. ```powershell -C:\PS> $error[0].targetobject +PS> $error[0].targetobject Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- @@ -100,9 +99,9 @@ exception. The following example uses the Throw keyword to throw a System.FormatException object. ```powershell -C:\PS> $formatError = new-object system.formatexception +PS> $formatError = new-object system.formatexception -C:\PS> throw $formatError +PS> throw $formatError One of the identified items was in an invalid format. At line:1 char:6 @@ -145,7 +144,7 @@ function Get-XMLFiles param ($path = $(throw "The Path parameter is required.")) dir -path $path\*.xml -recurse | sort lastwritetime | - ft lastwritetime, attributes, name -auto + Format-Table lastwritetime, attributes, name -AutoSize } ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_scopes.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_scopes.md index 6137b7bab05b..93bddbb0554d 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_scopes.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_scopes.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 01/08/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_scopes --- - # About Scopes about_Scopes @@ -99,13 +98,13 @@ Get-Variable or Get-Alias. For example, to get all the variables in the local scope, type: ```powershell -get-variable -scope local +Get-Variable -Scope local ``` To get all the variables in the global scope, type: ```powershell -get-variable -scope global +Get-Variable -Scope global ``` ## Scope Modifiers @@ -156,7 +155,7 @@ definition creates a function in the global scope: ```powershell function global:Hello { - write-host "Hello, World" + Write-Host "Hello, World" } ``` @@ -197,7 +196,7 @@ change) items in a particular scope. Use the following command to find all the cmdlets in your session that have a Scope parameter: ```powershell -get-help * -parameter scope +Get-Help * -Parameter scope ``` To find the variables that are visible in a particular scope, use the Scope @@ -208,7 +207,7 @@ For example, the following command gets the variables that are visible in the local scope: ```powershell -get-variable -scope local +Get-Variable -Scope local ``` To create a variable in a particular scope, use a scope modifier or the Scope @@ -216,7 +215,7 @@ parameter of Set-Variable. The following command creates a variable in the global scope: ```powershell -new-variable -scope global -name a -value "One" +New-Variable -Scope global -Name a -Value "One" ``` You can also use the Scope parameter of the New-Alias, Set-Alias, or Get-Alias @@ -224,7 +223,7 @@ cmdlets to specify the scope. The following command creates an alias in the global scope: ```powershell -new-alias -scope global -name np -value Notepad.exe +New-Alias -Scope global -Name np -Value Notepad.exe ``` To get the functions in a particular scope, use the Get-Item cmdlet when you @@ -349,7 +348,7 @@ First, to display the value of the \$ConfirmPreference variable in the local scope, use the following command: ``` -C:\PS> $ConfirmPreference +PS> $ConfirmPreference High ``` @@ -372,7 +371,7 @@ Next, test the current value of the \$ConfirmPreference variable in the current scope. ``` -C:\PS> $ConfirmPreference +PS> $ConfirmPreference High ``` @@ -413,7 +412,7 @@ When the script is complete, only the global value of \$test is defined in the session. ``` -C:\PS> $test +PS> $test Global ``` @@ -442,7 +441,7 @@ $global:test = "Local" When the script is complete, the global value of \$test is changed. ``` -C:\PS> $test +PS> $test Local ``` @@ -462,11 +461,11 @@ New-Variable -Name ptest -Value 1 -Option private You can display and change the value of \$ptest in the local scope. ``` -C:\PS> $ptest +PS> $ptest 1 -C:\PS> $ptest = 2 -C:\PS> $ptest +PS> $ptest = 2 +PS> $ptest 2 ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_simplified_syntax.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_simplified_syntax.md index ac9e4de8c2fc..3a840ddad781 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_simplified_syntax.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_simplified_syntax.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Simplified_Syntax --- - # about_Simplified_Syntax ## SHORT DESCRIPTION From f4861a83aad0e9c707d7739aaa12c36bbaf1a870 Mon Sep 17 00:00:00 2001 From: Thomas Lee Date: Wed, 2 May 2018 15:35:37 +0100 Subject: [PATCH 4/6] Update What-s-New-With-PowerShell.md (#2388) Updated title to reflect article is about what is new in Powerhell 5.0. --- .../docs-conceptual/whats-new/What-s-New-With-PowerShell.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reference/docs-conceptual/whats-new/What-s-New-With-PowerShell.md b/reference/docs-conceptual/whats-new/What-s-New-With-PowerShell.md index ff41c73cabf6..b1ba583062bb 100644 --- a/reference/docs-conceptual/whats-new/What-s-New-With-PowerShell.md +++ b/reference/docs-conceptual/whats-new/What-s-New-With-PowerShell.md @@ -1,10 +1,10 @@ --- ms.date: 06/05/2017 keywords: powershell,cmdlet -title: What s New With PowerShell +title: What's New With PowerShell 5.0 --- -# What's New With PowerShell +# What's New With PowerShell 5.0 Windows PowerShell® 5.0 includes significant new features that extend its use, improve its usability, and allow you to control and manage Windows-based environments more easily and comprehensively. The major improvements are in the areas of Desired State Configuration, security, performance, remoting, and language enhancements. Windows PowerShell 5.0 is backward-compatible. Cmdlets, providers, modules, snap-ins, scripts, functions, and profiles that were designed for Windows PowerShell 4.0, Windows PowerShell 3.0, and Windows PowerShell 2.0 generally work in Windows PowerShell 5.0 without changes. @@ -21,4 +21,4 @@ Windows PowerShell 5.0 is installed by default on Windows Server® 2016 and Wind - New features in Windows PowerShell 4.0 - New features in Windows PowerShell 3.0 ---> \ No newline at end of file +--> From 09337bc5e1034fd32dea3b63e442c7b8a783e2d9 Mon Sep 17 00:00:00 2001 From: PRASOON KARUNAN V <12897753+kvprasoon@users.noreply.github.com> Date: Wed, 2 May 2018 20:06:31 +0530 Subject: [PATCH 5/6] Related change with #1880 (#2387) Related change to Updated localmachine\Root to LocalMachine\My (#1880). Change was added only in code but not in description. --- dsc/secureMOF.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dsc/secureMOF.md b/dsc/secureMOF.md index 16c9d3675fbd..f9fe5798d955 100644 --- a/dsc/secureMOF.md +++ b/dsc/secureMOF.md @@ -155,7 +155,7 @@ The following example: 1. creates a certificate on the **Authoring node**. 2. exports the certificate including the private key on the **Authoring node**. 3. removes the private key from the **Authoring node**, but keeps the public key certificate in the **my** store. - 4. imports the private key certificate into the root certificate store on the **Target node**. + 4. imports the private key certificate into the My(Personal) certificate store on the **Target node**. - it must be added to the root store so that it will be trusted by the **Target node**. #### On the Authoring Node: create and export the certificate @@ -466,4 +466,4 @@ function Get-EncryptionCertificate } Start-CredentialEncryptionExample -``` \ No newline at end of file +``` From e2b1e4d5773e10d95a47c9d878119b1fdfce7fca Mon Sep 17 00:00:00 2001 From: Sergey Vasin Date: Wed, 2 May 2018 18:03:58 +0300 Subject: [PATCH 6/6] Change Get-WMIObject cmdlet reference to Get-CimInstance in Collecting-Information-About-Computers.md. (#2386) --- .../Collecting-Information-About-Computers.md | 190 ++++++++++-------- 1 file changed, 103 insertions(+), 87 deletions(-) diff --git a/reference/docs-conceptual/getting-started/cookbooks/Collecting-Information-About-Computers.md b/reference/docs-conceptual/getting-started/cookbooks/Collecting-Information-About-Computers.md index 02ce5d7b8fb5..ac828b4acbd7 100644 --- a/reference/docs-conceptual/getting-started/cookbooks/Collecting-Information-About-Computers.md +++ b/reference/docs-conceptual/getting-started/cookbooks/Collecting-Information-About-Computers.md @@ -6,35 +6,44 @@ ms.assetid: 9e7b6a2d-34f7-4731-a92c-8b3382eb51bb --- # Collecting Information About Computers -**Get-WmiObject** is the most important cmdlet for general system management tasks. All critical subsystem settings are exposed through WMI. Furthermore, WMI treats data as objects that are in collections of one or more items. Because Windows PowerShell also works with objects and has a pipeline that allows you to treat single or multiple objects in the same way, generic WMI access allows you to perform some advanced tasks with very little work. +Cmdlets from **CimCmdlets** module are the most important cmdlets for general system management tasks. +All critical subsystem settings are exposed through WMI. +Furthermore, WMI treats data as objects that are in collections of one or more items. +Because Windows PowerShell also works with objects and has a pipeline that allows you to treat single or multiple objects in the same way, generic WMI access allows you to perform some advanced tasks with very little work. -The following examples demonstrate how to collect specific information by using **Get-WmiObject** against an arbitrary computer. We specify the **ComputerName** parameter with the dot value (**.**), which represents the local computer. You can specify a name or IP address associated with any computer you can reach through WMI. To retrieve information about the local computer, you could omit the **-ComputerName.** +The following examples demonstrate how to collect specific information by using `Get-CimInstance` against an arbitrary computer. +We specify the **ComputerName** parameter with the dot value (**.**), which represents the local computer. +You can specify a name or IP address associated with any computer you can reach through WMI. +To retrieve information about the local computer, you could omit the **ComputerName** parameter. ### Listing Desktop Settings We'll begin with a command that collects information about the desktops on the local computer. ```powershell -Get-WmiObject -Class Win32_Desktop -ComputerName . +Get-CimInstance -ClassName Win32_Desktop -ComputerName . ``` This returns information for all desktops, whether they are in use or not. > [!NOTE] -> Information returned by some WMI classes can be very detailed, and often include metadata about the WMI class. Because most of these metadata properties have names that begin with a double underscore, you can filter the properties using Select-Object. Specify only properties that begin with alphabetic characters by using **[a-z]*** as the Property value. For example: +> Information returned by some WMI classes can be very detailed, and often include metadata about the WMI class. +Because most of these metadata properties have names that begin with **Cim**, you can filter the properties using `Select-Object`. +Specify the **-ExcludeProperty** parameter with "Cim*" as the value. +For example: ```powershell -Get-WmiObject -Class Win32_Desktop -ComputerName . | Select-Object -Property [a-z]* +Get-CimInstance -ClassName Win32_Desktop -ComputerName . | Select-Object -ExcludeProperty "CIM*" ``` -To filter out the metadata, use a pipeline operator (|) to send the results of the Get-WmiObject command to `Select-Object -Property [a-z]*`. +To filter out the metadata, use a pipeline operator (|) to send the results of the `Get-CimInstance` command to `Select-Object -ExcludeProperty "CIM*"`. ### Listing BIOS Information -The WMI Win32_BIOS class returns fairly compact and complete information about the system BIOS on the local computer: +The WMI **Win32_BIOS** class returns fairly compact and complete information about the system BIOS on the local computer: ```powershell -Get-WmiObject -Class Win32_BIOS -ComputerName . +Get-CimInstance -ClassName Win32_BIOS -ComputerName . ``` ### Listing Processor Information @@ -42,13 +51,13 @@ Get-WmiObject -Class Win32_BIOS -ComputerName . You can retrieve general processor information by using WMI's **Win32_Processor** class, although you will likely want to filter the information: ```powershell -Get-WmiObject -Class Win32_Processor -ComputerName . | Select-Object -Property [a-z]* +Get-CimInstance -ClassName Win32_Processor -ComputerName . | Select-Object -ExcludeProperty "CIM*" ``` For a generic description string of the processor family, you can just return the **SystemType** property: -``` -PS> Get-WmiObject -Class Win32_ComputerSystem -ComputerName . | Select-Object -Property SystemType +```powershell +Get-CimInstance -ClassName Win32_ComputerSystem -ComputerName . | Select-Object -Property SystemType SystemType ---------- @@ -57,127 +66,130 @@ X86-based PC ### Listing Computer Manufacturer and Model -Computer model information is also available from **Win32_ComputerSystem**. The standard displayed output will not need any filtering to provide OEM data: +Computer model information is also available from **Win32_ComputerSystem**. +The standard displayed output will not need any filtering to provide OEM data: +```powershell +Get-CimInstance -ClassName Win32_ComputerSystem ``` -PS> Get-WmiObject -Class Win32_ComputerSystem -Domain : WORKGROUP -Manufacturer : Compaq Presario 06 -Model : DA243A-ABA 6415cl NA910 -Name : MyPC -PrimaryOwnerName : Jane Doe -TotalPhysicalMemory : 804765696 +```output +Name PrimaryOwnerName Domain TotalPhysicalMemory Model Manufacturer +---- ---------------- ------ ------------------- ----- ------------ +MyPC Jane Doe WORKGROUP 804765696 DA243A-ABA 6415cl NA910 Compaq Presario 06 ``` -Your output from commands such as this, which return information directly from some hardware, is only as good as the data you have. Some information is not correctly configured by hardware manufacturers and may therefore be unavailable. +Your output from commands such as this, which return information directly from some hardware, is only as good as the data you have. +Some information is not correctly configured by hardware manufacturers and may therefore be unavailable. ### Listing Installed Hotfixes You can list all installed hotfixes by using **Win32_QuickFixEngineering**: ```powershell -Get-WmiObject -Class Win32_QuickFixEngineering -ComputerName . +Get-CimInstance -ClassName Win32_QuickFixEngineering -ComputerName . ``` This class returns a list of hotfixes that looks like this: ```output -Description : Update for Windows XP (KB910437) -FixComments : Update -HotFixID : KB910437 -Install Date : -InstalledBy : Administrator -InstalledOn : 12/16/2005 -Name : -ServicePackInEffect : SP3 -Status : +Source Description HotFixID InstalledBy InstalledOn PSComputerName +------ ----------- -------- ----------- ----------- -------------- + Security Update KB4048951 Administrator 12/16/2017 . ``` -For more succinct output, you may want to exclude some properties. Although you can use the **Get-WmiObject's Property** parameter to choose only the **HotFixID**, doing so will actually return more information, because all the metadata is displayed by default: +For more succinct output, you may want to exclude some properties. +Although you can use the `Get-CimInstance`'s **Property** parameter to choose only the **HotFixID**, doing so will actually return more information, because all the metadata is displayed by default: -``` -PS> Get-WmiObject -Class Win32_QuickFixEngineering -ComputerName . -Property HotFixID - -HotFixID : KB910437 -__GENUS : 2 -__CLASS : Win32_QuickFixEngineering -__SUPERCLASS : -__DYNASTY : -__RELPATH : -__PROPERTY_COUNT : 1 -__DERIVATION : {} -__SERVER : -__NAMESPACE : -__PATH : +```powershell +Get-CimInstance -ClassName Win32_QuickFixEngineering -ComputerName . -Property HotFixID ``` -The additional data is returned, because the Property parameter in **Get-WmiObject** restricts the properties returned from WMI class instances, not the object returned to Windows PowerShell. To reduce the output, use **Select-Object**: +```output +PSShowComputerName : True +InstalledOn : +Caption : +Description : +InstallDate : +Name : +Status : +CSName : +FixComments : +HotFixID : KB4048951 +InstalledBy : +ServicePackInEffect : +PSComputerName : . +CimClass : root/cimv2:Win32_QuickFixEngineering +CimInstanceProperties : {Caption, Description, InstallDate, Name...} +CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties +``` + +The additional data is returned, because the Property parameter in `Get-CimInstance` restricts the properties returned from WMI class instances, not the object returned to Windows PowerShell. +To reduce the output, use `Select-Object`: +```powershell +Get-CimInstance -ClassName Win32_QuickFixEngineering -ComputerName . -Property HotFixId | Select-Object -Property HotFixId ``` -PS> Get-WmiObject -Class Win32_QuickFixEngineering -ComputerName . -Property HotFixId | Select-Object -Property HotFixId +```output HotFixId -------- -KB910437 +KB4048951 ``` ### Listing Operating System Version Information -The **Win32_OperatingSystem** class properties include version and service pack information. You can explicitly select only these properties to get a version information summary from **Win32_OperatingSystem**: +The **Win32_OperatingSystem** class properties include version and service pack information. +You can explicitly select only these properties to get a version information summary from **Win32_OperatingSystem**: ```powershell -Get-WmiObject -Class Win32_OperatingSystem -ComputerName . | Select-Object -Property BuildNumber,BuildType,OSType,ServicePackMajorVersion,ServicePackMinorVersion +Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName . | Select-Object -Property BuildNumber,BuildType,OSType,ServicePackMajorVersion,ServicePackMinorVersion ``` -You can also use wildcards with the **Select-Object's Property** parameter. Because all the properties beginning with either **Build** or **ServicePack** are important to use here, we can shorten this to the following form: +You can also use wildcards with the `Select-Object`'s **Property** parameter. +Because all the properties beginning with either **Build** or **ServicePack** are important to use here, we can shorten this to the following form: +```powershell +Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName . | Select-Object -Property Build*,OSType,ServicePack* ``` -PS> Get-WmiObject -Class Win32_OperatingSystem -ComputerName . | Select-Object -Property Build*,OSType,ServicePack* -BuildNumber : 2600 -BuildType : Uniprocessor Free +```output +BuildNumber : 16299 +BuildType : Multiprocessor Free OSType : 18 -ServicePackMajorVersion : 2 +ServicePackMajorVersion : 0 ServicePackMinorVersion : 0 ``` ### Listing Local Users and Owner -Local general user information—number of licensed users, current number of users, and owner name—can be found with a selection of **Win32_OperatingSystem** properties. You can explicitly select the properties to display like this: +Local general user information — number of licensed users, current number of users, and owner name — can be found with a selection of **Win32_OperatingSystem** class' properties. +You can explicitly select the properties to display like this: ```powershell -Get-WmiObject -Class Win32_OperatingSystem -ComputerName . | Select-Object -Property NumberOfLicensedUsers,NumberOfUsers,RegisteredUser +Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName . | Select-Object -Property NumberOfLicensedUsers,NumberOfUsers,RegisteredUser ``` A more succinct version using wildcards is: ```powershell -Get-WmiObject -Class Win32_OperatingSystem -ComputerName . | Select-Object -Property *user* +Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName . | Select-Object -Property *user* ``` ### Getting Available Disk Space -To see the disk space and free space for local drives, you can use the WMI Win32_LogicalDisk class. You need to see only instances with a DriveType of 3—the value WMI uses for fixed hard disks. - -``` -PS> Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" -ComputerName . +To see the disk space and free space for local drives, you can use the Win32_LogicalDisk WMI class. +You need to see only instances with a DriveType of 3 — the value WMI uses for fixed hard disks. -DeviceID : C: -DriveType : 3 -ProviderName : -FreeSpace : 65541357568 -Size : 203912880128 -VolumeName : Local Disk +```powershell +Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" -ComputerName . -DeviceID : Q: -DriveType : 3 -ProviderName : -FreeSpace : 44298250240 -Size : 122934034432 -VolumeName : New Volume +DeviceID DriveType ProviderName VolumeName Size FreeSpace PSComputerName +-------- --------- ------------ ---------- ---- --------- -------------- +C: 3 Local Disk 203912880128 65541357568 . +Q: 3 New Volume 122934034432 44298250240 . -PS> Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" -ComputerName . | Measure-Object -Property FreeSpace,Size -Sum | Select-Object -Property Property,Sum +Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" -ComputerName . | Measure-Object -Property FreeSpace,Size -Sum | Select-Object -Property Property,Sum Property Sum -------- --- @@ -187,26 +199,27 @@ Size 326846914560 ### Getting Logon Session Information -You can get general information about logon sessions associated with users through the WMI Win32_LogonSession class: +You can get general information about logon sessions associated with users through the **Win32_LogonSession** WMI class: ```powershell -Get-WmiObject -Class Win32_LogonSession -ComputerName . +Get-CimInstance -ClassName Win32_LogonSession -ComputerName . ``` ### Getting the User Logged on to a Computer -You can display the user logged on to a particular computer system using Win32_ComputerSystem. This command returns only the user logged on to the system desktop: +You can display the user logged on to a particular computer system using Win32_ComputerSystem. +This command returns only the user logged on to the system desktop: ```powershell -Get-WmiObject -Class Win32_ComputerSystem -Property UserName -ComputerName . +Get-CimInstance -ClassName Win32_ComputerSystem -Property UserName -ComputerName . ``` ### Getting Local Time from a Computer -You can retrieve the current local time on a specific computer by using the WMI Win32_LocalTime class. Because this class by default displays all metadata, you may want to filter it using **Select-Object**: +You can retrieve the current local time on a specific computer by using the **Win32_LocalTime** WMI class. -``` -PS> Get-WmiObject -Class Win32_LocalTime -ComputerName . | Select-Object -Property [a-z]* +```powershell +Get-CimInstance -ClassName Win32_LocalTime -ComputerName . Day : 15 DayOfWeek : 4 @@ -217,19 +230,22 @@ Month : 6 Quarter : 2 Second : 52 WeekInMonth : 3 -Year : 2006 +Year : 2017 +PSComputerName : . ``` ### Displaying Service Status -To view the status of all services on a specific computer, you can locally use the **Get-Service** cmdlet as mentioned earlier. For remote systems, you can use the WMI Win32_Service class. If you also use **Select-Object** to filter the results to **Status**, **Name**, and **DisplayName**, the output format will be almost identical to that from **Get-Service**: +To view the status of all services on a specific computer, you can locally use the `Get-Service` cmdlet. +For remote systems, you can use the **Win32_Service** WMI class. +If you also use `Select-Object` to filter the results to **Status**, **Name**, and **DisplayName**, the output format will be almost identical to that from `Get-Service`: ```powershell -Get-WmiObject -Class Win32_Service -ComputerName . | Select-Object -Property Status,Name,DisplayName +Get-CimInstance -ClassName Win32_Service -ComputerName . | Select-Object -Property Status,Name,DisplayName ``` -To allow the complete display of names for the occasional services with extremely long names, you may want to use **Format-Table** with the **AutoSize** and **Wrap** parameters, to optimize column width and allow long names to wrap instead of being truncated: +To allow the complete display of names for the occasional services with extremely long names, you may want to use `Format-Table` with the **AutoSize** and **Wrap** parameters, to optimize column width and allow long names to wrap instead of being truncated: ```powershell -Get-WmiObject -Class Win32_Service -ComputerName . | Format-Table -Property Status,Name,DisplayName -AutoSize -Wrap +Get-CimInstance -ClassName Win32_Service -ComputerName . | Format-Table -Property Status,Name,DisplayName -AutoSize -Wrap ```