GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 134.29.175.74 / Your IP : 216.73.216.160 Web Server : nginx/1.10.2 System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586 User : Administrator ( 0) PHP Version : 7.1.0 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Windows/SysWOW64/WindowsPowerShell/v1.0/en-US/ |
Upload File : |
<?xml version="1.0" encoding="utf-8"?> <helpItems schema="maml" xmlns="http://msh"> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Add-Member</command:name> <command:verb>Add</command:verb> <command:noun>Member</command:noun> <maml:description> <maml:para>Adds custom properties and methods to an instance of a PowerShell object.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Add-Member` cmdlet lets you add members (properties and methods) to an instance of a PowerShell object. For instance, you can add a NoteProperty member that contains a description of the object or a ScriptMethod member that runs a script to change the object.</maml:para> <maml:para>To use `Add-Member`, pipe the object to `Add-Member`, or use the InputObject parameter to specify the object.</maml:para> <maml:para>The MemberType parameter indicates the type of member that you want to add. The Name parameter assigns a name to the new member, and the Value parameter sets the value of the member.</maml:para> <maml:para>The properties and methods that you add are added only to the particular instance of the object that you specify. `Add-Member` does not change the object type. To create a new object type, use the `Add-Type` cmdlet.</maml:para> <maml:para>You can also use the `Export-Clixml` cmdlet to save the instance of the object, including the additional members, in a file. Then you can use the `Import-Clixml` cmdlet to re-create the instance of the object from the information that is stored in the exported file.</maml:para> <maml:para>Beginning in Windows PowerShell 3.0, `Add-Member` has new features that make it easier to add note properties to objects. You can use the NotePropertyName and NotePropertyValue parameters to define a note property or use the NotePropertyMembers parameter, which takes a hash table of note property names and values.</maml:para> <maml:para>Also, beginning in Windows PowerShell 3.0, the PassThru parameter, which generates an output object, is needed less frequently. `Add-Member` now adds the new members directly to the input object of more types. For more information, see the PassThru parameter description.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Add-Member</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="Type"> <maml:name>MemberType</maml:name> <maml:Description> <maml:para>Specifies the type of the member to add. This parameter is required. The acceptable values for this parameter are:</maml:para> <maml:para>- NoteProperty</maml:para> <maml:para>- AliasProperty</maml:para> <maml:para>- ScriptProperty</maml:para> <maml:para>- CodeProperty</maml:para> <maml:para>- ScriptMethod</maml:para> <maml:para>- CodeMethod</maml:para> <maml:para></maml:para> <maml:para>For information about these values, see PSMemberTypes Enumeration (/dotnet/api/system.management.automation.psmembertypes)in the MSDN library.</maml:para> <maml:para>Not all objects have every type of member. If you specify a member type that the object does not have, PowerShell returns an error.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">AliasProperty</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">CodeProperty</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Property</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">NoteProperty</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ScriptProperty</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Properties</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">PropertySet</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Method</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">CodeMethod</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ScriptMethod</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Methods</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ParameterizedProperty</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">MemberSet</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Event</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Dynamic</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">All</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSMemberTypes</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSMemberTypes</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the name of the member that this cmdlet adds.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none"> <maml:name>Value</maml:name> <maml:Description> <maml:para>Specifies the initial value of the added member. If you add an AliasProperty , CodeProperty , ScriptProperty or CodeMethod member, you can supply optional, additional information by using the SecondValue parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="3" aliases="none"> <maml:name>SecondValue</maml:name> <maml:Description> <maml:para>Specifies optional additional information about AliasProperty , ScriptProperty , CodeProperty , or CodeMethod members.</maml:para> <maml:para>If used when adding an AliasProperty , this parameter must be a data type. A conversion to the specified data type is added to the value of the AliasProperty .</maml:para> <maml:para>For example, if you add an AliasProperty that provides an alternate name for a string property, you can also specify a SecondValue parameter of System.Int32 to indicate that the value of that string property should be converted to an integer when accessed by using the corresponding AliasProperty .</maml:para> <maml:para>You can use the SecondValue parameter to specify an additional ScriptBlock when adding a ScriptProperty member. The first ScriptBlock , specified in the Value parameter, is used to get the value of a variable. The second ScriptBlock , specified in the SecondValue parameter, is used to set the value of a variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet adds a new member even the object has a custom member with the same name. You cannot use the Force parameter to replace a standard member of a type.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the object to which the new member is added. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> <maml:para>For most objects, `Add-Member` adds the new members to the input object. However, when the input object is a string, `Add-Member` cannot add the member to the input object. For these objects, use the PassThru parameter to create an output object.</maml:para> <maml:para>In Windows PowerShell 2.0, `Add-Member` added members only to the PSObject wrapper of objects, not to the object. Use the PassThru parameter to create an output object for any object that has a PSObject wrapper.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TypeName</maml:name> <maml:Description> <maml:para>Specifies a name for the type.</maml:para> <maml:para>When the type is a class in the System namespace or a type that has a type accelerator, you can enter the short name of the type. Otherwise, the full type name is required. This parameter is effective only when the InputObject is a PSObject .</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Add-Member</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>NotePropertyName</maml:name> <maml:Description> <maml:para>Specifies the note property name.</maml:para> <maml:para>Use this parameter with the NotePropertyValue parameter. This parameter is optional.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>NotePropertyValue</maml:name> <maml:Description> <maml:para>Specifies the note property value.</maml:para> <maml:para>Use this parameter with the NotePropertyName parameter. This parameter is optional.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet adds a new member even the object has a custom member with the same name. You cannot use the Force parameter to replace a standard member of a type.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the object to which the new member is added. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> <maml:para>For most objects, `Add-Member` adds the new members to the input object. However, when the input object is a string, `Add-Member` cannot add the member to the input object. For these objects, use the PassThru parameter to create an output object.</maml:para> <maml:para>In Windows PowerShell 2.0, `Add-Member` added members only to the PSObject wrapper of objects, not to the object. Use the PassThru parameter to create an output object for any object that has a PSObject wrapper.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TypeName</maml:name> <maml:Description> <maml:para>Specifies a name for the type.</maml:para> <maml:para>When the type is a class in the System namespace or a type that has a type accelerator, you can enter the short name of the type. Otherwise, the full type name is required. This parameter is effective only when the InputObject is a PSObject .</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Add-Member</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>NotePropertyMembers</maml:name> <maml:Description> <maml:para>Specifies a hash table or ordered dictionary of note property names and values. Type a hash table or dictionary in which the keys are note property names and the values are note property values.</maml:para> <maml:para>For more information about hash tables and ordered dictionaries in PowerShell, see about_Hash_Tables (../Microsoft.PowerShell.Core/About/about_Hash_Tables.md).</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Collections.IDictionary</command:parameterValue> <dev:type> <maml:name>System.Collections.IDictionary</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet adds a new member even the object has a custom member with the same name. You cannot use the Force parameter to replace a standard member of a type.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the object to which the new member is added. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> <maml:para>For most objects, `Add-Member` adds the new members to the input object. However, when the input object is a string, `Add-Member` cannot add the member to the input object. For these objects, use the PassThru parameter to create an output object.</maml:para> <maml:para>In Windows PowerShell 2.0, `Add-Member` added members only to the PSObject wrapper of objects, not to the object. Use the PassThru parameter to create an output object for any object that has a PSObject wrapper.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TypeName</maml:name> <maml:Description> <maml:para>Specifies a name for the type.</maml:para> <maml:para>When the type is a class in the System namespace or a type that has a type accelerator, you can enter the short name of the type. Otherwise, the full type name is required. This parameter is effective only when the InputObject is a PSObject .</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Add-Member</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the object to which the new member is added. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> <maml:para>For most objects, `Add-Member` adds the new members to the input object. However, when the input object is a string, `Add-Member` cannot add the member to the input object. For these objects, use the PassThru parameter to create an output object.</maml:para> <maml:para>In Windows PowerShell 2.0, `Add-Member` added members only to the PSObject wrapper of objects, not to the object. Use the PassThru parameter to create an output object for any object that has a PSObject wrapper.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TypeName</maml:name> <maml:Description> <maml:para>Specifies a name for the type.</maml:para> <maml:para>When the type is a class in the System namespace or a type that has a type accelerator, you can enter the short name of the type. Otherwise, the full type name is required. This parameter is effective only when the InputObject is a PSObject .</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet adds a new member even the object has a custom member with the same name. You cannot use the Force parameter to replace a standard member of a type.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the object to which the new member is added. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="Type"> <maml:name>MemberType</maml:name> <maml:Description> <maml:para>Specifies the type of the member to add. This parameter is required. The acceptable values for this parameter are:</maml:para> <maml:para>- NoteProperty</maml:para> <maml:para>- AliasProperty</maml:para> <maml:para>- ScriptProperty</maml:para> <maml:para>- CodeProperty</maml:para> <maml:para>- ScriptMethod</maml:para> <maml:para>- CodeMethod</maml:para> <maml:para></maml:para> <maml:para>For information about these values, see PSMemberTypes Enumeration (/dotnet/api/system.management.automation.psmembertypes)in the MSDN library.</maml:para> <maml:para>Not all objects have every type of member. If you specify a member type that the object does not have, PowerShell returns an error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSMemberTypes</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSMemberTypes</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the name of the member that this cmdlet adds.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>NotePropertyMembers</maml:name> <maml:Description> <maml:para>Specifies a hash table or ordered dictionary of note property names and values. Type a hash table or dictionary in which the keys are note property names and the values are note property values.</maml:para> <maml:para>For more information about hash tables and ordered dictionaries in PowerShell, see about_Hash_Tables (../Microsoft.PowerShell.Core/About/about_Hash_Tables.md).</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Collections.IDictionary</command:parameterValue> <dev:type> <maml:name>System.Collections.IDictionary</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>NotePropertyName</maml:name> <maml:Description> <maml:para>Specifies the note property name.</maml:para> <maml:para>Use this parameter with the NotePropertyValue parameter. This parameter is optional.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>NotePropertyValue</maml:name> <maml:Description> <maml:para>Specifies the note property value.</maml:para> <maml:para>Use this parameter with the NotePropertyName parameter. This parameter is optional.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> <maml:para>For most objects, `Add-Member` adds the new members to the input object. However, when the input object is a string, `Add-Member` cannot add the member to the input object. For these objects, use the PassThru parameter to create an output object.</maml:para> <maml:para>In Windows PowerShell 2.0, `Add-Member` added members only to the PSObject wrapper of objects, not to the object. Use the PassThru parameter to create an output object for any object that has a PSObject wrapper.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="3" aliases="none"> <maml:name>SecondValue</maml:name> <maml:Description> <maml:para>Specifies optional additional information about AliasProperty , ScriptProperty , CodeProperty , or CodeMethod members.</maml:para> <maml:para>If used when adding an AliasProperty , this parameter must be a data type. A conversion to the specified data type is added to the value of the AliasProperty .</maml:para> <maml:para>For example, if you add an AliasProperty that provides an alternate name for a string property, you can also specify a SecondValue parameter of System.Int32 to indicate that the value of that string property should be converted to an integer when accessed by using the corresponding AliasProperty .</maml:para> <maml:para>You can use the SecondValue parameter to specify an additional ScriptBlock when adding a ScriptProperty member. The first ScriptBlock , specified in the Value parameter, is used to get the value of a variable. The second ScriptBlock , specified in the SecondValue parameter, is used to set the value of a variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none"> <maml:name>Value</maml:name> <maml:Description> <maml:para>Specifies the initial value of the added member. If you add an AliasProperty , CodeProperty , ScriptProperty or CodeMethod member, you can supply optional, additional information by using the SecondValue parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TypeName</maml:name> <maml:Description> <maml:para>Specifies a name for the type.</maml:para> <maml:para>When the type is a class in the System namespace or a type that has a type accelerator, you can enter the short name of the type. Otherwise, the full type name is required. This parameter is effective only when the InputObject is a PSObject .</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe any object type to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None or System.Object</maml:name> </dev:type> <maml:description> <maml:para>When you use the PassThru parameter, this cmdlet returns the newly-extended object. Otherwise, this cmdlet does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>You can add members only to PSObject objects. To determine whether an object is a PSObject object, use the `-is` operator.</maml:para> <maml:para>For instance, to test an object stored in the `$obj` variable, type `$obj -is [PSObject]`.</maml:para> <maml:para>The names of the MemberType , Name , Value , and SecondValue parameters are optional. If you omit the parameter names, the unnamed parameter values must appear in this order: MemberType , Name , Value , and SecondValue .</maml:para> <maml:para>If you include the parameter names, the parameters can appear in any order.</maml:para> <maml:para>You can use the `$this` automatic variable in script blocks that define the values of new properties and methods. The `$this` variable refers to the instance of the object to which the properties and methods are being added. For more information about the `$this` variable, see about_Automatic_Variables (../Microsoft.PowerShell.Core/About/about_Automatic_Variables.md).</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1: Add a note property to a PSObject ---------</maml:title> <dev:code>$A = Get-ChildItem c:\ps-test\test.txt $A | Add-Member -NotePropertyName Status -NotePropertyValue Done $A.Status Done</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 2: Add an alias property to a PSObject --------</maml:title> <dev:code>$A = Get-ChildItem C:\Temp\test.txt $A | Add-Member -MemberType AliasProperty -Name Size -Value Length $A.Size 2394</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 3: Add a StringUse note property to a string -----</maml:title> <dev:code>$A = "A string" $A = $A | Add-Member -NotePropertyMembers @{StringUse="Display"} -PassThru $A.StringUse Display</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 4: Add a script method to a FileInfo object -----</maml:title> <dev:code>$A = Get-ChildItem C:\Temp\test.txt $S = {[math]::Round(($this.Length / 1MB), 2)} $A | Add-Member -MemberType ScriptMethod -Name "SizeInMB" -Value $S $A.SizeInMB() 0.43</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 5: Copy all properties of an object to another ----</maml:title> <dev:code>function Copy-Property ($From, $To) { $properties = Get-Member -InputObject $From -MemberType Property foreach ($p in $properties) { $To | Add-Member -MemberType NoteProperty -Name $p.Name -Value $From.$($p.Name) -Force } }</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------------- Example 6: Create a custom object --------------</maml:title> <dev:code>$Asset = New-Object -TypeName PSObject $d = [ordered]@{Name="Server30";System="Server Core";PSVersion="4.0"} $Asset | Add-Member -NotePropertyMembers $d -TypeName Asset $Asset | Get-Member TypeName: Asset Name MemberType Definition ---- ---------- ---------- Equals Method bool Equals(System.Object obj) GetHashCode Method int GetHashCode() GetType Method type GetType() ToString Method string ToString() Name NoteProperty System.String Name=Server30 PSVersion NoteProperty System.String PSVersion=4.0 System NoteProperty System.String System=Server Core</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/add-member?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Export-Clixml</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Member</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Import-Clixml</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Automatic_Variables</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Add-Type</command:name> <command:verb>Add</command:verb> <command:noun>Type</command:noun> <maml:description> <maml:para>Adds a Microsoft .NET Framework class to a PowerShell session.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Add-Type` cmdlet lets you define a Microsoft .NET Framework class in your PowerShell session. You can then instantiate objects, by using the `New-Object` cmdlet, and use the objects just as you would use any .NET Framework object. If you add an `Add-Type` command to your PowerShell profile, the class is available in all PowerShell sessions.</maml:para> <maml:para>You can specify the type by specifying an existing assembly or source code files, or you can specify the source code inline or saved in a variable. You can even specify only a method and `Add-Type` will define and generate the class. On Windows, you can use this feature to make Platform Invoke (P/Invoke) calls to unmanaged functions in PowerShell. If you specify source code, `Add-Type` compiles the specified source code and generates an in-memory assembly that contains the new .NET Framework types.</maml:para> <maml:para>You can use the parameters of `Add-Type` to specify an alternate language and compiler, C# is the default, compiler options, assembly dependencies, the class namespace, the names of the type, and the resulting assembly.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Add-Type</maml:name> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="AN"> <maml:name>AssemblyName</maml:name> <maml:Description> <maml:para>Specifies the name of an assembly that includes the types. `Add-Type` takes the types from the specified assembly. This parameter is required when you're creating types based on an assembly name.</maml:para> <maml:para>Enter the full or simple name, also known as the partial name, of an assembly. Wildcard characters are permitted in the assembly name. If you enter a simple or partial name, `Add-Type` resolves it to the full name, and then uses the full name to load the assembly.</maml:para> <maml:para>This parameter doesn't accept a path or a file name. To enter the path to the assembly dynamic-link library (DLL) file, use the Path parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>IgnoreWarnings</maml:name> <maml:Description> <maml:para>Ignores compiler warnings. Use this parameter to prevent `Add-Type` from handling compiler warnings as errors.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns a System.Runtime object that represents the types that were added. By default, this cmdlet doesn't generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Add-Type</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>TypeDefinition</maml:name> <maml:Description> <maml:para>Specifies the source code that contains the type definitions. Enter the source code in a string or here-string, or enter a variable that contains the source code. For more information about here-strings, see about_Quoting_Rules (../Microsoft.PowerShell.Core/about/about_Quoting_Rules.md).</maml:para> <maml:para>Include a namespace declaration in your type definition. If you omit the namespace declaration, your type might have the same name as another type or the shortcut for another type, causing an unintentional overwrite. For example, if you define a type called Exception , scripts that use Exception as the shortcut for System.Exception will fail.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Provider"> <maml:name>CodeDomProvider</maml:name> <maml:Description> <maml:para>Specifies a code generator or compiler. `Add-Type` uses the specified compiler to compile the source code. The default is the C# compiler. Use this parameter if you're using a language that can't be specified by using the Language parameter. The CodeDomProvider that you specify must be able to generate assemblies from source code.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.CodeDom.Compiler.CodeDomProvider</command:parameterValue> <dev:type> <maml:name>System.CodeDom.Compiler.CodeDomProvider</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>C# compiler</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="CP"> <maml:name>CompilerParameters</maml:name> <maml:Description> <maml:para>Specifies the options for the source code compiler. These options are sent to the compiler without revision.</maml:para> <maml:para>This parameter allows you to direct the compiler to generate an executable file, embed resources, or set command-line options, such as the `/unsafe` option. This parameter implements the CompilerParameters class, System.CodeDom.Compiler.CompilerParameters .</maml:para> <maml:para>You can't use the CompilerParameters and ReferencedAssemblies parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.CodeDom.Compiler.CompilerParameters</command:parameterValue> <dev:type> <maml:name>System.CodeDom.Compiler.CompilerParameters</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>IgnoreWarnings</maml:name> <maml:Description> <maml:para>Ignores compiler warnings. Use this parameter to prevent `Add-Type` from handling compiler warnings as errors.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Language</maml:name> <maml:Description> <maml:para>Specifies the language that is used in the source code. The `Add-Type` cmdlet uses the value of this parameter to select the appropriate CodeDomProvider . CSharp is the default value. The acceptable values for this parameter are as follows:</maml:para> <maml:para>- CSharp</maml:para> <maml:para>- CSharpVersion2</maml:para> <maml:para>- CSharpVersion3</maml:para> <maml:para>- JScript</maml:para> <maml:para>- VisualBasic</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">CSharp</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">CSharpVersion2</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">CSharpVersion3</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">JScript</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">VisualBasic</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.Language</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.Language</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>CSharp</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="OA"> <maml:name>OutputAssembly</maml:name> <maml:Description> <maml:para>Generates a DLL file for the assembly with the specified name in the location. Enter an optional path and file name. Wildcard characters are permitted. By default, `Add-Type` generates the assembly only in memory.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="OT"> <maml:name>OutputType</maml:name> <maml:Description> <maml:para>Specifies the output type of the output assembly. By default, no output type is specified. This parameter is valid only when an output assembly is specified in the command. For more information about the values, see OutputAssemblyType Enumeration (/dotnet/api/microsoft.powershell.commands.outputassemblytype).</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- ConsoleApplication</maml:para> <maml:para>- Library</maml:para> <maml:para>- WindowsApplication</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">ConsoleApplication</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Library</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">WindowsApplication</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.OutputAssemblyType</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.OutputAssemblyType</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns a System.Runtime object that represents the types that were added. By default, this cmdlet doesn't generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="RA"> <maml:name>ReferencedAssemblies</maml:name> <maml:Description> <maml:para>Specifies the assemblies upon which the type depends. By default, `Add-Type` references `System.dll` and `System.Management.Automation.dll`. The assemblies that you specify by using this parameter are referenced in addition to the default assemblies.</maml:para> <maml:para>You can't use the CompilerParameters and ReferencedAssemblies parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Add-Type</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the name of the class to create. This parameter is required when generating a type from a member definition.</maml:para> <maml:para>The type name and namespace must be unique within a session. You can't unload a type or change it. To change the code for a type, you must change the name or start a new PowerShell session. Otherwise, the command fails.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>MemberDefinition</maml:name> <maml:Description> <maml:para>Specifies new properties or methods for the class. `Add-Type` generates the template code that is required to support the properties or methods.</maml:para> <maml:para>On Windows, you can use this feature to make Platform Invoke (P/Invoke) calls to unmanaged functions in PowerShell.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Provider"> <maml:name>CodeDomProvider</maml:name> <maml:Description> <maml:para>Specifies a code generator or compiler. `Add-Type` uses the specified compiler to compile the source code. The default is the C# compiler. Use this parameter if you're using a language that can't be specified by using the Language parameter. The CodeDomProvider that you specify must be able to generate assemblies from source code.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.CodeDom.Compiler.CodeDomProvider</command:parameterValue> <dev:type> <maml:name>System.CodeDom.Compiler.CodeDomProvider</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>C# compiler</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="CP"> <maml:name>CompilerParameters</maml:name> <maml:Description> <maml:para>Specifies the options for the source code compiler. These options are sent to the compiler without revision.</maml:para> <maml:para>This parameter allows you to direct the compiler to generate an executable file, embed resources, or set command-line options, such as the `/unsafe` option. This parameter implements the CompilerParameters class, System.CodeDom.Compiler.CompilerParameters .</maml:para> <maml:para>You can't use the CompilerParameters and ReferencedAssemblies parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.CodeDom.Compiler.CompilerParameters</command:parameterValue> <dev:type> <maml:name>System.CodeDom.Compiler.CompilerParameters</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>IgnoreWarnings</maml:name> <maml:Description> <maml:para>Ignores compiler warnings. Use this parameter to prevent `Add-Type` from handling compiler warnings as errors.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Language</maml:name> <maml:Description> <maml:para>Specifies the language that is used in the source code. The `Add-Type` cmdlet uses the value of this parameter to select the appropriate CodeDomProvider . CSharp is the default value. The acceptable values for this parameter are as follows:</maml:para> <maml:para>- CSharp</maml:para> <maml:para>- CSharpVersion2</maml:para> <maml:para>- CSharpVersion3</maml:para> <maml:para>- JScript</maml:para> <maml:para>- VisualBasic</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">CSharp</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">CSharpVersion2</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">CSharpVersion3</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">JScript</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">VisualBasic</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.Language</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.Language</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>CSharp</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NS"> <maml:name>Namespace</maml:name> <maml:Description> <maml:para>Specifies a namespace for the type.</maml:para> <maml:para>If this parameter isn't included in the command, the type is created in the Microsoft.PowerShell.Commands.AddType.AutoGeneratedTypes namespace. If the parameter is included in the command with an empty string value or a value of `$Null`, the type is generated in the global namespace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="OA"> <maml:name>OutputAssembly</maml:name> <maml:Description> <maml:para>Generates a DLL file for the assembly with the specified name in the location. Enter an optional path and file name. Wildcard characters are permitted. By default, `Add-Type` generates the assembly only in memory.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="OT"> <maml:name>OutputType</maml:name> <maml:Description> <maml:para>Specifies the output type of the output assembly. By default, no output type is specified. This parameter is valid only when an output assembly is specified in the command. For more information about the values, see OutputAssemblyType Enumeration (/dotnet/api/microsoft.powershell.commands.outputassemblytype).</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- ConsoleApplication</maml:para> <maml:para>- Library</maml:para> <maml:para>- WindowsApplication</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">ConsoleApplication</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Library</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">WindowsApplication</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.OutputAssemblyType</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.OutputAssemblyType</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns a System.Runtime object that represents the types that were added. By default, this cmdlet doesn't generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="RA"> <maml:name>ReferencedAssemblies</maml:name> <maml:Description> <maml:para>Specifies the assemblies upon which the type depends. By default, `Add-Type` references `System.dll` and `System.Management.Automation.dll`. The assemblies that you specify by using this parameter are referenced in addition to the default assemblies.</maml:para> <maml:para>You can't use the CompilerParameters and ReferencedAssemblies parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Using"> <maml:name>UsingNamespace</maml:name> <maml:Description> <maml:para>Specifies other namespaces that are required for the class. This is much like the C# keyword, `Using`.</maml:para> <maml:para>By default, `Add-Type` references the System namespace. When the MemberDefinition parameter is used, `Add-Type` also references the System.Runtime.InteropServices namespace by default. The namespaces that you add by using the UsingNamespace parameter are referenced in addition to the default namespaces.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>System namespace</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Add-Type</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the path to source code files or assembly DLL files that contain the types.</maml:para> <maml:para>If you submit source code files, `Add-Type` compiles the code in the files and creates an in-memory assembly of the types. The file name extension specified in the value of Path determines the compiler that `Add-Type` uses.</maml:para> <maml:para>If you submit an assembly file, `Add-Type` takes the types from the assembly. To specify an in-memory assembly or the global assembly cache, use the AssemblyName parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="CP"> <maml:name>CompilerParameters</maml:name> <maml:Description> <maml:para>Specifies the options for the source code compiler. These options are sent to the compiler without revision.</maml:para> <maml:para>This parameter allows you to direct the compiler to generate an executable file, embed resources, or set command-line options, such as the `/unsafe` option. This parameter implements the CompilerParameters class, System.CodeDom.Compiler.CompilerParameters .</maml:para> <maml:para>You can't use the CompilerParameters and ReferencedAssemblies parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.CodeDom.Compiler.CompilerParameters</command:parameterValue> <dev:type> <maml:name>System.CodeDom.Compiler.CompilerParameters</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>IgnoreWarnings</maml:name> <maml:Description> <maml:para>Ignores compiler warnings. Use this parameter to prevent `Add-Type` from handling compiler warnings as errors.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="OA"> <maml:name>OutputAssembly</maml:name> <maml:Description> <maml:para>Generates a DLL file for the assembly with the specified name in the location. Enter an optional path and file name. Wildcard characters are permitted. By default, `Add-Type` generates the assembly only in memory.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="OT"> <maml:name>OutputType</maml:name> <maml:Description> <maml:para>Specifies the output type of the output assembly. By default, no output type is specified. This parameter is valid only when an output assembly is specified in the command. For more information about the values, see OutputAssemblyType Enumeration (/dotnet/api/microsoft.powershell.commands.outputassemblytype).</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- ConsoleApplication</maml:para> <maml:para>- Library</maml:para> <maml:para>- WindowsApplication</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">ConsoleApplication</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Library</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">WindowsApplication</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.OutputAssemblyType</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.OutputAssemblyType</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns a System.Runtime object that represents the types that were added. By default, this cmdlet doesn't generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="RA"> <maml:name>ReferencedAssemblies</maml:name> <maml:Description> <maml:para>Specifies the assemblies upon which the type depends. By default, `Add-Type` references `System.dll` and `System.Management.Automation.dll`. The assemblies that you specify by using this parameter are referenced in addition to the default assemblies.</maml:para> <maml:para>You can't use the CompilerParameters and ReferencedAssemblies parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Add-Type</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="CP"> <maml:name>CompilerParameters</maml:name> <maml:Description> <maml:para>Specifies the options for the source code compiler. These options are sent to the compiler without revision.</maml:para> <maml:para>This parameter allows you to direct the compiler to generate an executable file, embed resources, or set command-line options, such as the `/unsafe` option. This parameter implements the CompilerParameters class, System.CodeDom.Compiler.CompilerParameters .</maml:para> <maml:para>You can't use the CompilerParameters and ReferencedAssemblies parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.CodeDom.Compiler.CompilerParameters</command:parameterValue> <dev:type> <maml:name>System.CodeDom.Compiler.CompilerParameters</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>IgnoreWarnings</maml:name> <maml:Description> <maml:para>Ignores compiler warnings. Use this parameter to prevent `Add-Type` from handling compiler warnings as errors.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to source code files or assembly DLL files that contain the types. Unlike Path , the value of the LiteralPath parameter is used exactly as it's typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="OA"> <maml:name>OutputAssembly</maml:name> <maml:Description> <maml:para>Generates a DLL file for the assembly with the specified name in the location. Enter an optional path and file name. Wildcard characters are permitted. By default, `Add-Type` generates the assembly only in memory.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="OT"> <maml:name>OutputType</maml:name> <maml:Description> <maml:para>Specifies the output type of the output assembly. By default, no output type is specified. This parameter is valid only when an output assembly is specified in the command. For more information about the values, see OutputAssemblyType Enumeration (/dotnet/api/microsoft.powershell.commands.outputassemblytype).</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- ConsoleApplication</maml:para> <maml:para>- Library</maml:para> <maml:para>- WindowsApplication</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">ConsoleApplication</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Library</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">WindowsApplication</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.OutputAssemblyType</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.OutputAssemblyType</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns a System.Runtime object that represents the types that were added. By default, this cmdlet doesn't generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="RA"> <maml:name>ReferencedAssemblies</maml:name> <maml:Description> <maml:para>Specifies the assemblies upon which the type depends. By default, `Add-Type` references `System.dll` and `System.Management.Automation.dll`. The assemblies that you specify by using this parameter are referenced in addition to the default assemblies.</maml:para> <maml:para>You can't use the CompilerParameters and ReferencedAssemblies parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="AN"> <maml:name>AssemblyName</maml:name> <maml:Description> <maml:para>Specifies the name of an assembly that includes the types. `Add-Type` takes the types from the specified assembly. This parameter is required when you're creating types based on an assembly name.</maml:para> <maml:para>Enter the full or simple name, also known as the partial name, of an assembly. Wildcard characters are permitted in the assembly name. If you enter a simple or partial name, `Add-Type` resolves it to the full name, and then uses the full name to load the assembly.</maml:para> <maml:para>This parameter doesn't accept a path or a file name. To enter the path to the assembly dynamic-link library (DLL) file, use the Path parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Provider"> <maml:name>CodeDomProvider</maml:name> <maml:Description> <maml:para>Specifies a code generator or compiler. `Add-Type` uses the specified compiler to compile the source code. The default is the C# compiler. Use this parameter if you're using a language that can't be specified by using the Language parameter. The CodeDomProvider that you specify must be able to generate assemblies from source code.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.CodeDom.Compiler.CodeDomProvider</command:parameterValue> <dev:type> <maml:name>System.CodeDom.Compiler.CodeDomProvider</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>C# compiler</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="CP"> <maml:name>CompilerParameters</maml:name> <maml:Description> <maml:para>Specifies the options for the source code compiler. These options are sent to the compiler without revision.</maml:para> <maml:para>This parameter allows you to direct the compiler to generate an executable file, embed resources, or set command-line options, such as the `/unsafe` option. This parameter implements the CompilerParameters class, System.CodeDom.Compiler.CompilerParameters .</maml:para> <maml:para>You can't use the CompilerParameters and ReferencedAssemblies parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.CodeDom.Compiler.CompilerParameters</command:parameterValue> <dev:type> <maml:name>System.CodeDom.Compiler.CompilerParameters</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>IgnoreWarnings</maml:name> <maml:Description> <maml:para>Ignores compiler warnings. Use this parameter to prevent `Add-Type` from handling compiler warnings as errors.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Language</maml:name> <maml:Description> <maml:para>Specifies the language that is used in the source code. The `Add-Type` cmdlet uses the value of this parameter to select the appropriate CodeDomProvider . CSharp is the default value. The acceptable values for this parameter are as follows:</maml:para> <maml:para>- CSharp</maml:para> <maml:para>- CSharpVersion2</maml:para> <maml:para>- CSharpVersion3</maml:para> <maml:para>- JScript</maml:para> <maml:para>- VisualBasic</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.Language</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.Language</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>CSharp</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to source code files or assembly DLL files that contain the types. Unlike Path , the value of the LiteralPath parameter is used exactly as it's typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>MemberDefinition</maml:name> <maml:Description> <maml:para>Specifies new properties or methods for the class. `Add-Type` generates the template code that is required to support the properties or methods.</maml:para> <maml:para>On Windows, you can use this feature to make Platform Invoke (P/Invoke) calls to unmanaged functions in PowerShell.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the name of the class to create. This parameter is required when generating a type from a member definition.</maml:para> <maml:para>The type name and namespace must be unique within a session. You can't unload a type or change it. To change the code for a type, you must change the name or start a new PowerShell session. Otherwise, the command fails.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NS"> <maml:name>Namespace</maml:name> <maml:Description> <maml:para>Specifies a namespace for the type.</maml:para> <maml:para>If this parameter isn't included in the command, the type is created in the Microsoft.PowerShell.Commands.AddType.AutoGeneratedTypes namespace. If the parameter is included in the command with an empty string value or a value of `$Null`, the type is generated in the global namespace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="OA"> <maml:name>OutputAssembly</maml:name> <maml:Description> <maml:para>Generates a DLL file for the assembly with the specified name in the location. Enter an optional path and file name. Wildcard characters are permitted. By default, `Add-Type` generates the assembly only in memory.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="OT"> <maml:name>OutputType</maml:name> <maml:Description> <maml:para>Specifies the output type of the output assembly. By default, no output type is specified. This parameter is valid only when an output assembly is specified in the command. For more information about the values, see OutputAssemblyType Enumeration (/dotnet/api/microsoft.powershell.commands.outputassemblytype).</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- ConsoleApplication</maml:para> <maml:para>- Library</maml:para> <maml:para>- WindowsApplication</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.OutputAssemblyType</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.OutputAssemblyType</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns a System.Runtime object that represents the types that were added. By default, this cmdlet doesn't generate any output.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the path to source code files or assembly DLL files that contain the types.</maml:para> <maml:para>If you submit source code files, `Add-Type` compiles the code in the files and creates an in-memory assembly of the types. The file name extension specified in the value of Path determines the compiler that `Add-Type` uses.</maml:para> <maml:para>If you submit an assembly file, `Add-Type` takes the types from the assembly. To specify an in-memory assembly or the global assembly cache, use the AssemblyName parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="RA"> <maml:name>ReferencedAssemblies</maml:name> <maml:Description> <maml:para>Specifies the assemblies upon which the type depends. By default, `Add-Type` references `System.dll` and `System.Management.Automation.dll`. The assemblies that you specify by using this parameter are referenced in addition to the default assemblies.</maml:para> <maml:para>You can't use the CompilerParameters and ReferencedAssemblies parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>TypeDefinition</maml:name> <maml:Description> <maml:para>Specifies the source code that contains the type definitions. Enter the source code in a string or here-string, or enter a variable that contains the source code. For more information about here-strings, see about_Quoting_Rules (../Microsoft.PowerShell.Core/about/about_Quoting_Rules.md).</maml:para> <maml:para>Include a namespace declaration in your type definition. If you omit the namespace declaration, your type might have the same name as another type or the shortcut for another type, causing an unintentional overwrite. For example, if you define a type called Exception , scripts that use Exception as the shortcut for System.Exception will fail.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Using"> <maml:name>UsingNamespace</maml:name> <maml:Description> <maml:para>Specifies other namespaces that are required for the class. This is much like the C# keyword, `Using`.</maml:para> <maml:para>By default, `Add-Type` references the System namespace. When the MemberDefinition parameter is used, `Add-Type` also references the System.Runtime.InteropServices namespace by default. The namespaces that you add by using the UsingNamespace parameter are referenced in addition to the default namespaces.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>System namespace</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You can't send objects down the pipeline to `Add-Type`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None or System.Type</maml:name> </dev:type> <maml:description> <maml:para>When you use the PassThru parameter, `Add-Type` returns a System.Type object that represents the new type. Otherwise, this cmdlet doesn't generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>The types that you add exist only in the current session. To use the types in all sessions, add them to your PowerShell profile. For more information about the profile, see about_Profiles (../Microsoft.PowerShell.Core/About/about_Profiles.md).</maml:para> <maml:para>Type names and namespaces must be unique within a session. You can't unload a type or change it. If you need to change the code for a type, you must change the name or start a new PowerShell session. Otherwise, the command fails.</maml:para> <maml:para>The CodeDomProvider class for some languages, such as IronPython and J#, doesn't generate output. As a result, types written in these languages can't be used with `Add-Type`.</maml:para> <maml:para>This cmdlet is based on the Microsoft .NET Framework CodeDomProvider Class (/dotnet/api/system.codedom.compiler.codedomprovider).</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>----------- Example 1: Add a .NET type to a session -----------</maml:title> <dev:code>$Source = @" public class BasicTest { public static int Add(int a, int b) { return (a + b); } public int Multiply(int a, int b) { return (a * b); } } "@ Add-Type -TypeDefinition $Source [BasicTest]::Add(4, 3) $BasicTestObject = New-Object BasicTest $BasicTestObject.Multiply(5, 2)</dev:code> <dev:remarks> <maml:para>The `$Source` variable stores the source code for the class. The type has a static method called `Add` and a non-static method called `Multiply`.</maml:para> <maml:para>The `Add-Type` cmdlet adds the class to the session. Because it's using inline source code, the command uses the TypeDefinition parameter to specify the code in the `$Source` variable.</maml:para> <maml:para>The `Add` static method of the BasicTest class uses the double-colon characters (`::`) to specify a static member of the class. The integers are added and the sum is displayed.</maml:para> <maml:para>The `New-Object` cmdlet instantiates an instance of the BasicTest class. It saves the new object in the `$BasicTestObject` variable.</maml:para> <maml:para>`$BasicTestObject` uses the `Multiply` method. The integers are multiplied and the product is displayed.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------------- Example 2: Examine an added type ---------------</maml:title> <dev:code>[BasicTest] | Get-Member TypeName: System.RuntimeType Name MemberType Definition ---- ---------- ---------- AsType Method type AsType() Clone Method System.Object Clone(), System.Object ICloneable.Clone() Equals Method bool Equals(System.Object obj), bool Equals(type o) FindInterfaces Method type[] FindInterfaces(System.Reflection.TypeFilter filter... ... [BasicTest] | Get-Member -Static TypeName: BasicTest Name MemberType Definition ---- ---------- ---------- Add Method static int Add(int a, int b) Equals Method static bool Equals(System.Object objA, System.Object objB) new Method BasicTest new() ReferenceEquals Method static bool ReferenceEquals(System.Object objA, System.Object objB) $BasicTestObject | Get-Member TypeName: BasicTest Name MemberType Definition ---- ---------- ---------- Equals Method bool Equals(System.Object obj) GetHashCode Method int GetHashCode() GetType Method type GetType() Multiply Method int Multiply(int a, int b) ToString Method string ToString()</dev:code> <dev:remarks> <maml:para>The `Get-Member` cmdlet gets the type and members of the BasicTest class that `Add-Type` added to the session. The `Get-Member` command reveals that it's a System.RuntimeType object, which is derived from the System.Object class.</maml:para> <maml:para>The `Get-Member` Static parameter gets the static properties and methods of the BasicTest class. The output shows that the `Add` method is included.</maml:para> <maml:para>The `Get-Member` cmdlet gets the members of the object stored in the `$BasicTestObject` variable. `$BasicTestObject` was created by using the `New-Object` cmdlet with the BasicTest class. The output reveals that the value of the `$BasicTestObject` variable is an instance of the BasicTest class and that it includes a member called `Multiply`.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------ Example 3: Add types from an assembly ------------</maml:title> <dev:code>$AccType = Add-Type -AssemblyName "accessib*" -PassThru</dev:code> <dev:remarks> <maml:para>The `$AccType` variable stores an object created with the `Add-Type` cmdlet. `Add-Type` uses the AssemblyName parameter to specify the name of the assembly. The asterisk (`*`) wildcard character allows you to get the correct assembly even when you aren't sure of the name or its spelling. The PassThru parameter generates objects that represent the classes that are added to the session.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------- Example 4: Call native Windows APIs -------------</maml:title> <dev:code>$Signature = @" [DllImport("user32.dll")]public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); "@ $ShowWindowAsync = Add-Type -MemberDefinition $Signature -Name "Win32ShowWindowAsync" -Namespace Win32Functions -PassThru # Minimize the PowerShell console $ShowWindowAsync::ShowWindowAsync((Get-Process -Id $pid).MainWindowHandle, 2) # Restore the PowerShell console $ShowWindowAsync::ShowWindowAsync((Get-Process -Id $Pid).MainWindowHandle, 4)</dev:code> <dev:remarks> <maml:para>The `$Signature` variable stores the C# signature of the `ShowWindowAsync` function. To ensure that the resulting method will be visible in a PowerShell session, the `public` keyword was added to the standard signature. For more information, see ShowWindowAsync function (/windows/win32/api/winuser/nf-winuser-showwindowasync).</maml:para> <maml:para>The `$ShowWindowAsync` variable stores the object created by the `Add-Type` PassThru parameter. The `Add-Type` cmdlet adds the `ShowWindowAsync` function to the PowerShell session as a static method. The command uses the MemberDefinition parameter to specify the method definition saved in the `$Signature` variable. The command uses the Name and Namespace parameters to specify a name and namespace for the class. The PassThru parameter generates an object that represents the types.</maml:para> <maml:para>The new `ShowWindowAsync` static method is used in the commands to minimize and restore the PowerShell console. The method takes two parameters: the window handle, and an integer that specifies how the window is displayed.</maml:para> <maml:para>To minimize the PowerShell console, `ShowWindowAsync` uses the `Get-Process` cmdlet with the `$PID` automatic variable to get the process that is hosting the current PowerShell session. Then it uses the MainWindowHandle property of the current process and a value of `2`, which represents the `SW_MINIMIZE` value.</maml:para> <maml:para>To restore the window, `ShowWindowAsync` uses a value of `4` for the window position, which represents the `SW_RESTORE` value.</maml:para> <maml:para>To maximize the window, use the value of `3` that represents `SW_MAXIMIZE`.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 5: Add a type from a Visual Basic file --------</maml:title> <dev:code>Add-Type -Path "C:\PS-Test\Hello.vb" [VBFromFile]::SayHello(", World") # From Hello.vb Public Class VBFromFile Public Shared Function SayHello(sourceName As String) As String Dim myValue As String = "Hello" return myValue + sourceName End Function End Class Hello, World</dev:code> <dev:remarks> <maml:para>`Add-Type` uses the Path parameter to specify the source file, `Hello.vb`, and adds the type defined in the file. The `SayHello` function is called as a static method of the VBFromFile class.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 6: Add a class with JScript.NET -----------</maml:title> <dev:code>Add-Type @' class FRectangle { var Length : double; var Height : double; function Perimeter() : double { return (Length + Height) * 2; } function Area() : double { return Length * Height; } } '@ -Language JScript $rect = [FRectangle]::new() $rect Length Height ------ ------ 0 0</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------------- Example 7: Add an F# compiler ----------------</maml:title> <dev:code>Add-Type -Path "FSharp.Compiler.CodeDom.dll" $Provider = New-Object Microsoft.FSharp.Compiler.CodeDom.FSharpCodeProvider $FSharpCode = @" let rec loop n =if n <= 0 then () else beginprint_endline (string_of_int n);loop (n-1)end "@ $FSharpType = Add-Type -TypeDefinition $FSharpCode -CodeDomProvider $Provider -PassThru | Where-Object { $_.IsPublic } $FSharpType::loop(4) 4 3 2 1</dev:code> <dev:remarks> <maml:para>`Add-Type` uses the Path parameter to specify an assembly and gets the types in the assembly. `New-Object` creates an instance of the F# code provider and saves the result in the `$Provider` variable. The `$FSharpCode` variable saves the F# code that defines the Loop method.</maml:para> <maml:para>The the `$FSharpType` variable stores the results of the `Add-Type` cmdlet that saves the public types defined in `$FSharpCode`. The TypeDefinition parameter specifies the source code that defines the types. The CodeDomProvider parameter specifies the source code compiler. The PassThru parameter directs `Add-Type` to return a Runtime object that represents the types. The objects are sent down the pipeline to the `Where-Object` cmdlet, which returns only the public types. The Where-Object cmdlet is used because the F# provider generates non-public types to support the resulting public type.</maml:para> <maml:para>The Loop method is called as a static method of the type stored in the `$FSharpType` variable.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/add-type?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Profiles</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Quoting_Rules</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Add-Member</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>OutputAssemblyType</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Platform Invoke (P/Invoke)</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Where-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Clear-Variable</command:name> <command:verb>Clear</command:verb> <command:noun>Variable</command:noun> <maml:description> <maml:para>Deletes the value of a variable.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Clear-Variable cmdlet deletes the data stored in a variable, but it does not delete the variable. As a result, the value of the variable is NULL (empty). If the variable has a specified data or object type, this cmdlet preserves the type of the object stored in the variable.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Clear-Variable</maml:name> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the name of the variable to be cleared. Wildcards are permitted. This parameter is required, but the parameter name ("Name") is optional.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Exclude</maml:name> <maml:Description> <maml:para>Specifies an array of items that this cmdlet omits in the operation. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as "s*". Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Allows the cmdlet to clear a variable even if it is read-only. Even using the Force parameter, the cmdlet cannot clear constants.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Include</maml:name> <maml:Description> <maml:para>Specifies an array of items that this cmdlet includes in the operation. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as "s*". Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope in which this alias is valid.</maml:para> <maml:para>The acceptable values for this parameter are:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Script</maml:para> <maml:para></maml:para> <maml:para>You can also use a number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent). Local is the default. For more information, see about_Scopes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Exclude</maml:name> <maml:Description> <maml:para>Specifies an array of items that this cmdlet omits in the operation. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as "s*". Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Allows the cmdlet to clear a variable even if it is read-only. Even using the Force parameter, the cmdlet cannot clear constants.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Include</maml:name> <maml:Description> <maml:para>Specifies an array of items that this cmdlet includes in the operation. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as "s*". Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the name of the variable to be cleared. Wildcards are permitted. This parameter is required, but the parameter name ("Name") is optional.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope in which this alias is valid.</maml:para> <maml:para>The acceptable values for this parameter are:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Script</maml:para> <maml:para></maml:para> <maml:para>You can also use a number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent). Local is the default. For more information, see about_Scopes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe objects to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None or System.Management.Automation.PSVariable</maml:name> </dev:type> <maml:description> <maml:para>When you use the PassThru parameter, this cmdlet generates a System.Management.Automation.PSVariable object representing the cleared variable. Otherwise, this cmdlet does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>* To delete a variable, along with its value, use Remove-Variable or Remove-Item.</maml:para> <maml:para> This cmdlet does not delete the values of variables that are set as constants or owned by the system, even if you use the Force parameter.</maml:para> <maml:para> If the variable that you are clearing does not exist, the cmdlet has no effect. It does not create a variable with a null value.</maml:para> <maml:para> You can also refer to Clear-Variable by its built-in alias, clv. For more information, see about_Aliases.</maml:para> <maml:para>*</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>Example 1: Remove the value of global variables that begin with a search string</maml:title> <dev:code>PS C:\> Clear-Variable my* -Scope Global</dev:code> <dev:remarks> <maml:para>This command removes the value of global variables that have names that begin with my.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 2: Clear a variable in a child scope but not the parent scope</maml:title> <dev:code>PS C:\> $a=3 PS C:\> &{ Clear-Variable a } PS C:\> $a 3</dev:code> <dev:remarks> <maml:para>These commands demonstrate that clearing a variable in a child scope does not clear the value in the parent scope. The first command sets the value of the variable $A to 3. The second command uses the invoke operator (&) to run the Clear-Variable command in a new scope. The variable is cleared in the child scope (although it did not exist), but it is not cleared in the local scope. The third command, which gets the value of $A, shows that the value 3 is unaffected.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 3: Delete the value of the specified variable ----</maml:title> <dev:code>PS C:\> Clear-Variable -Name "Processes"</dev:code> <dev:remarks> <maml:para>This command deletes the value of the variable named Processes. After the cmdlet completes the operation, the variable named Processes still exists, but the value is null.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/clear-variable?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Compare-Object</command:name> <command:verb>Compare</command:verb> <command:noun>Object</command:noun> <maml:description> <maml:para>Compares two sets of objects.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Compare-Object` cmdlet compares two sets of objects. One set of objects is the reference , and the other set of objects is the difference .</maml:para> <maml:para>`Compare-Object` checks for available methods of comparing a whole object. If it can't find a suitable method, it call the ToString() methods of the input objects and compares the string results. You can provide one or more properties to be used for comparison. When properties are provided, the cmdlet compares the values of those properties only.</maml:para> <maml:para>The result of the comparison indicates whether a property value appeared only in the reference object (`<=`) or only in the difference object (`=>`). If the IncludeEqual parameter is used, (`==`) indicates the value is in both objects.</maml:para> <maml:para>If the reference or the difference objects are null (`$null`), `Compare-Object` generates a terminating error.</maml:para> <maml:para>Some examples use splatting to reduce the line length of the code samples. For more information, see about_Splatting (../Microsoft.PowerShell.Core/About/about_Splatting.md).</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Compare-Object</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>ReferenceObject</maml:name> <maml:Description> <maml:para>Specifies an array of objects used as a reference for comparison.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="1" aliases="none"> <maml:name>DifferenceObject</maml:name> <maml:Description> <maml:para>Specifies the objects that are compared to the reference objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CaseSensitive</maml:name> <maml:Description> <maml:para>Indicates that comparisons should be case-sensitive.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Culture</maml:name> <maml:Description> <maml:para>Specifies the culture to use for comparisons.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ExcludeDifferent</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet displays only the characteristics of compared objects that are equal. The differences between the objects are discarded.</maml:para> <maml:para>Use ExcludeDifferent with IncludeEqual to display only the lines that match between the reference and difference objects.</maml:para> <maml:para>If ExcludeDifferent is specified without IncludeEqual , there's no output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>IncludeEqual</maml:name> <maml:Description> <maml:para>IncludeEqual displays the matches between the reference and difference objects.</maml:para> <maml:para>By default, the output also includes the differences between the reference and difference objects.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>When you use the PassThru parameter, `Compare-Object` omits the PSCustomObject wrapper around the compared objects and returns the differing objects, unchanged.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies an array of properties of the reference and difference objects to compare.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SyncWindow</maml:name> <maml:Description> <maml:para>Specifies the number of adjacent objects that `Compare-Object` inspects while looking for a match in a collection of objects. `Compare-Object` examines adjacent objects when it doesn't find the object in the same position in a collection. The default value is `[Int32]::MaxValue`, which means that `Compare-Object` examines the entire object collection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>[Int32]::MaxValue</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CaseSensitive</maml:name> <maml:Description> <maml:para>Indicates that comparisons should be case-sensitive.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Culture</maml:name> <maml:Description> <maml:para>Specifies the culture to use for comparisons.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="1" aliases="none"> <maml:name>DifferenceObject</maml:name> <maml:Description> <maml:para>Specifies the objects that are compared to the reference objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ExcludeDifferent</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet displays only the characteristics of compared objects that are equal. The differences between the objects are discarded.</maml:para> <maml:para>Use ExcludeDifferent with IncludeEqual to display only the lines that match between the reference and difference objects.</maml:para> <maml:para>If ExcludeDifferent is specified without IncludeEqual , there's no output.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>IncludeEqual</maml:name> <maml:Description> <maml:para>IncludeEqual displays the matches between the reference and difference objects.</maml:para> <maml:para>By default, the output also includes the differences between the reference and difference objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>When you use the PassThru parameter, `Compare-Object` omits the PSCustomObject wrapper around the compared objects and returns the differing objects, unchanged.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies an array of properties of the reference and difference objects to compare.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>ReferenceObject</maml:name> <maml:Description> <maml:para>Specifies an array of objects used as a reference for comparison.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SyncWindow</maml:name> <maml:Description> <maml:para>Specifies the number of adjacent objects that `Compare-Object` inspects while looking for a match in a collection of objects. `Compare-Object` examines adjacent objects when it doesn't find the object in the same position in a collection. The default value is `[Int32]::MaxValue`, which means that `Compare-Object` examines the entire object collection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>[Int32]::MaxValue</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can send an object down the pipeline to the DifferenceObject parameter.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>If the reference object and the difference object are the same, there's no output, unless you use the IncludeEqual parameter.</maml:para> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.PSCustomObject</maml:name> </dev:type> <maml:description> <maml:para>If the objects are different, `Compare-Object` wraps the differing objects in a `PSCustomObject` wrapper with a SideIndicator property to reference the differences.</maml:para> <maml:para>When you use the PassThru parameter, the Type of the object is not changed but the instance of the object returned has an added NoteProperty named SideIndicator . SideIndicator shows which input object the output belongs to.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>When using the PassThru parameter, the output displayed in the console may not include the SideIndicator property. The default format view of the for the object type output by `Compare-Object` does not include the SideIndicator property. For more information see Example 3 (#ex3)in this article.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------ Example 1 - Compare the content of two text files ------</maml:title> <dev:code>Compare-Object -ReferenceObject (Get-Content -Path C:\Test\Testfile1.txt) -DifferenceObject (Get-Content -Path C:\Test\Testfile2.txt) InputObject SideIndicator ----------- ------------- cat => racoon => dog <= squirrel <=</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 2 - Compare each line of content and exclude the differences</maml:title> <dev:code>$objects = @{ ReferenceObject = (Get-Content -Path C:\Test\Testfile1.txt) DifferenceObject = (Get-Content -Path C:\Test\Testfile2.txt) } Compare-Object @objects -IncludeEqual -ExcludeDifferent InputObject SideIndicator ----------- ------------- bird ==</dev:code> <dev:remarks> <maml:para><a id="ex3" /></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 3 - Show the difference when using the PassThru parameter</maml:title> <dev:code>$a = $True Compare-Object -IncludeEqual $a $a (Compare-Object -IncludeEqual $a $a) | Get-Member InputObject SideIndicator ----------- ------------- True == TypeName: System.Management.Automation.PSCustomObject Name MemberType Definition ---- ---------- ---------- Equals Method bool Equals(System.Object obj) GetHashCode Method int GetHashCode() GetType Method type GetType() ToString Method string ToString() InputObject NoteProperty System.Boolean InputObject=True SideIndicator NoteProperty string SideIndicator=== Compare-Object -IncludeEqual $a $a -PassThru (Compare-Object -IncludeEqual $a $a -PassThru) | Get-Member True TypeName: System.Boolean Name MemberType Definition ---- ---------- ---------- CompareTo Method int CompareTo(System.Object obj), int CompareTo(bool value), int IComparable.CompareTo(Syst Equals Method bool Equals(System.Object obj), bool Equals(bool obj), bool IEquatable[bool].Equals(bool ot GetHashCode Method int GetHashCode() GetType Method type GetType() GetTypeCode Method System.TypeCode GetTypeCode(), System.TypeCode IConvertible.GetTypeCode() ToBoolean Method bool IConvertible.ToBoolean(System.IFormatProvider provider) ToByte Method byte IConvertible.ToByte(System.IFormatProvider provider) ToChar Method char IConvertible.ToChar(System.IFormatProvider provider) ToDateTime Method datetime IConvertible.ToDateTime(System.IFormatProvider provider) ToDecimal Method decimal IConvertible.ToDecimal(System.IFormatProvider provider) ToDouble Method double IConvertible.ToDouble(System.IFormatProvider provider) ToInt16 Method short IConvertible.ToInt16(System.IFormatProvider provider) ToInt32 Method int IConvertible.ToInt32(System.IFormatProvider provider) ToInt64 Method long IConvertible.ToInt64(System.IFormatProvider provider) ToSByte Method sbyte IConvertible.ToSByte(System.IFormatProvider provider) ToSingle Method float IConvertible.ToSingle(System.IFormatProvider provider) ToString Method string ToString(), string ToString(System.IFormatProvider provider), string IConvertible.To ToType Method System.Object IConvertible.ToType(type conversionType, System.IFormatProvider provider) ToUInt16 Method ushort IConvertible.ToUInt16(System.IFormatProvider provider) ToUInt32 Method uint IConvertible.ToUInt32(System.IFormatProvider provider) ToUInt64 Method ulong IConvertible.ToUInt64(System.IFormatProvider provider) TryFormat Method bool TryFormat(System.Span[char] destination, [ref] int charsWritten) SideIndicator NoteProperty string SideIndicator===</dev:code> <dev:remarks> <maml:para>When using PassThru , the original object type ( System.Boolean ) is returned. Note how the output displayed by the default format for System.Boolean objects didn't display the SideIndicator property. However, the returned System.Boolean object has the added NoteProperty .</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--- Example 4 - Compare two simple objects using properties ---</maml:title> <dev:code>Compare-Object -ReferenceObject 'abc' -DifferenceObject 'xyz' -Property Length -IncludeEqual Length SideIndicator ------ ------------- 3 ==</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 5 - Comparing complex objects using properties ----</maml:title> <dev:code>PS> Get-Process pwsh NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName ------ ----- ----- ------ -- -- ----------- 101 123.32 139.10 35.81 11168 1 pwsh 89 107.55 66.97 11.44 17600 1 pwsh PS> $a = Get-Process -Id 11168 PS> $b = Get-Process -Id 17600 PS> $a.ToString() System.Diagnostics.Process (pwsh) PS> $b.ToString() System.Diagnostics.Process (pwsh) PS> Compare-Object $a $b -IncludeEqual InputObject SideIndicator ----------- ------------- System.Diagnostics.Process (pwsh) == PS> Compare-Object $a $b -Property ProcessName, Id, CPU ProcessName Id CPU SideIndicator ----------- -- --- ------------- pwsh 17600 11.4375 => pwsh 11168 36.203125 <=</dev:code> <dev:remarks> <maml:para>When you specify properties to be compared, the cmdlet shows the differences.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 6 - Comparing complex objects that implement IComparable</maml:title> <dev:code>Compare-Object ([TimeSpan]"0:0:1") "0:0:1" -IncludeEqual InputObject SideIndicator ----------- ------------- 00:00:01 == Compare-Object "0:0:1" ([TimeSpan]"0:0:1") InputObject SideIndicator ----------- ------------- 00:00:01 => 0:0:1 <=</dev:code> <dev:remarks> <maml:para>In the second case, the TimeSpan is converted to a string so the object are different.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/compare-object?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ForEach-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Group-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Measure-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Select-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Sort-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Tee-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Where-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Process</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Convert-String</command:name> <command:verb>Convert</command:verb> <command:noun>String</command:noun> <maml:description> <maml:para>Formats a string to match examples.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Convert-String cmdlet formats a string to match the format of examples.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Convert-String</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="E"> <maml:name>Example</maml:name> <maml:Description> <maml:para>Specifies a list of examples of the target format. Specify pairs separated by the equal (=) sign, with the source pattern on the left and the target pattern on the right, as in the following examples:</maml:para> <maml:para>* `-Example "Hello World=World, Hello"`</maml:para> <maml:para>* `-Example "Hello World=World: Hello",'"Hello","1"=1: Hello'`</maml:para> <maml:para></maml:para> <maml:para>> Note >The second example uses a list of patterns</maml:para> <maml:para>Alternatively, specify a list of hash tables that contain Before and After properties.</maml:para> <maml:para>* `-Example @{before='"Hello","World"'; after='World: Hello'}, @{before='"Hello","1"'; after='1: Hello'}`</maml:para> <maml:para>> Caution >Avoid using spaces around the equal sign, >as they are treated as part of the pattern.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Collections.Generic.List`1[System.Management.Automation.PSObject]</command:parameterValue> <dev:type> <maml:name>System.Collections.Generic.List`1[System.Management.Automation.PSObject]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies a string to format.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="E"> <maml:name>Example</maml:name> <maml:Description> <maml:para>Specifies a list of examples of the target format. Specify pairs separated by the equal (=) sign, with the source pattern on the left and the target pattern on the right, as in the following examples:</maml:para> <maml:para>* `-Example "Hello World=World, Hello"`</maml:para> <maml:para>* `-Example "Hello World=World: Hello",'"Hello","1"=1: Hello'`</maml:para> <maml:para></maml:para> <maml:para>> Note >The second example uses a list of patterns</maml:para> <maml:para>Alternatively, specify a list of hash tables that contain Before and After properties.</maml:para> <maml:para>* `-Example @{before='"Hello","World"'; after='World: Hello'}, @{before='"Hello","1"'; after='1: Hello'}`</maml:para> <maml:para>> Caution >Avoid using spaces around the equal sign, >as they are treated as part of the pattern.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Collections.Generic.List`1[System.Management.Automation.PSObject]</command:parameterValue> <dev:type> <maml:name>System.Collections.Generic.List`1[System.Management.Automation.PSObject]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies a string to format.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe strings to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>String</maml:name> </dev:type> <maml:description> <maml:para>This cmdlet returns a string.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------ Example 1: Convert format of a string ------------</maml:title> <dev:code>"Mu Han", "Jim Hance", "David Ahs", "Kim Akers" | Convert-String -Example "Ed Wilson=Wilson, E." Han, M. Hance, J. Ahs, D. Akers, K.</dev:code> <dev:remarks> <maml:para>The first command creates an array that contains first and last names.</maml:para> <maml:para>The second command formats the names according to the example. It puts the surname first in the output, followed by an initial.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------ Example 2: Simplify format of a string ------------</maml:title> <dev:code>$composers = @("Johann Sebastian Bach", "Wolfgang Amadeus Mozart", "Frederic Francois Chopin", "Johannes Brahms") $composers | Convert-String -Example "first middle last=last, first" Bach, Johann Mozart, Wolfgang Chopin, Frederic Brahms, Johannes</dev:code> <dev:remarks> <maml:para>The first command creates an array that contains first, middle and last names. Note that the last entry has no middle name.</maml:para> <maml:para>The second command formats the names according to the example. It puts the last name first in the output, followed by the first name. All middle names removed; entry without middle name is handled correctly.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title> Example 3: Output management when strings don't match example </maml:title> <dev:code>$composers = @("Johann Sebastian Bach", "Wolfgang Amadeus Mozart", "Frederic Francois Chopin", "Johannes Brahms") $composers | Convert-String -Example "first middle last=middle, first" Sebastian, Johann Amadeus, Wolfgang Francois, Frederic</dev:code> <dev:remarks> <maml:para>The first command creates an array that contains first, middle and last names. Note that the last entry has no middle name.</maml:para> <maml:para>The second command formats the names according to the example. It puts the middle name first in the output, followed by the first name. The last entry in $Composers is skipped, because it doesn't match the sample pattern: it has no middle name.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------ Example 4: Caution with beauty spaces ------------</maml:title> <dev:code>$composers = @("Antonio Vivaldi", "Richard Wagner ", "Franz Schubert", "Johannes Brahms ") $composers | Convert-String -Example "Patti Fuller = Fuller, P." Wagner, R. Brahms, J.</dev:code> <dev:remarks> <maml:para>The first command creates an array of first and last names. Note that second and fourth items have an extra trailing space, after the last name.</maml:para> <maml:para>The second command converts all strings that match the sample pattern: word, space, word, and final trailing space , all of this before the equal sign. Also, note the leading space in the output.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>- Example 5: Format process information with multiple patterns -</maml:title> <dev:code>$ExamplePatterns = @( @{before='"Hello","World"'; after='World: Hello'}, @{before='"Hello","1"'; after='1: Hello'}, @{before='"Hello-World","22"'; after='22: Hello-World'}, @{before='"hello world","333"'; after='333: hello world'} ) $Processes = Get-Process | Select-Object -Property ProcessName, Id | ConvertTo-Csv -NoTypeInformation $Processes | Convert-String -Example $ExamplePatterns Id: ProcessName 4368: AGSService 8896: Amazon Music Helper 4420: AppleMobileDeviceService ... 11140: git-bash 0: Idle ... 56: Secure System ... 13028: WmiPrvSE 2724: WUDFHost 2980: WUDFHost 3348: WUDFHost</dev:code> <dev:remarks> <maml:para>$ExamplePatterns defines different expected patterns in the data, through examples.</maml:para> <maml:para>The first pattern, `@{before='"Hello","World"'; after='World: Hello'}`, reads as follows: expect strings where a word comes enclosed in double quotes, then a comma, and then the second, and last, word enclosed in quotes; with no spaces in the string. On the output: place second word first, without quotes, then a single space, and then the first word, without quotes. The second pattern, `@{before='"Hello","1"'; after='1: Hello'}`, reads as follows: expect strings where a word comes enclosed in double quotes, then a comma, and then a number enclosed in quotes; with no spaces in the string. On the output: place the number first, without quotes, then a single space, and then the word, without quotes. The third pattern, `@{before='"Hello-World","22"'; after='22: Hello-World'}`, reads as follows: expect strings where two words with a hyphen in between come enclosed in double quotes, then a comma, and then a number enclosed in quotes; with no spaces between the comma and the third double quote. On the output: place the number first, without quotes, then a single space, and then the hyphenated words, without quotes. The fourth, and final, pattern, `@{before='"hello world","333"'; after='333: hello world'}`, reads as follows: expect strings where two words with a space in between come enclosed in double quotes, then a comma, and then a number enclosed in quotes; with no spaces between the comma and the third double quote. On the output: place the number first, without quotes, then a single space, and then the words with the space in between, without quotes. The first command gets all processes by using the Get-Process cmdlet. The command passes them to the Select-Object cmdlet, which selects the process name and process ID. At the end of the pipeline, the command converts the output to comma separated values, without type information, by using the ConvertTo-Csv cmdlet. The command stores the results in the $Processes variable. $Processes now contains process names and PID.</maml:para> <maml:para>The second command specifies an example variable that changes the order of the input items. The command coverts each string in $Processes .</maml:para> <maml:para>> Note >The fourth pattern implicitly says that two or more words >separated by spaces are matched. > >Without the fourth pattern, only the first word of the string enclosed in >double quotes is matched.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/convert-string?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertFrom-String</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-Csv</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Process</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-String</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Select-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>ConvertFrom-Csv</command:name> <command:verb>ConvertFrom</command:verb> <command:noun>Csv</command:noun> <maml:description> <maml:para>Converts object properties in comma-separated value (CSV) format into CSV versions of the original objects.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `ConvertFrom-Csv` cmdlet creates objects from CSV variable-length strings that are generated by the `ConvertTo-Csv` cmdlet.</maml:para> <maml:para>You can use the parameters of this cmdlet to specify the column header row, which determines the property names of the resulting objects, to specify the item delimiter, or to direct this cmdlet to use the list separator for the current culture as the delimiter.</maml:para> <maml:para>The objects that `ConvertFrom-Csv` creates are CSV versions of the original objects. The property values of the CSV objects are string versions of the property values of the original objects. The CSV versions of the objects do not have any methods.</maml:para> <maml:para>You can also use the `Export-Csv` and `Import-Csv` cmdlets to convert objects to CSV strings in a file (and back). These cmdlets are the same as the `ConvertTo-Csv` and `ConvertFrom-Csv` cmdlets, except that they save the CSV strings in a file.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>ConvertFrom-Csv</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the CSV strings to be converted to objects. Enter a variable that contains the CSV strings or type a command or expression that gets the CSV strings. You can also pipe the CSV strings to `ConvertFrom-Csv`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Delimiter</maml:name> <maml:Description> <maml:para>Specifies the delimiter that separates the property values in the CSV strings. The default is a comma (,).</maml:para> <maml:para>Enter a character, such as a colon (:). To specify a semicolon (;) enclose it in single quotation marks.</maml:para> <maml:para>If you specify a character other than the actual string delimiter in the file, `ConvertFrom-Csv` cannot create the objects from the CSV strings and will return the CSV strings.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Char</command:parameterValue> <dev:type> <maml:name>System.Char</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>comma (,)</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Header</maml:name> <maml:Description> <maml:para>Specifies an alternate column header row for the imported string. The column header determines the property names of the objects created by `ConvertFrom-Csv`.</maml:para> <maml:para>Enter column headers as a comma-separated list. Do not enclose the header string in quotation marks. Enclose each column header in single quotation marks.</maml:para> <maml:para>If you enter fewer column headers than there are data columns, the remaining data columns are discarded. If you enter more column headers than there are data columns, the additional column headers are created with empty data columns.</maml:para> <maml:para>When using the Header parameter, omit the column header string from the CSV strings. Otherwise, this cmdlet creates an extra object from the items in the header row.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>ConvertFrom-Csv</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the CSV strings to be converted to objects. Enter a variable that contains the CSV strings or type a command or expression that gets the CSV strings. You can also pipe the CSV strings to `ConvertFrom-Csv`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Header</maml:name> <maml:Description> <maml:para>Specifies an alternate column header row for the imported string. The column header determines the property names of the objects created by `ConvertFrom-Csv`.</maml:para> <maml:para>Enter column headers as a comma-separated list. Do not enclose the header string in quotation marks. Enclose each column header in single quotation marks.</maml:para> <maml:para>If you enter fewer column headers than there are data columns, the remaining data columns are discarded. If you enter more column headers than there are data columns, the additional column headers are created with empty data columns.</maml:para> <maml:para>When using the Header parameter, omit the column header string from the CSV strings. Otherwise, this cmdlet creates an extra object from the items in the header row.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseCulture</maml:name> <maml:Description> <maml:para>Uses the list separator for the current culture as the item delimiter. To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Delimiter</maml:name> <maml:Description> <maml:para>Specifies the delimiter that separates the property values in the CSV strings. The default is a comma (,).</maml:para> <maml:para>Enter a character, such as a colon (:). To specify a semicolon (;) enclose it in single quotation marks.</maml:para> <maml:para>If you specify a character other than the actual string delimiter in the file, `ConvertFrom-Csv` cannot create the objects from the CSV strings and will return the CSV strings.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Char</command:parameterValue> <dev:type> <maml:name>System.Char</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>comma (,)</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Header</maml:name> <maml:Description> <maml:para>Specifies an alternate column header row for the imported string. The column header determines the property names of the objects created by `ConvertFrom-Csv`.</maml:para> <maml:para>Enter column headers as a comma-separated list. Do not enclose the header string in quotation marks. Enclose each column header in single quotation marks.</maml:para> <maml:para>If you enter fewer column headers than there are data columns, the remaining data columns are discarded. If you enter more column headers than there are data columns, the additional column headers are created with empty data columns.</maml:para> <maml:para>When using the Header parameter, omit the column header string from the CSV strings. Otherwise, this cmdlet creates an extra object from the items in the header row.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the CSV strings to be converted to objects. Enter a variable that contains the CSV strings or type a command or expression that gets the CSV strings. You can also pipe the CSV strings to `ConvertFrom-Csv`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseCulture</maml:name> <maml:Description> <maml:para>Uses the list separator for the current culture as the item delimiter. To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe CSV strings to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>This cmdlet returns the objects described by the properties in the CSV strings.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>Because the imported objects are CSV versions of the object type, they are not recognized and formatted by the PowerShell type formatting entries that format the non-CSV versions of the object type.</maml:para> <maml:para>In CSV format, each object is represented by a comma-separated list of the property values of the object. The property values are converted to strings (by using the ToString() method of the object), so they are represented by the name of the property value. This cmdlet does not export the methods of the object.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>Example 1: Convert processes on the local computer to CSV format</maml:title> <dev:code>$P = Get-Process | ConvertTo-Csv $P | ConvertFrom-Csv</dev:code> <dev:remarks> <maml:para>The `Get-Process` cmdlet sends the processes down the pipeline to `ConvertTo-Csv`. The `ConvertTo-Csv` cmdlet converts the process objects to a series of CSV strings. The `ConvertFrom-Csv` cmdlet converts the CSV strings into CSV versions of the original process objects. The CSV strings are saved in the `$P` variable.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 2: Convert a data object to CSV format and then to CSV object format</maml:title> <dev:code>$Date = Get-Date | ConvertTo-Csv -Delimiter ';' ConvertFrom-Csv -InputObject $Date -Delimiter ';'</dev:code> <dev:remarks> <maml:para>The first command uses `Get-Date` to send the current date and time down the pipeline to `ConvertTo-Csv`. The `ConvertTo-Csv` cmdlet converts the date object to a series of CSV strings. The Delimiter parameter is used to specify a semicolon delimiter. The strings are saved in the `$Date` variable.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 3: Use the header parameter to change the names of properties</maml:title> <dev:code>$J = Start-Job -ScriptBlock { Get-Process } | ConvertTo-Csv -NoTypeInformation $Header = 'State', 'MoreData', 'StatusMessage', 'Location', 'Command', 'StateInfo', 'Finished', 'InstanceId', 'Id', 'Name', 'ChildJobs', 'BeginTime', 'EndTime', 'JobType', 'Output', 'Error', 'Progress', 'Verbose', 'Debug', 'Warning', 'Information' # Delete the default header from $J $J = $J[1..($J.count - 1)] $J | ConvertFrom-Csv -Header $Header State : Running MoreData : True StatusMessage : Location : localhost Command : Get-Process StateInfo : Running Finished : System.Threading.ManualResetEvent InstanceId : a259eb63-6824-4b97-a033-305108ae1c2e Id : 1 Name : Job1 ChildJobs : System.Collections.Generic.List`1[System.Management.Automation.Job] BeginTime : 12/20/2018 18:59:57 EndTime : JobType : BackgroundJob Output : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] Error : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] Progress : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] Verbose : System.Management.Automation.PSDataCollection`1[System.Management.Automation.VerboseRecord] Debug : System.Management.Automation.PSDataCollection`1[System.Management.Automation.DebugRecord] Warning : System.Management.Automation.PSDataCollection`1[System.Management.Automation.WarningRecord] Information : System.Management.Automation.PSDataCollection`1[System.Management.Automation.InformationRecord]</dev:code> <dev:remarks> <maml:para>The `Start-Job` cmdlet starts a background job that runs `Get-Process`. A job object is sent down the pipeline to `ConvertTo-Csv` and converted to a CSV string. The NoTypeInformation parameter removes the type information header from CSV output and is optional in PowerShell Core. The `$Header` variable contains a custom header that replaces the following default values: HasMoreData , JobStateInfo , PSBeginTime , PSEndTime , and PSJobTypeName . The `$J` variable contains the CSV string and is used to remove the default header. The `ConvertFrom-Csv` cmdlet converts the CSV string into a PSCustomObject and uses the Header parameter to apply the `$Header` variable.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 4: Convert CSV strings of service objects ------</maml:title> <dev:code>(Get-Culture).TextInfo.ListSeparator $Services = (Get-Service | ConvertTo-Csv) ConvertFrom-Csv -InputObject $Services -UseCulture</dev:code> <dev:remarks> <maml:para>The `Get-Culture` cmdlet uses the nested properties TextInfo and ListSeparator to get the current culture's default list separator. The `Get-Service` cmdlet sends service objects down the pipeline to `ConvertTo-Csv`. The `ConvertTo-Csv` converts the service objects to a series of CSV strings. The CSV strings are stored in the `$Services` variable. The `ConvertFrom-Csv` cmdlet uses the InputObject parameter and converts the CSV strings from the `$Services` variable. The UseCulture parameter uses the current culture's default list separator.</maml:para> <maml:para>When the UseCulture parameter is used, be sure that the current culture's default list separator matches the delimiter used in the CSV strings. Otherwise, `ConvertFrom-Csv` cannot generate objects from the CSV strings.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/convertfrom-csv?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-Csv</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Export-Csv</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Import-Csv</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>ConvertFrom-Json</command:name> <command:verb>ConvertFrom</command:verb> <command:noun>Json</command:noun> <maml:description> <maml:para>Converts a JSON-formatted string to a custom object.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `ConvertFrom-Json` cmdlet converts a JavaScript Object Notation (JSON) formatted string to a custom PSCustomObject object that has a property for each field in the JSON string. JSON is commonly used by web sites to provide a textual representation of objects. The JSON standard does not prohibit usage that is prohibited with a PSCustomObject . For example, if the JSON string contains duplicate keys, only the last key is used by this cmdlet. See other examples below.</maml:para> <maml:para>To generate a JSON string from any object, use the `ConvertTo-Json` cmdlet.</maml:para> <maml:para>This cmdlet was introduced in PowerShell 3.0.</maml:para> <maml:para>> [!NOTE] > This cmdlet doesn't support JSON with comments.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>ConvertFrom-Json</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the JSON strings to convert to JSON objects. Enter a variable that contains the string, or type a command or expression that gets the string. You can also pipe a string to `ConvertFrom-Json`.</maml:para> <maml:para>The InputObject parameter is required, but its value can be an empty string. When the input object is an empty string, `ConvertFrom-Json` does not generate any output. The InputObject value cannot be `$null`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the JSON strings to convert to JSON objects. Enter a variable that contains the string, or type a command or expression that gets the string. You can also pipe a string to `ConvertFrom-Json`.</maml:para> <maml:para>The InputObject parameter is required, but its value can be an empty string. When the input object is an empty string, `ConvertFrom-Json` does not generate any output. The InputObject value cannot be `$null`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a JSON string to `ConvertFrom-Json`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>PSCustomObject</maml:name> </dev:type> <maml:description> <maml:para></maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>The `ConvertFrom-Json` cmdlet is implemented using the JavaScriptSerializer class (/dotnet/api/system.web.script.serialization.javascriptserializer).</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>---- Example 1: Convert a DateTime object to a JSON object ----</maml:title> <dev:code>Get-Date | Select-Object -Property * | ConvertTo-Json | ConvertFrom-Json DisplayHint : 2 DateTime : Friday, January 13, 2012 8:06:31 PM Date : 1/13/2012 8:00:00 AM Day : 13 DayOfWeek : 5 DayOfYear : 13 Hour : 20 Kind : 2 Millisecond : 400 Minute : 6 Month : 1 Second : 31 Ticks : 634620819914009002 TimeOfDay : @{Ticks=723914009002; Days=0; Hours=20; Milliseconds=400; Minutes=6; Seconds=31; TotalDays=0.83786343634490734; TotalHours=20.108722472277776; TotalMilliseconds=72391400.900200009; TotalMinutes=1206.5233483366667;TotalSeconds=72391.4009002} Year : 2012</dev:code> <dev:remarks> <maml:para>The example uses the `Select-Object` cmdlet to get all of the properties of the DateTime object. It uses the `ConvertTo-Json` cmdlet to convert the DateTime object to a string formatted as a JSON object and the `ConvertFrom-Json` cmdlet to convert the JSON-formatted string to a PSCustomObject object.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 2: Get JSON strings from a web service and convert them to PowerShell objects</maml:title> <dev:code># Ensures that Invoke-WebRequest uses TLS 1.2 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $j = Invoke-WebRequest 'https://api.github.com/repos/PowerShell/PowerShell/issues' | ConvertFrom-Json</dev:code> <dev:remarks> <maml:para>You can also use the `Invoke-RestMethod` cmdlet, which automatically converts JSON content to objects.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 3: Convert a JSON string to a custom object -----</maml:title> <dev:code>Get-Content JsonFile.JSON | ConvertFrom-Json</dev:code> <dev:remarks> <maml:para>The command uses Get-Content cmdlet to get the strings in a JSON file. Then it uses the pipeline operator to send the delimited string to the `ConvertFrom-Json` cmdlet, which converts it to a custom object.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/convertfrom-json?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>An Introduction to JavaScript Object Notation (JSON) in JavaScript and .NET</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-Json</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Invoke-WebRequest</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Invoke-RestMethod</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>ConvertFrom-String</command:name> <command:verb>ConvertFrom</command:verb> <command:noun>String</command:noun> <maml:description> <maml:para>Extracts and parses structured properties from string content.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The ConvertFrom-String cmdlet extracts and parses structured properties from string content. This cmdlet generates an object by parsing text from a traditional text stream. For each string in the pipeline, the cmdlet splits the input by either a delimiter or a parse expression, and then assigns property names to each of the resulting split elements. You can provide these property names; if you do not, they are automatically generated for you.</maml:para> <maml:para>The cmdlet's default parameter set, ByDelimiter , splits exactly on the regular expression delimiter. It does not perform quote matching or delimiter escaping as the `Import-Csv` cmdlet does.</maml:para> <maml:para>The cmdlet's alternate parameter set, TemplateParsing , generates elements from the groups that are captured by a regular expression. For more information on regular expressions, see about_Regular_Expressions (../Microsoft.PowerShell.Core/About/about_Regular_Expressions.md).</maml:para> <maml:para>This cmdlet supports two modes: basic delimited parsing, and automatically-generated, example-driven parsing.</maml:para> <maml:para>Delimited parsing, by default, splits the input at white space, and assigns property names to the resulting groups.</maml:para> <maml:para>You can customize the delimiter by piping the `ConvertFrom-String` results into one of the `Format- ` cmdlets, or you can use the Delimiter * parameter.</maml:para> <maml:para>The cmdlet also supports automatically-generated, example-driven parsing based on the FlashExtract, research work by Microsoft Research (https://www.microsoft.com/en-us/research/publication/flashextract-framework-data-extraction-examples/?from=http%3A%2F%2Fresearch.microsoft.com%2Fen-us%2Fum%2Fpeople%2Fsumitg%2Fflashextract.html).</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>ConvertFrom-String</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies strings received from the pipeline, or a variable that contains a string object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="DEL"> <maml:name>Delimiter</maml:name> <maml:Description> <maml:para>Specifies a regular expression that identifies the boundary between elements. Elements that are created by the split become properties in the resulting object. The delimiter is ultimately used in a call to the Split method of the type `[System.Text.RegularExpressions.RegularExpression]`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PN"> <maml:name>PropertyNames</maml:name> <maml:Description> <maml:para>Specifies an array of property names to which to assign split values in the resulting object. Every line of text that you split or parse generates elements that represent property values. If the element is the result of a capture group, and that capture group is named (for example, `(?<name>)` or `(?'name')` ), then the name of that capture group is assigned to the property.</maml:para> <maml:para>If you provide any elements in the PropertyName array, those names are assigned to properties that have not yet been named.</maml:para> <maml:para>If you provide more property names than there are fields, PowerShell ignores the extra property names. If you do not specify enough property names to name all fields, PowerShell automatically assigns numerical property names to any properties that are not named: P1 , P2 , etc.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>ConvertFrom-String</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies strings received from the pipeline, or a variable that contains a string object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="IE"> <maml:name>IncludeExtent</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet includes an extent text property that is removed by default.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="TC"> <maml:name>TemplateContent</maml:name> <maml:Description> <maml:para>Specifies an expression, or an expression saved as a variable, that describes the properties to which this cmdlet assigns strings. The syntax of a template field specification is the following: `{[optional-typecast]<name>:<example-value>}`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="TF"> <maml:name>TemplateFile</maml:name> <maml:Description> <maml:para>Specifies a file, as an array, that contains a template for the desired parsing of the string. In the template file, properties and their values are enclosed in brackets, as shown below. If a property, such as the Name property and its associated other properties, appears multiple times, you can add an asterisk (`*`) to indicate that this results in multiple records. This avoids extracting multiple properties into a single record.</maml:para> <maml:para></maml:para> <maml:para>{Name*:David Chew}</maml:para> <maml:para>{City:Redmond}, {State:WA}</maml:para> <maml:para>{Name*:Evan Narvaez} {Name*:Antonio Moreno}</maml:para> <maml:para>{City:Issaquah}, {State:WA}</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="UT"> <maml:name>UpdateTemplate</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet saves the results of a learning algorithm into a comment in the template file. This makes the algorithm learning process faster. To use this parameter, you must also specify a template file with the TemplateFile parameter.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="DEL"> <maml:name>Delimiter</maml:name> <maml:Description> <maml:para>Specifies a regular expression that identifies the boundary between elements. Elements that are created by the split become properties in the resulting object. The delimiter is ultimately used in a call to the Split method of the type `[System.Text.RegularExpressions.RegularExpression]`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="IE"> <maml:name>IncludeExtent</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet includes an extent text property that is removed by default.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies strings received from the pipeline, or a variable that contains a string object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PN"> <maml:name>PropertyNames</maml:name> <maml:Description> <maml:para>Specifies an array of property names to which to assign split values in the resulting object. Every line of text that you split or parse generates elements that represent property values. If the element is the result of a capture group, and that capture group is named (for example, `(?<name>)` or `(?'name')` ), then the name of that capture group is assigned to the property.</maml:para> <maml:para>If you provide any elements in the PropertyName array, those names are assigned to properties that have not yet been named.</maml:para> <maml:para>If you provide more property names than there are fields, PowerShell ignores the extra property names. If you do not specify enough property names to name all fields, PowerShell automatically assigns numerical property names to any properties that are not named: P1 , P2 , etc.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="TC"> <maml:name>TemplateContent</maml:name> <maml:Description> <maml:para>Specifies an expression, or an expression saved as a variable, that describes the properties to which this cmdlet assigns strings. The syntax of a template field specification is the following: `{[optional-typecast]<name>:<example-value>}`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="TF"> <maml:name>TemplateFile</maml:name> <maml:Description> <maml:para>Specifies a file, as an array, that contains a template for the desired parsing of the string. In the template file, properties and their values are enclosed in brackets, as shown below. If a property, such as the Name property and its associated other properties, appears multiple times, you can add an asterisk (`*`) to indicate that this results in multiple records. This avoids extracting multiple properties into a single record.</maml:para> <maml:para></maml:para> <maml:para>{Name*:David Chew}</maml:para> <maml:para>{City:Redmond}, {State:WA}</maml:para> <maml:para>{Name*:Evan Narvaez} {Name*:Antonio Moreno}</maml:para> <maml:para>{City:Issaquah}, {State:WA}</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="UT"> <maml:name>UpdateTemplate</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet saves the results of a learning algorithm into a comment in the template file. This makes the algorithm learning process faster. To use this parameter, you must also specify a template file with the TemplateFile parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para></maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues /> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-- Example 1: Generate an object with default property names --</maml:title> <dev:code>"Hello World" | ConvertFrom-String P1 P2 -- -- Hello World</dev:code> <dev:remarks> <maml:para>This command generates an object with default property names, P1 and P2 .</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 1A: Get to know the generated object ---------</maml:title> <dev:code>"Hello World" | ConvertFrom-String | Get-Member TypeName: System.Management.Automation.PSCustomObject Name MemberType Definition ---- ---------- ---------- Equals Method bool Equals(System.Object obj) GetHashCode Method int GetHashCode() GetType Method type GetType() ToString Method string ToString() P1 NoteProperty string P1=Hello P2 NoteProperty string P2=World</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 2: Generate an object with default property names using a delimiter</maml:title> <dev:code>"Contoso\Administrator" | ConvertFrom-String -Delimiter "\\" P1 P2 -- -- Contoso Administrator</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 3: Generate an object that contains two named properties</maml:title> <dev:code>$content = Get-Content C:\Windows\System32\drivers\etc\hosts $content = $content -match "^[^#]" $content | ConvertFrom-String -PropertyNames IP, Server IP Server -- ------ 192.168.7.10 W2012R2 192.168.7.20 W2016 192.168.7.101 WIN8 192.168.7.102 WIN10</dev:code> <dev:remarks> <maml:para>The `Get-Content` cmdlet stores the content of a Windows hosts file in `$content`. The second command removes any comments at the beginning of the hosts file using a regular expression that matches any line that does not start with (`#`). The last command converts the remaining text into objects with Server and IP properties.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 4: Use an expression as the value of the TemplateContent parameter, save the results in a variable.</maml:title> <dev:code>$template = @' {Name*:Phoebe Cat}, {phone:425-123-6789}, {age:6} {Name*:Lucky Shot}, {phone:(206) 987-4321}, {age:12} '@ $testText = @' Phoebe Cat, 425-123-6789, 6 Lucky Shot, (206) 987-4321, 12 Elephant Wise, 425-888-7766, 87 Wild Shrimp, (111) 222-3333, 1 '@ $PersonalData = $testText | ConvertFrom-String -TemplateContent $template Write-output ("Pet items found: " + ($PersonalData.Count)) $PersonalData Pet items found: 4 Name phone age ---- ----- --- Phoebe Cat 425-123-6789 6 Lucky Shot (206) 987-4321 12 Elephant Wise 425-888-7766 87 Wild Shrimp (111) 222-3333 1</dev:code> <dev:remarks> <maml:para>Each line in the input is evaluated by the sample matches. If the line matches the examples given in the pattern, values are extracted and passed to the output variable.</maml:para> <maml:para>The sample data, `$template`, provides two different phone formats:</maml:para> <maml:para>- `425-123-6789`</maml:para> <maml:para>- `(206) 987-4321`</maml:para> <maml:para></maml:para> <maml:para>The sample data also provides two different age formats:</maml:para> <maml:para>- `6`</maml:para> <maml:para>- `12`</maml:para> <maml:para></maml:para> <maml:para>This implies that phones like `(206) 987 4321` will not be recognized, because there's no sample data that matches that pattern because there are no hyphens.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>- Example 5: Specifying data types to the generated properties -</maml:title> <dev:code>$template = @' {[string]Name*:Phoebe Cat}, {[string]phone:425-123-6789}, {[int]age:6} {[string]Name*:Lucky Shot}, {[string]phone:(206) 987-4321}, {[int]age:12} '@ $testText = @' Phoebe Cat, 425-123-6789, 6 Lucky Shot, (206) 987-4321, 12 Elephant Wise, 425-888-7766, 87 Wild Shrimp, (111) 222-3333, 1 '@ $PersonalData = $testText | ConvertFrom-String -TemplateContent $template Write-output ("Pet items found: " + ($PersonalData.Count)) $PersonalData Pet items found: 4 Name phone age ---- ----- --- Phoebe Cat 425-123-6789 6 Lucky Shot (206) 987-4321 12 Elephant Wise 425-888-7766 87 Wild Shrimp (111) 222-3333 1 $PersonalData | Get-Member TypeName: System.Management.Automation.PSCustomObject Name MemberType Definition ---- ---------- ---------- Equals Method bool Equals(System.Object obj) GetHashCode Method int GetHashCode() GetType Method type GetType() ToString Method string ToString() age NoteProperty int age=6 Name NoteProperty string Name=Phoebe Cat phone NoteProperty string phone=425-123-6789</dev:code> <dev:remarks> <maml:para>The `Get-Member` cmdlet is used to show that the age property is an integer.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/convertfrom-string?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertFrom-String: Example-based text parsing</maml:linkText> <maml:uri>https://devblogs.microsoft.com/powershell/convertfrom-string-example-based-text-parsing/</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertFrom-StringData</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertFrom-Csv</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-Xml</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>ConvertFrom-StringData</command:name> <command:verb>ConvertFrom</command:verb> <command:noun>StringData</command:noun> <maml:description> <maml:para>Converts a string containing one or more key and value pairs to a hash table.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `ConvertFrom-StringData` cmdlet converts a string that contains one or more key and value pairs into a hash table. Because each key-value pair must be on a separate line, here-strings are often used as the input format. By default, the key must be separated from the value by an equals sign (`=`) character.</maml:para> <maml:para>The `ConvertFrom-StringData` cmdlet is considered to be a safe cmdlet that can be used in the `DATA` section of a script or function. When used in a `DATA` section, the contents of the string must conform to the rules for a DATA section. For more information, see about_Data_Sections (../Microsoft.PowerShell.Core/About/about_Data_Sections.md).</maml:para> <maml:para>`ConvertFrom-StringData` supports escape character sequences that are allowed by conventional machine translation tools. That is, the cmdlet can interpret backslashes (``) as escape characters in the string data by using the Regex.Unescape Method (/dotnet/api/system.text.regularexpressions.regex.unescape), instead of the PowerShell backtick character (`) that would normally signal the end of a line in a script. Inside the here-string, the backtick character does not work. You can also preserve a literal backslash in your results by escaping it with a preceding backslash, like this: `\`. Unescaped backslash characters, such as those that are commonly used in file paths, can render as illegal escape sequences in your results.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>ConvertFrom-StringData</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>StringData</maml:name> <maml:Description> <maml:para>Specifies the string to be converted. You can use this parameter or pipe a string to `ConvertFrom-StringData`. The parameter name is optional.</maml:para> <maml:para>The value of this parameter must be a string that contains one or more key-value pairs. Each key-value pair must be on a separate line, or each pair must be separated by newline characters (`n).</maml:para> <maml:para>You can include comments in the string, but the comments cannot be on the same line as a key-value pair. `ConvertFrom-StringData` ignores single-line comments. The `#` character must be the first non-whitespace character on the line. All characters on the line after the `#` are ignored. The comments are not included in the hash table.</maml:para> <maml:para>A here-string is a string consisting of one or more lines. Quotation marks within the here-string are interpreted literally as part of the string data. For more information, see about_Quoting_Rules (../Microsoft.PowerShell.Core/About/about_Quoting_Rules.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>StringData</maml:name> <maml:Description> <maml:para>Specifies the string to be converted. You can use this parameter or pipe a string to `ConvertFrom-StringData`. The parameter name is optional.</maml:para> <maml:para>The value of this parameter must be a string that contains one or more key-value pairs. Each key-value pair must be on a separate line, or each pair must be separated by newline characters (`n).</maml:para> <maml:para>You can include comments in the string, but the comments cannot be on the same line as a key-value pair. `ConvertFrom-StringData` ignores single-line comments. The `#` character must be the first non-whitespace character on the line. All characters on the line after the `#` are ignored. The comments are not included in the hash table.</maml:para> <maml:para>A here-string is a string consisting of one or more lines. Quotation marks within the here-string are interpreted literally as part of the string data. For more information, see about_Quoting_Rules (../Microsoft.PowerShell.Core/About/about_Quoting_Rules.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a string containing a key-value pair to `ConvertFrom-StringData`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Collections.Hashtable</maml:name> </dev:type> <maml:description> <maml:para>This cmdlet returns a hash table that it creates from the key-value pairs.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>A here-string is a string consisting of one or more lines within which quotation marks are interpreted literally.</maml:para> <maml:para>This cmdlet can be useful in scripts that display user messages in multiple spoken languages. You can use the dictionary-style hash tables to isolate text strings from code, such as in resource files, and to format the text strings for use in translation tools.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>Example 1: Convert a single-quoted here-string to a hash table</maml:title> <dev:code>$Here = @' Msg1 = The string parameter is required. Msg2 = Credentials are required for this command. Msg3 = The specified variable does not exist. '@ ConvertFrom-StringData -StringData $Here Name Value ---- ----- Msg3 The specified variable does not exist. Msg2 Credentials are required for this command. Msg1 The string parameter is required.</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 2: Convert a here-string containing a comment ----</maml:title> <dev:code>ConvertFrom-StringData -StringData @' Name = Disks.ps1 # Category is optional. Category = Storage Cost = Free '@ Name Value ---- ----- Cost Free Category Storage Name Disks.ps1</dev:code> <dev:remarks> <maml:para>The value of the StringData parameter is a here-string, instead of a variable that contains a here-string. Either format is valid. The here-string includes a comment about one of the strings. `ConvertFrom-StringData` ignores single-line comments, but the `#` character must be the first non-whitespace character on the line. All characters on the line after the `#` are ignored.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 3: Convert a string to a hash table ---------</maml:title> <dev:code>$A = ConvertFrom-StringData -StringData "Top = Red `n Bottom = Blue" $A Name Value ---- ----- Bottom Blue Top Red</dev:code> <dev:remarks> <maml:para>To satisfy the condition that each key-value pair must be on a separate line, the string uses the PowerShell newline character (`n) to separate the pairs.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 4: Use ConvertFrom-StringData in the DATA section of a script</maml:title> <dev:code>$TextMsgs = DATA { ConvertFrom-StringData @' Text001 = The $Notebook variable contains the name of the user's system notebook. Text002 = The $MyNotebook variable contains the name of the user's private notebook. '@ } $TextMsgs Name Value ---- ----- Text001 The $Notebook variable contains the name of the user's system notebook. Text002 The $MyNotebook variable contains the name of the user's private notebook.</dev:code> <dev:remarks> <maml:para>Because the text includes variable names, it must be enclosed in a single-quoted string so that the variables are interpreted literally and not expanded. Variables are not permitted in the DATA section.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 5: Use the pipeline operator to pass a string ----</maml:title> <dev:code>$Here = @' Msg1 = The string parameter is required. Msg2 = Credentials are required for this command. Msg3 = The specified variable does not exist. '@ $Hash = $Here | ConvertFrom-StringData $Hash Name Value ---- ----- Msg3 The specified variable does not exist. Msg2 Credentials are required for this command. Msg1 The string parameter is required.</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 6: Use escape characters to add new lines and return characters</maml:title> <dev:code>ConvertFrom-StringData @" Vincentio = Heaven doth with us as we with torches do,\nNot light them for themselves; for if our virtues\nDid not go forth of us, 'twere all alike\nAs if we had them not. Angelo = Let there be some more test made of my metal,\nBefore so noble and so great a figure\nBe stamp'd upon it. "@ | Format-List Name : Angelo Value : Let there be some more test made of my metal, Before so noble and so great a figure Be stamp'd upon it. Name : Vincentio Value : Heaven doth with us as we with torches do, Not light them for themselves; for if our virtues Did not go forth of us, 'twere all alike As if we had them not.</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 7: Use backslash escape character to correctly render a file path</maml:title> <dev:code>ConvertFrom-StringData "Message=Look in c:\\Windows\\System32" Name Value ---- ----- Message Look in c:\Windows\System32</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/convertfrom-stringdata?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>ConvertTo-Csv</command:name> <command:verb>ConvertTo</command:verb> <command:noun>Csv</command:noun> <maml:description> <maml:para>Converts .NET objects into a series of comma-separated value (CSV) strings.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `ConvertTo-CSV` cmdlet returns a series of comma-separated value (CSV) strings that represent the objects that you submit. You can then use the `ConvertFrom-Csv` cmdlet to recreate objects from the CSV strings. The objects converted from CSV are string values of the original objects that contain property values and no methods.</maml:para> <maml:para>You can use the `Export-Csv` cmdlet to convert objects to CSV strings. `Export-CSV` is similar to `ConvertTo-CSV`, except that it saves the CSV strings to a file.</maml:para> <maml:para>The `ConvertTo-CSV` cmdlet has parameters to specify a delimiter other than a comma or use the current culture as the delimiter.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>ConvertTo-Csv</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects that are converted to CSV strings. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe objects to `ConvertTo-CSV`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Delimiter</maml:name> <maml:Description> <maml:para>Specifies the delimiter to separate the property values in CSV strings. The default is a comma (`,`). Enter a character, such as a colon (`:`). To specify a semicolon (`;`) enclose it in single quotation marks.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Char</command:parameterValue> <dev:type> <maml:name>System.Char</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>comma (,)</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NTI"> <maml:name>NoTypeInformation</maml:name> <maml:Description> <maml:para>Removes the #TYPE information header from the output. This parameter became the default in PowerShell 6.0 and is included for backwards compatibility.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>ConvertTo-Csv</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects that are converted to CSV strings. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe objects to `ConvertTo-CSV`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NTI"> <maml:name>NoTypeInformation</maml:name> <maml:Description> <maml:para>Removes the #TYPE information header from the output. This parameter became the default in PowerShell 6.0 and is included for backwards compatibility.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseCulture</maml:name> <maml:Description> <maml:para>Uses the list separator for the current culture as the item delimiter. To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Delimiter</maml:name> <maml:Description> <maml:para>Specifies the delimiter to separate the property values in CSV strings. The default is a comma (`,`). Enter a character, such as a colon (`:`). To specify a semicolon (`;`) enclose it in single quotation marks.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Char</command:parameterValue> <dev:type> <maml:name>System.Char</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>comma (,)</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects that are converted to CSV strings. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe objects to `ConvertTo-CSV`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NTI"> <maml:name>NoTypeInformation</maml:name> <maml:Description> <maml:para>Removes the #TYPE information header from the output. This parameter became the default in PowerShell 6.0 and is included for backwards compatibility.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseCulture</maml:name> <maml:Description> <maml:para>Uses the list separator for the current culture as the item delimiter. To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe any object that has an Extended Type System (ETS) adapter to `ConvertTo-CSV`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>The CSV output is returned as a collection of strings.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>In CSV format, each object is represented by a comma-separated list of its property value. The property values are converted to strings using the object's ToString() method. The strings are represented by the property value name. `ConvertTo-CSV` does not export the object's methods.</maml:para> <maml:para>The CSV strings are output as follows:</maml:para> <maml:para>- By default the first string contains the #TYPE information header followed by the object type's fully qualified name. For example, #TYPE System.Diagnostics.Process . - If NoTypeInformation is used the first string includes the column headers. The headers contain the first object's property names as a comma-separated list. - The remaining strings contain comma-separated lists of each object's property values.</maml:para> <maml:para>When you submit multiple objects to `ConvertTo-CSV`, `ConvertTo-CSV` orders the strings based on the properties of the first object that you submit. If the remaining objects do not have one of the specified properties, the property value of that object is Null, as represented by two consecutive commas. If the remaining objects have additional properties, those property values are ignored.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------- Example 1: Convert an object to CSV -------------</maml:title> <dev:code>Get-Process -Name 'PowerShell' | ConvertTo-Csv -NoTypeInformation "Name","SI","Handles","VM","WS","PM","NPM","Path","Company","CPU","FileVersion", ... "powershell","11","691","2204036739072","175943680","132665344","33312", ...</dev:code> <dev:remarks> <maml:para>The `Get-Process` cmdlet gets the Process object and uses the Name parameter to specify the PowerShell process. The process object is sent down the pipeline to the `ConvertTo-CSV` cmdlet. The `ConvertTo-CSV` cmdlet converts the object to CSV strings. The NoTypeInformation parameter removes the #TYPE information header from the CSV output.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 2: Convert a DateTime object to CSV ---------</maml:title> <dev:code>$Date = Get-Date ConvertTo-Csv -InputObject $Date -Delimiter ';' -NoTypeInformation "DisplayHint";"DateTime";"Date";"Day";"DayOfWeek";"DayOfYear";"Hour";"Kind";"Millisecond";"Minute";"Month";"Second";"Ticks";"TimeOfDay";"Year" "DateTime";"Friday, January 4, 2019 14:40:51";"1/4/2019 00:00:00";"4";"Friday";"4";"14";"Local";"711";"40";"1";"51";"636822096517114991";"14:40:51.7114991";"2019"</dev:code> <dev:remarks> <maml:para>The `Get-Date` cmdlet gets the DateTime object and saves it in the `$Date` variable. The `ConvertTo-Csv` cmdlet converts the DateTime object to strings. The InputObject parameter uses the DateTime object stored in the `$Date` variable. The Delimiter parameter specifies a semicolon to separate the string values. The NoTypeInformation parameter removes the #TYPE information header from the CSV output.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 3: Convert the PowerShell event log to CSV ------</maml:title> <dev:code>(Get-Culture).TextInfo.ListSeparator Get-WinEvent -LogName 'Windows PowerShell' | ConvertTo-Csv -UseCulture -NoTypeInformation , "Message","Id","Version","Qualifiers","Level","Task","Opcode","Keywords","RecordId", ... "Error Message = System error","403",,"0","4","4",,"36028797018963968","46891","PowerShell", ...</dev:code> <dev:remarks> <maml:para>The `Get-Culture` cmdlet uses the nested properties TextInfo and ListSeparator and displays the current culture's default list separator. The `Get-WinEvent` cmdlet gets the event log objects and uses the LogName parameter to specify the log file name. The event log objects are sent down the pipeline to the `ConvertTo-Csv` cmdlet. The `ConvertTo-Csv` cmdlet converts the event log objects to a series of CSV strings. The UseCulture parameter uses the current culture's default list separator as the delimiter. The NoTypeInformation parameter removes the #TYPE information header from the CSV output.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/convertto-csv?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertFrom-Csv</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Export-Csv</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Import-Csv</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>ConvertTo-Html</command:name> <command:verb>ConvertTo</command:verb> <command:noun>Html</command:noun> <maml:description> <maml:para>Converts .NET objects into HTML that can be displayed in a Web browser.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `ConvertTo-Html` cmdlet converts .NET objects into HTML that can be displayed in a Web browser. You can use this cmdlet to display the output of a command in a Web page.</maml:para> <maml:para>You can use the parameters of `ConvertTo-Html` to select object properties, to specify a table or list format, to specify the HTML page title, to add text before and after the object, and to return only the table or list fragment, instead of a strict DTD page.</maml:para> <maml:para>When you submit multiple objects to `ConvertTo-Html`, PowerShell creates the table (or list) based on the properties of the first object that you submit. If the remaining objects do not have one of the specified properties, the property value of that object is an empty cell. If the remaining objects have additional properties, those property values are not included in the file.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>ConvertTo-Html</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Includes the specified properties of the objects in the HTML. The value of the Property parameter can be a new calculated property.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Head</maml:name> <maml:Description> <maml:para>Specifies the content of the `<HEAD>` tag. The default is `<title>HTML TABLE</title>`. If you use the Head parameter, the Title parameter is ignored.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none"> <maml:name>Title</maml:name> <maml:Description> <maml:para>Specifies a title for the HTML file, that is, the text that appears between the `<TITLE>` tags.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="3" aliases="none"> <maml:name>Body</maml:name> <maml:Description> <maml:para>Specifies the text to add after the opening `<BODY>` tag. By default, there is no text in that position.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>As</maml:name> <maml:Description> <maml:para>Determines whether the object is formatted as a table or a list. Valid values are Table and List . The default value is Table .</maml:para> <maml:para>The Table value generates an HTML table that resembles the PowerShell table format. The header row displays the property names. Each table row represents an object and displays the object's values for each property.</maml:para> <maml:para>The List value generates a two-column HTML table for each object that resembles the PowerShell list format. The first column displays the property name. The second column displays the property value.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Table</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">List</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cu, uri"> <maml:name>CssUri</maml:name> <maml:Description> <maml:para>Specifies the Uniform Resource Identifier (URI) of the cascading style sheet (CSS) that is applied to the HTML file. The URI is included in a style sheet link in the output.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Uri</command:parameterValue> <dev:type> <maml:name>System.Uri</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be represented in HTML. Enter a variable that contains the objects or type a command or expression that gets the objects.</maml:para> <maml:para>If you use this parameter to submit multiple objects, such as all of the services on a computer, `ConvertTo-Html` creates a table that displays the properties of a collection or of an array of objects. To create a table of the individual objects, use the pipeline operator to pipe the objects to `ConvertTo-Html`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PostContent</maml:name> <maml:Description> <maml:para>Specifies text to add after the closing `</TABLE>` tag. By default, there is no text in that position.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PreContent</maml:name> <maml:Description> <maml:para>Specifies text to add before the opening `<TABLE>` tag. By default, there is no text in that position.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>ConvertTo-Html</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Includes the specified properties of the objects in the HTML. The value of the Property parameter can be a new calculated property.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>As</maml:name> <maml:Description> <maml:para>Determines whether the object is formatted as a table or a list. Valid values are Table and List . The default value is Table .</maml:para> <maml:para>The Table value generates an HTML table that resembles the PowerShell table format. The header row displays the property names. Each table row represents an object and displays the object's values for each property.</maml:para> <maml:para>The List value generates a two-column HTML table for each object that resembles the PowerShell list format. The first column displays the property name. The second column displays the property value.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Table</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">List</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Fragment</maml:name> <maml:Description> <maml:para>Generates only an HTML table. The HTML, HEAD, TITLE, and BODY tags are omitted.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be represented in HTML. Enter a variable that contains the objects or type a command or expression that gets the objects.</maml:para> <maml:para>If you use this parameter to submit multiple objects, such as all of the services on a computer, `ConvertTo-Html` creates a table that displays the properties of a collection or of an array of objects. To create a table of the individual objects, use the pipeline operator to pipe the objects to `ConvertTo-Html`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PostContent</maml:name> <maml:Description> <maml:para>Specifies text to add after the closing `</TABLE>` tag. By default, there is no text in that position.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PreContent</maml:name> <maml:Description> <maml:para>Specifies text to add before the opening `<TABLE>` tag. By default, there is no text in that position.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>As</maml:name> <maml:Description> <maml:para>Determines whether the object is formatted as a table or a list. Valid values are Table and List . The default value is Table .</maml:para> <maml:para>The Table value generates an HTML table that resembles the PowerShell table format. The header row displays the property names. Each table row represents an object and displays the object's values for each property.</maml:para> <maml:para>The List value generates a two-column HTML table for each object that resembles the PowerShell list format. The first column displays the property name. The second column displays the property value.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="3" aliases="none"> <maml:name>Body</maml:name> <maml:Description> <maml:para>Specifies the text to add after the opening `<BODY>` tag. By default, there is no text in that position.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cu, uri"> <maml:name>CssUri</maml:name> <maml:Description> <maml:para>Specifies the Uniform Resource Identifier (URI) of the cascading style sheet (CSS) that is applied to the HTML file. The URI is included in a style sheet link in the output.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Uri</command:parameterValue> <dev:type> <maml:name>System.Uri</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Fragment</maml:name> <maml:Description> <maml:para>Generates only an HTML table. The HTML, HEAD, TITLE, and BODY tags are omitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Head</maml:name> <maml:Description> <maml:para>Specifies the content of the `<HEAD>` tag. The default is `<title>HTML TABLE</title>`. If you use the Head parameter, the Title parameter is ignored.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be represented in HTML. Enter a variable that contains the objects or type a command or expression that gets the objects.</maml:para> <maml:para>If you use this parameter to submit multiple objects, such as all of the services on a computer, `ConvertTo-Html` creates a table that displays the properties of a collection or of an array of objects. To create a table of the individual objects, use the pipeline operator to pipe the objects to `ConvertTo-Html`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PostContent</maml:name> <maml:Description> <maml:para>Specifies text to add after the closing `</TABLE>` tag. By default, there is no text in that position.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PreContent</maml:name> <maml:Description> <maml:para>Specifies text to add before the opening `<TABLE>` tag. By default, there is no text in that position.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Includes the specified properties of the objects in the HTML. The value of the Property parameter can be a new calculated property.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none"> <maml:name>Title</maml:name> <maml:Description> <maml:para>Specifies a title for the HTML file, that is, the text that appears between the `<TITLE>` tags.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe any .NET object to `ConvertTo-Html`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.String or System.Xml.XmlDocument</maml:name> </dev:type> <maml:description> <maml:para>`ConvertTo-Html` returns series of strings that comprise valid HTML.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>To use this cmdlet, pipe one or more objects to the cmdlet or use the InputObject parameter to specify the object. When the input consists of multiple objects, the output of these two methods is quite different.</maml:para> <maml:para>- When you pipe multiple objects to a cmdlet, PowerShell sends the objects to the cmdlet one at a time. As a result, `ConvertTo-Html` creates a table that displays the individual objects. For example, if you pipe the processes on a computer to `ConvertTo-Html`, the resulting table displays all of the processes.</maml:para> <maml:para>- When you use the InputObject parameter to submit multiple objects, `ConvertTo-Html` receives these objects as a collection or as an array. As a result, it creates a table that displays the array and its properties, not the items in the array. For example, if you use InputObject to submit the processes on a computer to `ConvertTo-Html`, the resulting table displays an object array and its properties.</maml:para> <maml:para> To comply with the XHTML Strict DTD, the DOCTYPE tag is modified accordingly:</maml:para> <maml:para> `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">`</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------- Example 1: Create a web page to display the date -------</maml:title> <dev:code>ConvertTo-Html -InputObject (Get-Date)</dev:code> <dev:remarks> <maml:para>This command creates an HTML page that displays the properties of the current date. It uses the InputObject parameter to submit the results of a `Get-Date` command to the `ConvertTo-Html` cmdlet.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 2: Create a web page to display PowerShell aliases --</maml:title> <dev:code>Get-Alias | ConvertTo-Html | Out-File aliases.htm Invoke-Item aliases.htm</dev:code> <dev:remarks> <maml:para>This command creates an HTML page that lists the PowerShell aliases in the current console.</maml:para> <maml:para>The command uses the `Get-Alias` cmdlet to get the aliases. It uses the pipeline operator (`|`) to send the aliases to the `ConvertTo-Html` cmdlet, which creates the HTML page. The command also uses the `Out-File` cmdlet to send the HTML code to the `aliases.htm` file.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 3: Create a web page to display PowerShell events --</maml:title> <dev:code>`Get-EventLog` -LogName "Windows PowerShell" | ConvertTo-Html | Out-File pslog.htm</dev:code> <dev:remarks> <maml:para>This command creates an HTML page called `pslog.htm` that displays the events in the Windows PowerShell event log on the local computer.</maml:para> <maml:para>It uses the `Get-EventLog` cmdlet to get the events in the Windows PowerShell log and then uses the pipeline operator (`|`) to send the events to the `ConvertTo-Html` cmdlet. The command also uses the `Out-File` cmdlet to send the HTML code to the `pslog.htm` file.</maml:para> <maml:para>The command also uses the `Out-File` cmdlet to send the HTML code to the `pslog.htm` file.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 4: Create a web page to display processes ------</maml:title> <dev:code>Get-Process | ConvertTo-Html -Property Name, Path, Company -Title "Process Information" | Out-File proc.htm Invoke-Item proc.htm</dev:code> <dev:remarks> <maml:para>These commands create and open an HTML page that lists the name, path, and company of the processes on the local computer.</maml:para> <maml:para>The first command uses the `Get-Process` cmdlet to get objects that represent the processes running on the computer. The command uses the pipeline operator (`|`) to send the process objects to the `ConvertTo-Html` cmdlet.</maml:para> <maml:para>The command uses the Property parameter to select three properties of the process objects to be included in the table. The command uses the Title parameter to specify a title for the HTML page. The command also uses the `Out-File` cmdlet to send the resulting HTML to a file named Proc.htm.</maml:para> <maml:para>The second command uses the `Invoke-Item` cmdlet to open the `Proc.htm` in the default browser.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--- Example 5: Create a web page to display service objects ---</maml:title> <dev:code>Get-Service | ConvertTo-Html -CssUri "test.css" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>HTML TABLE</title> <link rel="stylesheet" type="text/css" href="test.css" /> ...</dev:code> <dev:remarks> <maml:para>This command creates an HTML page of the service objects that the `Get-Service` cmdlet returns. The command uses the CssUri parameter to specify a cascading style sheet for the HTML page.</maml:para> <maml:para>The CssUri parameter adds an additional `<link rel="stylesheet" type="text/css" href="test.css">` tag to the resulting HTML. The HREF attribute in the tag contains the name of the style sheet.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--- Example 6: Create a web page to display service objects ---</maml:title> <dev:code>Get-Service | ConvertTo-Html -As LIST | Out-File services.htm</dev:code> <dev:remarks> <maml:para>This command creates an HTML page of the service objects that the `Get-Service` cmdlet returns. The command uses the As parameter to specify a list format. The cmdlet `Out-File` sends the resulting HTML to the `Services.htm` file.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 7: Create a web table for the current date ------</maml:title> <dev:code>Get-Date | ConvertTo-Html -Fragment <table> <colgroup>...</colgroup> <tr><th>DisplayHint</th><th>DateTime</th><th>Date</th><th>Day</th><th>DayOfWeek</th><th>DayOfYear</th><th>Hour</th> <th>Kind</th><th>Millisecond</th><th>Minute</th><th>Month</th><th>Second</th><th>Ticks</th><th>TimeOfDay</th><th>Year</th></tr> <tr><td>DateTime</td><td>Monday, May 05, 2008 10:40:04 AM</td><td>5/5/2008 12:00:00 AM</td><td>5</td><td>Monday</td> <td>126</td><td>10</td><td>Local</td><td>123</td><td>40</td><td>5</td><td>4</td><td>633455808041237213</td><td>10:40:04.12 37213</td><td>2008</td></tr> </table></dev:code> <dev:remarks> <maml:para>This command uses `ConvertTo-Html` to generate an HTML table of the current date. The command uses the `Get-Date` cmdlet to get the current date. It uses a pipeline operator (|) to send the results to the `ConvertTo-Html` cmdlet.</maml:para> <maml:para>The `ConvertTo-Html` command includes the Fragment parameter, which limits the output to an HTML table. As a result, the other elements of an HTML page, such as the `<HEAD>` and `<BODY>` tags, are omitted.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 8: Create a web page to display PowerShell events --</maml:title> <dev:code>Get-EventLog -Log "Windows PowerShell" | ConvertTo-Html -Property id, level, task</dev:code> <dev:remarks> <maml:para>This command uses the `Get-EventLog` cmdlet to get events from the Windows PowerShell event log.</maml:para> <maml:para>It uses a pipeline operator (`|`) to send the events to the `ConvertTo-Html` cmdlet, which converts the events to HTML format.</maml:para> <maml:para>The `ConvertTo-Html` command uses the Property parameter to select only the ID , Level , and Task properties of the event.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 9: Create a web page to display specified services --</maml:title> <dev:code>$htmlParams = @{ Title = "Windows Services: Server01" Body = Get-Date PreContent = "<P>Generated by Corporate IT</P>" PostContent = "For details, contact Corporate IT." } Get-Service A* | ConvertTo-Html @htmlParams | Out-File Services.htm Invoke-Item Services.htm</dev:code> <dev:remarks> <maml:para>This command creates and opens a Web page that displays the services on the computer that begin with A. It uses the Title , Body , PreContent , and PostContent parameters of `ConvertTo-Html` to customize the output.</maml:para> <maml:para>The first part of the command uses the `Get-Service` cmdlet to get the services on the computer that begin with A. The command uses a pipeline operator (`|`) to send the results to the `ConvertTo-Html` cmdlet. The command also uses the `Out-File` cmdlet to send the output to the Services.htm file.</maml:para> <maml:para>A semicolon (`;`) ends the first command and starts a second command, which uses the `Invoke-Item` cmdlet to open the `Services.htm` file in the default browser.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/convertto-html?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-Csv</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-Json</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-Xml</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Export-Clixml</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Import-Clixml</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>ConvertTo-Json</command:name> <command:verb>ConvertTo</command:verb> <command:noun>Json</command:noun> <maml:description> <maml:para>Converts an object to a JSON-formatted string.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `ConvertTo-Json` cmdlet converts any .NET object to a string in JavaScript Object Notation (JSON) format. The properties are converted to field names, the field values are converted to property values, and the methods are removed.</maml:para> <maml:para>You can then use the `ConvertFrom-Json` cmdlet to convert a JSON-formatted string to a JSON object, which is easily managed in PowerShell.</maml:para> <maml:para>Many web sites use JSON instead of XML to serialize data for communication between servers and web-based apps.</maml:para> <maml:para>This cmdlet was introduced in Windows PowerShell 3.0.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>ConvertTo-Json</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to convert to JSON format. Enter a variable that contains the objects, or type a command or expression that gets the objects. You can also pipe an object to `ConvertTo-Json`.</maml:para> <maml:para>The InputObject parameter is required, but its value can be null (`$null`) or an empty string. When the input object is `$null`, `ConvertTo-Json` does not generate any output. When the input object is an empty string, `ConvertTo-Json` returns an empty string.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Compress</maml:name> <maml:Description> <maml:para>Omits white space and indented formatting in the output string.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Depth</maml:name> <maml:Description> <maml:para>Specifies how many levels of contained objects are included in the JSON representation. The default value is 2.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>2</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Compress</maml:name> <maml:Description> <maml:para>Omits white space and indented formatting in the output string.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Depth</maml:name> <maml:Description> <maml:para>Specifies how many levels of contained objects are included in the JSON representation. The default value is 2.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>2</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to convert to JSON format. Enter a variable that contains the objects, or type a command or expression that gets the objects. You can also pipe an object to `ConvertTo-Json`.</maml:para> <maml:para>The InputObject parameter is required, but its value can be null (`$null`) or an empty string. When the input object is `$null`, `ConvertTo-Json` does not generate any output. When the input object is an empty string, `ConvertTo-Json` returns an empty string.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Object</maml:name> </dev:type> <maml:description> <maml:para>You can pipe any object to `ConvertTo-Json`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para></maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>The `ConvertTo-Json` cmdlet is implemented using the JavaScriptSerializer class (/dotnet/api/system.web.script.serialization.javascriptserializer).</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------------------- Example 1 --------------------------</maml:title> <dev:code>PS C:\> (Get-UICulture).Calendar | ConvertTo-Json { "MinSupportedDateTime": "\/Date(-62135596800000)\/", "MaxSupportedDateTime": "\/Date(253402300799999)\/", "AlgorithmType": 1, "CalendarType": 1, "Eras": [ 1 ], "TwoDigitYearMax": 2029, "IsReadOnly": false }</dev:code> <dev:remarks> <maml:para>This command uses the `ConvertTo-Json` cmdlet to convert a GregorianCalendar object to a JSON-formatted string.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------------------------- Example 2 --------------------------</maml:title> <dev:code>@{Account="User01";Domain="Domain01";Admin="True"} | ConvertTo-Json -Compress {"Domain":"Domain01","Account":"User01","Admin":"True"}</dev:code> <dev:remarks> <maml:para>This command shows the effect of using the Compress parameter of `ConvertTo-Json`. The compression affects only the appearance of the string, not its validity.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------------------------- Example 3 --------------------------</maml:title> <dev:code>Get-Date | Select-Object -Property * | ConvertTo-Json { "DisplayHint": 2, "DateTime": "Friday, January 13, 2012 8:06:16 PM", "Date": "\/Date(1326441600000)\/", "Day": 13, "DayOfWeek": 5, "DayOfYear": 13, "Hour": 20, "Kind": 2, "Millisecond": 221, "Minute": 6, "Month": 1, "Second": 16, "Ticks": 634620819762218083, "TimeOfDay": { "Ticks": 723762218083, "Days": 0, "Hours": 20, "Milliseconds": 221, "Minutes": 6, "Seconds": 16, "TotalDays": 0.83768775241087956, "TotalHours": 20.104506057861109, "TotalMilliseconds": 72376221.8083, "TotalMinutes": 1206.2703634716668, "TotalSeconds": 72376.22180829999 }, "Year": 2012 }</dev:code> <dev:remarks> <maml:para>This example uses the `ConvertTo-Json` cmdlet to convert a System.DateTime object from the `Get-Date` cmdlet to a JSON-formatted string. The command uses the `Select-Object` cmdlet to get all (` `) of the properties of the DateTime * object. The output shows the JSON string that `ConvertTo-Json` returned.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------------------------- Example 4 --------------------------</maml:title> <dev:code>Get-Date | Select-Object -Property * | ConvertTo-Json | ConvertFrom-Json DisplayHint : 2 DateTime : October 12, 2018 10:55:52 PM Date : 2018-10-12 12:00:00 AM Day : 12 DayOfWeek : 5 DayOfYear : 285 Hour : 22 Kind : 2 Millisecond : 768 Minute : 55 Month : 10 Second : 52 Ticks : 636749817527683372 TimeOfDay : @{Ticks=825527683372; Days=0; Hours=22; Milliseconds=768; Minutes=55; Seconds=52; TotalDays=0.95547185575463; TotalHours=22.9313245381111; TotalMilliseconds=82552768.3372; TotalMinutes=1375.87947228667; TotalSeconds=82552.7683372} Year : 2018</dev:code> <dev:remarks> <maml:para>This example shows how to use the `ConvertTo-Json` and `ConvertFrom-Json` cmdlets to convert an object to a JSON string and a JSON object.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/convertto-json?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>An Introduction to JavaScript Object Notation (JSON) in JavaScript and .NET</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertFrom-Json</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Content</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-UICulture</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Invoke-WebRequest</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Invoke-RestMethod</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>ConvertTo-Xml</command:name> <command:verb>ConvertTo</command:verb> <command:noun>Xml</command:noun> <maml:description> <maml:para>Creates an XML-based representation of an object.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `ConvertTo-Xml` cmdlet creates an XML-based (/dotnet/api/system.xml.xmldocument)representation of one or more .NET objects. To use this cmdlet, pipe one or more objects to the cmdlet, or use the InputObject parameter to specify the object.</maml:para> <maml:para>When you pipe multiple objects to `ConvertTo-Xml` or use the InputObject parameter to submit multiple objects, `ConvertTo-Xml` returns a single, in-memory XML document that includes representations of all of the objects.</maml:para> <maml:para>This cmdlet is similar to Export-Clixml (./Export-Clixml.md)except that `Export-Clixml` stores the resulting XML in a Common Language Infrastructure(CLI) XML (https://www.ecma-international.org/publications/standards/Ecma-335.htm)file that can be reimported as objects with Import-Clixml (./Import-Clixml.md). `ConvertTo-Xml` returns an in-memory representation of an XML document, so you can continue to process it in PowerShell. `ConvertTo-Xml` does not have an option to convert objects to CLI XML.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>ConvertTo-Xml</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the object to be converted. Enter a variable that contains the objects, or type a command or expression that gets the objects. You can also pipe objects to ConvertTo-XML .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>As</maml:name> <maml:Description> <maml:para>Determines the output format. The acceptable values for this parameter are:</maml:para> <maml:para>- String. Returns a single string. - Stream. Returns an array of strings. - Document. Returns an XmlDocument object.</maml:para> <maml:para>The default value is Document.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Stream</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">String</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Document</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Depth</maml:name> <maml:Description> <maml:para>Specifies how many levels of contained objects are included in the XML representation. The default value is 1.</maml:para> <maml:para>For example, if the object's properties also contain objects, to save an XML representation of the properties of the contained objects, you must specify a depth of 2.</maml:para> <maml:para>The default value can be overridden for the object type in the Types.ps1xml files. For more information, see about_Types.ps1xml.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NoTypeInformation</maml:name> <maml:Description> <maml:para>Omits the Type attribute from the object nodes.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>As</maml:name> <maml:Description> <maml:para>Determines the output format. The acceptable values for this parameter are:</maml:para> <maml:para>- String. Returns a single string. - Stream. Returns an array of strings. - Document. Returns an XmlDocument object.</maml:para> <maml:para>The default value is Document.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Depth</maml:name> <maml:Description> <maml:para>Specifies how many levels of contained objects are included in the XML representation. The default value is 1.</maml:para> <maml:para>For example, if the object's properties also contain objects, to save an XML representation of the properties of the contained objects, you must specify a depth of 2.</maml:para> <maml:para>The default value can be overridden for the object type in the Types.ps1xml files. For more information, see about_Types.ps1xml.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the object to be converted. Enter a variable that contains the objects, or type a command or expression that gets the objects. You can also pipe objects to ConvertTo-XML .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NoTypeInformation</maml:name> <maml:Description> <maml:para>Omits the Type attribute from the object nodes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe any object to ConvertTo-XML .</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.String or System.Xml.XmlDocument</maml:name> </dev:type> <maml:description> <maml:para>The value of the As parameter determines the type of object that ConvertTo-XML returns.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------------- Example 1: Convert a date to XML ---------------</maml:title> <dev:code>PS C:\> Get-Date | ConvertTo-Xml</dev:code> <dev:remarks> <maml:para>This command converts the current date (a DateTime object) to XML.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------- Example 2: Convert processes to XML -------------</maml:title> <dev:code>PS C:\> ConvertTo-Xml -As "Document" -InputObject (Get-Process) -Depth 3</dev:code> <dev:remarks> <maml:para>This command converts the process objects that represent all of the processes on the computer into an XML document. The objects are expanded to a depth of three levels.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/convertto-xml?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-Csv</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-Html</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Export-Clixml</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Date</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Import-Clixml</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Debug-Runspace</command:name> <command:verb>Debug</command:verb> <command:noun>Runspace</command:noun> <maml:description> <maml:para>Starts an interactive debugging session with a runspace.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Debug-Runspace` cmdlet starts an interactive debugging session with a local or remote active runspace. You can find a runspace that you want to debug by first running `Get-Process` to find processes associated with PowerShell, then `Enter-PSHostProcess` with the process ID specified in the Id parameter to attach to the process, and then `Get-Runspace` to list runspaces within the PowerShell host process.</maml:para> <maml:para>After you have selected a runspace to debug, if the runspace is currently running a command or script, or if the script has stopped at a breakpoint, PowerShell opens a remote debugger session for the runspace. You can debug the runspace script in the same way remote session scripts are debugged.</maml:para> <maml:para>You can only attach to a PowerShell host process if you are an administrator on the computer that is running the process, or you are running the script that you want to debug. Also, you cannot enter the host process that is running the current PowerShell session. You can only enter a host process that is running a different PowerShell session.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Debug-Runspace</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Id</maml:name> <maml:Description> <maml:para>Specifies the ID number of a runspace. You can run `Get-Runspace` to show runspace IDs.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>True</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>True</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Debug-Runspace</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>InstanceId</maml:name> <maml:Description> <maml:para>Specifies a runspace by its instance ID, a GUID that you can show by running `Get-Runspace`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Guid</command:parameterValue> <dev:type> <maml:name>System.Guid</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>True</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>True</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Debug-Runspace</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies a runspace by its name. You can run `Get-Runspace` to show the names of runspaces.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>True</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>True</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Debug-Runspace</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Runspace</maml:name> <maml:Description> <maml:para>Specifies a runspace object. The simplest way to provide a value for this parameter is to specify a variable that contains the results of a filtered `Get-Runspace` command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Runspaces.Runspace</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.Runspace</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>True</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>True</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Id</maml:name> <maml:Description> <maml:para>Specifies the ID number of a runspace. You can run `Get-Runspace` to show runspace IDs.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>InstanceId</maml:name> <maml:Description> <maml:para>Specifies a runspace by its instance ID, a GUID that you can show by running `Get-Runspace`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Guid</command:parameterValue> <dev:type> <maml:name>System.Guid</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies a runspace by its name. You can run `Get-Runspace` to show the names of runspaces.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Runspace</maml:name> <maml:Description> <maml:para>Specifies a runspace object. The simplest way to provide a value for this parameter is to specify a variable that contains the results of a filtered `Get-Runspace` command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Runspaces.Runspace</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.Runspace</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>True</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>True</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.Runspaces.Runspace</maml:name> </dev:type> <maml:description> <maml:para>You can pipe the results of a `Get-Runspace` command to Debug-Runspace.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues /> <maml:alertSet> <maml:alert> <maml:para>`Debug-Runspace` works on runspaces that are in the Opened state. If a runspace state changes from Opened to another state, that runspace is automatically removed from the running list. A runspace is added to the running list only if it meets the following criteria.</maml:para> <maml:para>- If it is coming from Invoke-Command; that is, it has an `Invoke-Command` GUID ID.</maml:para> <maml:para>- If it is coming from `Debug-Runspace`; that is, it has a `Debug-Runspace` GUID ID.</maml:para> <maml:para>- If it is coming from a PowerShell workflow, and its workflow job ID is the same as the current</maml:para> <maml:para> active debugger workflow job ID.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------- Example 1: Debug a remote runspace --------------</maml:title> <dev:code>PS C:\> Get-Process -ComputerName "WS10TestServer" -Name "*powershell*" Handles WS(K) VM(M) CPU(s) Id ProcessName ------- ----- ----- ------ -- ----------- 377 69912 63 2.09 2420 powershell 399 123396 829 4.48 1152 powershell_ise PS C:\> Enter-PSSession -ComputerName "WS10TestServer" [WS10TestServer]:PS C:\> Enter-PSHostProcess -Id 1152 [WS10TestServer:][Process:1152]: PS C:\Users\Test\Documents> Get-Runspace Id Name ComputerName Type State Availability -- ---- ------------ ---- ----- ------------ 1 Runspace1 WS10TestServer Remote Opened Available 2 RemoteHost WS10TestServer Remote Opened Busy PS C:\> [WS10TestServer][Process:1152]: PS C:\Users\Test\Documents> Debug-Runspace -Id 2 Hit Line breakpoint on 'C:\TestWFVar1.ps1:83' At C:\TestWFVar1.ps1:83 char:1 + $scriptVar = "Script Variable" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Process:1152]: [RSDBG: 2]: PS C:\> ></dev:code> <dev:remarks> <maml:para>In this example, you debug a runspace that is open on a remote computer, WS10TestServer. In the first line of the command, you run `Get-Process` on the remote computer, and filter for Windows PowerShell host processes. In this example, you want to debug process ID 1152, the Windows PowerShell ISE host process.</maml:para> <maml:para>In the second command, you run `Enter-PSSession` to open a remote session on WS10TestServer. In the third command, you attach to the Windows PowerShell ISE host process running on the remote server by running `Enter-PSHostProcess`, and specifying the ID of the host process that you obtained in the first command, 1152.</maml:para> <maml:para>In the fourth command, you list available runspaces for process ID 1152 by running `Get-Runspace`. You note the ID number of the Busy runspace; it is running a script that you want to debug.</maml:para> <maml:para>In the last command, you start debugging an opened runspace that is running a script, TestWFVar1.ps1, by running `Debug-Runspace`, and identifying the runspace by its ID, 2, by adding the Id parameter. Because there's a breakpoint in the script, the debugger opens.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/debug-runspace?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Debuggers</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Debug-Job</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Runspace</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Process</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Enter-PSHostProcess</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Enter-PSSession</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Disable-PSBreakpoint</command:name> <command:verb>Disable</command:verb> <command:noun>PSBreakpoint</command:noun> <maml:description> <maml:para>Disables the breakpoints in the current console.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Disable-PSBreakpoint cmdlet disables breakpoints, which assures that they are not hit when the script runs. You can use it to disable all breakpoints, or you can specify breakpoints by submitting breakpoint objects or breakpoint IDs.</maml:para> <maml:para>Technically, this cmdlet changes the value of the Enabled property of a breakpoint object to False. To re-enable a breakpoint, use the Enable-PSBreakpoint cmdlet. Breakpoints are enabled by default when you create them by using the Set-PSBreakpoint cmdlet.</maml:para> <maml:para>A breakpoint is a point in a script where execution stops temporarily so that you can examine the instructions in the script. Disable-PSBreakpoint is one of several cmdlets designed for debugging Windows PowerShell scripts. For more information about the Windows PowerShell debugger, see about_Debuggers.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Disable-PSBreakpoint</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Breakpoint</maml:name> <maml:Description> <maml:para>Specifies the breakpoints to disable. Enter a variable that contains breakpoint objects or a command that gets breakpoint objects, such as a Get-PSBreakpoint command. You can also pipe breakpoint objects to the Disable-PSBreakpoint cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Breakpoint[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Breakpoint[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the enabled breakpoints. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Disable-PSBreakpoint</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Id</maml:name> <maml:Description> <maml:para>Disables the breakpoints with the specified breakpoint IDs. Enter the IDs or a variable that contains the IDs. You cannot pipe IDs to Disable-PSBreakpoint .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the enabled breakpoints. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Breakpoint</maml:name> <maml:Description> <maml:para>Specifies the breakpoints to disable. Enter a variable that contains breakpoint objects or a command that gets breakpoint objects, such as a Get-PSBreakpoint command. You can also pipe breakpoint objects to the Disable-PSBreakpoint cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Breakpoint[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Breakpoint[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Id</maml:name> <maml:Description> <maml:para>Disables the breakpoints with the specified breakpoint IDs. Enter the IDs or a variable that contains the IDs. You cannot pipe IDs to Disable-PSBreakpoint .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the enabled breakpoints. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.Breakpoint</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a breakpoint object to Disable-PSBreakpoint .</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None or System.Management.Automation.Breakpoint</maml:name> </dev:type> <maml:description> <maml:para>When you use the PassThru parameter, Disable-PSBreakpoint returns an object that represents the disabled breakpoint. Otherwise, this cmdlet does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>---------- Example 1: Set a breakpoint and disable it ----------</maml:title> <dev:code>PS C:\> $B = Set-PSBreakpoint -Script "sample.ps1" -Variable "name" PS C:\> $B | Disable-PSBreakpoint</dev:code> <dev:remarks> <maml:para>These commands disable a newly-created breakpoint.</maml:para> <maml:para>The first command uses the Set-PSBreakpoint cmdlet to create a breakpoint on the Name variable in the Sample.ps1 script. Then, it saves the breakpoint object in the $B variable.</maml:para> <maml:para>The second command uses the Disable-PSBreakpoint cmdlet to disable the new breakpoint. It uses a pipeline operator (|) to send the breakpoint object in $B to the Disable-PSBreakpoint cmdlet.</maml:para> <maml:para>As a result of this command, the value of the Enabled property of the breakpoint object in $B is False.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------------- Example 2: Disable a breakpoint ---------------</maml:title> <dev:code>PS C:\> Disable-PSBreakpoint -Id 0</dev:code> <dev:remarks> <maml:para>This command disables the breakpoint with breakpoint ID 0.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 3: Create a disabled breakpoint -----------</maml:title> <dev:code>PS C:\> Disable-PSBreakpoint -Breakpoint ($B = Set-PSBreakpoint -Script "sample.ps1" -Line 5) PS C:\> $B</dev:code> <dev:remarks> <maml:para>This command creates a new breakpoint that is disabled until you enable it.</maml:para> <maml:para>It uses the Disable-PSBreakpoint cmdlet to disable the breakpoint. The value of the Breakpoint parameter is a Set-PSBreakpoint command that sets a new breakpoint, generates a breakpoint object, and saves the object in the $B variable.</maml:para> <maml:para>Cmdlet parameters that take objects as their values can accept a variable that contains the object or a command that gets or generates the object. In this case, because Set-PSBreakpoint generates a breakpoint object, it can be used as the value of the Breakpoint parameter.</maml:para> <maml:para>The second command displays the breakpoint object in the value of the $B variable.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 4: Disable all breakpoints in the current console --</maml:title> <dev:code>PS C:\> Get-PSBreakpoint | Disable-PSBreakpoint</dev:code> <dev:remarks> <maml:para>This command disables all breakpoints in the current console. You can abbreviate this command as: "gbp | dbp".</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/disable-psbreakpoint?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Enable-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-PSCallStack</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Disable-RunspaceDebug</command:name> <command:verb>Disable</command:verb> <command:noun>RunspaceDebug</command:noun> <maml:description> <maml:para>Disables debugging on one or more runspaces, and releases any pending debugger stop.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Disable-RunspaceDebug` cmdlet disables debugging on one or more runspaces, and releases any pending debugger stop.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Disable-RunspaceDebug</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>ProcessName</maml:name> <maml:Description> <maml:para>The name of the process that hosts the PowerShell runspace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>AppDomainName</maml:name> <maml:Description> <maml:para>The name of the application domain that hosts the PowerShell runspace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Disable-RunspaceDebug</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Runspace</maml:name> <maml:Description> <maml:para>One or more Runspace objects to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Runspaces.Runspace[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.Runspace[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Disable-RunspaceDebug</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceId</maml:name> <maml:Description> <maml:para>One or more Runspace Id numbers to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Disable-RunspaceDebug</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceInstanceId</maml:name> <maml:Description> <maml:para>One or more Runspace GUIDs to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Guid[]</command:parameterValue> <dev:type> <maml:name>System.Guid[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Disable-RunspaceDebug</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceName</maml:name> <maml:Description> <maml:para>One or more Runspace names to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>AppDomainName</maml:name> <maml:Description> <maml:para>The name of the application domain that hosts the PowerShell runspace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>ProcessName</maml:name> <maml:Description> <maml:para>The name of the process that hosts the PowerShell runspace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Runspace</maml:name> <maml:Description> <maml:para>One or more Runspace objects to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Runspaces.Runspace[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.Runspace[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceId</maml:name> <maml:Description> <maml:para>One or more Runspace Id numbers to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceInstanceId</maml:name> <maml:Description> <maml:para>One or more Runspace GUIDs to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Guid[]</command:parameterValue> <dev:type> <maml:name>System.Guid[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceName</maml:name> <maml:Description> <maml:para>One or more Runspace names to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes /> <command:returnValues /> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>----------- 1: Disable the default runspace debugger -----------</maml:title> <dev:code>Disable-RunspaceDebug Get-RunspaceDebug Id Name Enabled BreakAll -- ---- ------- -------- 1 Runspace1 False False</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/disable-runspacedebug?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Enable-RunspaceDebug</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-RunspaceDebug</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Enable-PSBreakpoint</command:name> <command:verb>Enable</command:verb> <command:noun>PSBreakpoint</command:noun> <maml:description> <maml:para>Enables the breakpoints in the current console.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Enable-PSBreakpoint` cmdlet re-enables disabled breakpoints. You can use it to enable all breakpoints, or specific breakpoints by providing breakpoint objects or IDs.</maml:para> <maml:para>A breakpoint is a point in a script where execution stops temporarily so that you can examine the state of the script. Newly created breakpoints are automatically enabled, but can be disabled using `Disable-PSBreakpoint`.</maml:para> <maml:para>Technically, this cmdlet changes the value of the Enabled property of a breakpoint object to True .</maml:para> <maml:para>`Enable-PSBreakpoint` is one of several cmdlets designed for debugging PowerShell scripts. For more information about the PowerShell debugger, see about_Debuggers (../Microsoft.PowerShell.Core/About/about_Debuggers.md).</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Enable-PSBreakpoint</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Breakpoint</maml:name> <maml:Description> <maml:para>Specifies the breakpoints to enable. Provide a variable containing breakpoints or a command that gets breakpoint objects, such as `Get-PSBreakpoint`. You can also pipe breakpoint objects to `Enable-PSBreakpoint`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Breakpoint[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Breakpoint[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the breakpoint being enabled. By default, this cmdlet doesn't generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet isn't run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Enable-PSBreakpoint</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Id</maml:name> <maml:Description> <maml:para>Specifies the Id numbers of the breakpoints to enable. The default value is all breakpoints. Provide the Id by number or in a variable. You can't pipe Id numbers to `Enable-PSBreakpoint`. To find the Id of a breakpoint, use the `Get-PSBreakpoint` cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the breakpoint being enabled. By default, this cmdlet doesn't generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet isn't run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Breakpoint</maml:name> <maml:Description> <maml:para>Specifies the breakpoints to enable. Provide a variable containing breakpoints or a command that gets breakpoint objects, such as `Get-PSBreakpoint`. You can also pipe breakpoint objects to `Enable-PSBreakpoint`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Breakpoint[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Breakpoint[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Id</maml:name> <maml:Description> <maml:para>Specifies the Id numbers of the breakpoints to enable. The default value is all breakpoints. Provide the Id by number or in a variable. You can't pipe Id numbers to `Enable-PSBreakpoint`. To find the Id of a breakpoint, use the `Get-PSBreakpoint` cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the breakpoint being enabled. By default, this cmdlet doesn't generate any output.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet isn't run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.Breakpoint</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a breakpoint object to `Enable-PSBreakpoint`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None or System.Management.Automation.Breakpoint</maml:name> </dev:type> <maml:description> <maml:para>When you use the PassThru parameter, `Enable-PSBreakpoint` returns a breakpoint object that represents that breakpoint that was enabled. Otherwise, this cmdlet doesn't generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>- The `Enable-PSBreakpoint` cmdlet doesn't generate an error if you try to enable a breakpoint that is already enabled. As such, you can enable all breakpoints without error, even when only a few are disabled.</maml:para> <maml:para>- Breakpoints are enabled when you create them by using the `Set-PSBreakpoint` cmdlet. You don't need to enable newly created breakpoints.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------- Example 1: Enable all breakpoints --------------</maml:title> <dev:code>Get-PSBreakpoint | Enable-PSBreakpoint</dev:code> <dev:remarks> <maml:para>Using aliases, this example can be abbreviated as `gbp | ebp`.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------- Example 2: Enable breakpoints by ID -------------</maml:title> <dev:code>Enable-PSBreakpoint -Id 0, 1, 5</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 3: Enable a disabled breakpoint -----------</maml:title> <dev:code>$B = Set-PSBreakpoint -Script "sample.ps1" -Variable Name -PassThru $B | Enable-PSBreakpoint -PassThru AccessMode : Write Variable : Name Action : Enabled : False HitCount : 0 Id : 0 Script : C:\ps-test\sample.ps1 ScriptName : C:\ps-test\sample.ps1 AccessMode : Write Variable : Name Action : Enabled : True HitCount : 0 Id : 0 Script : C:\ps-test\sample.ps1 ScriptName : C:\ps-test\sample.ps1</dev:code> <dev:remarks> <maml:para>`Set-PSBreakpoint` creates a breakpoint on the Name variable in the `Sample.ps1` script saving the breakpoint object in the `$B` variable. The PassThru parameter displays the value of the Enabled property of the breakpoint is False .</maml:para> <maml:para>`Enable-PSBreakpoint` re-enables the breakpoint. Again, using the PassThru parameter we see that the value of the Enabled property is True .</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 4: Enable breakpoints using a variable --------</maml:title> <dev:code>$B = Get-PSBreakpoint -Id 3, 5 Enable-PSBreakpoint -Breakpoint $B</dev:code> <dev:remarks> <maml:para>`Get-PSBreakpoint` gets the breakpoints and saves them in the `$B` variable. Using the Breakpoint parameter, `Enable-PSBreakpoint` enables the breakpoints.</maml:para> <maml:para>This example is equivalent to running `Enable-PSBreakpoint -Id 3, 5`.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/enable-psbreakpoint?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Disable-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-PSCallStack</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Enable-RunspaceDebug</command:name> <command:verb>Enable</command:verb> <command:noun>RunspaceDebug</command:noun> <maml:description> <maml:para>Enables debugging on runspaces where any breakpoint is preserved until a debugger is attached.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Enable-RunspaceDebug` cmdlet enables debugging on runspaces where any breakpoint is preserved until a debugger is attached.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Enable-RunspaceDebug</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>ProcessName</maml:name> <maml:Description> <maml:para>The name of the process that hosts the PowerShell runspace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>AppDomainName</maml:name> <maml:Description> <maml:para>The name of the application domain that hosts the PowerShell runspace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Enable-RunspaceDebug</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceName</maml:name> <maml:Description> <maml:para>One or more Runspace names to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>BreakAll</maml:name> <maml:Description> <maml:para>Causes any running command or script in the Runspace to stop in step mode, regardless of whether a debugger is currently attached. The script or command will remain stopped until a debugger is attached to debug the current stop point.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Enable-RunspaceDebug</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Runspace</maml:name> <maml:Description> <maml:para>One or more Runspace objects to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Runspaces.Runspace[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.Runspace[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>BreakAll</maml:name> <maml:Description> <maml:para>Causes any running command or script in the Runspace to stop in step mode, regardless of whether a debugger is currently attached. The script or command will remain stopped until a debugger is attached to debug the current stop point.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Enable-RunspaceDebug</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceId</maml:name> <maml:Description> <maml:para>One or more Runspace Id numbers to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>BreakAll</maml:name> <maml:Description> <maml:para>Causes any running command or script in the Runspace to stop in step mode, regardless of whether a debugger is currently attached. The script or command will remain stopped until a debugger is attached to debug the current stop point.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Enable-RunspaceDebug</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceInstanceId</maml:name> <maml:Description> <maml:para>One or more Runspace GUIDs to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Guid[]</command:parameterValue> <dev:type> <maml:name>System.Guid[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>AppDomainName</maml:name> <maml:Description> <maml:para>The name of the application domain that hosts the PowerShell runspace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>BreakAll</maml:name> <maml:Description> <maml:para>Causes any running command or script in the Runspace to stop in step mode, regardless of whether a debugger is currently attached. The script or command will remain stopped until a debugger is attached to debug the current stop point.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>ProcessName</maml:name> <maml:Description> <maml:para>The name of the process that hosts the PowerShell runspace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Runspace</maml:name> <maml:Description> <maml:para>One or more Runspace objects to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Runspaces.Runspace[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.Runspace[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceId</maml:name> <maml:Description> <maml:para>One or more Runspace Id numbers to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceInstanceId</maml:name> <maml:Description> <maml:para>One or more Runspace GUIDs to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Guid[]</command:parameterValue> <dev:type> <maml:name>System.Guid[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceName</maml:name> <maml:Description> <maml:para>One or more Runspace names to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes /> <command:returnValues /> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>----------- 1: Enable the default runspace debugger -----------</maml:title> <dev:code>Enable-RunspaceDebug Get-RunspaceDebug Id Name Enabled BreakAll -- ---- ------- -------- 1 Runspace1 True False</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/enable-runspacedebug?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Disable-RunspaceDebug</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-RunspaceDebug</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Export-Alias</command:name> <command:verb>Export</command:verb> <command:noun>Alias</command:noun> <maml:description> <maml:para>Exports information about currently defined aliases to a file.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Export-Alias` cmdlet exports the aliases in the current session to a file. If the output file does not exist, the cmdlet will create it.</maml:para> <maml:para>`Export-Alias` can export the aliases in a particular scope or all scopes, it can generate the data in CSV format or as a series of Set-Alias commands that you can add to a session or to a PowerShell profile.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Export-Alias</maml:name> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the names as an array of the aliases to export. Wildcards are permitted.</maml:para> <maml:para>By default, `Export-Alias` exports all aliases in the session or scope.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Append</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet appends the output to the specified file, rather than overwriting the existing contents of that file.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>As</maml:name> <maml:Description> <maml:para>Specifies the output format. CSV is the default. The acceptable values for this parameter are:</maml:para> <maml:para>- CSV. Comma-separated value (CSV) format. - Script. Creates a `Set-Alias` command for each exported alias. If you name the output file with a .ps1 file name extension, you can run it as a script to add the aliases to any session.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Csv</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Script</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.ExportAliasFormat</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.ExportAliasFormat</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Description</maml:name> <maml:Description> <maml:para>Specifies the description of the exported file. The description appears as a comment at the top of the file, following the header information.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Forces the command to run without asking for user confirmation.</maml:para> <maml:para>Overwrites the output file, even if the read-only attribute is set on the file.</maml:para> <maml:para>By default, `Export-Alias` overwrites files without warning, unless the read-only or hidden attribute is set or the NoClobber parameter is used in the command. The NoClobber parameter takes precedence over the Force parameter when both are used in a command.</maml:para> <maml:para>The Force parameter cannot force `Export-Alias` to overwrite files with the hidden attribute.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to the output file. Unlike Path , the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NoOverwrite"> <maml:name>NoClobber</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet prevents `Export-Alias` from overwriting any files, even if the Force parameter is used in the command.</maml:para> <maml:para>If the NoClobber parameter is omitted, `Export-Alias` will overwrite an existing file without warning, unless the read-only attribute is set on the file. NoClobber takes precedence over the Force parameter, which permits `Export-Alias` to overwrite a file with the read-only attribute. NoClobber does not prevent the Append parameter from adding content to an existing file.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope from which the aliases should be exported. The acceptable values for this parameter are:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Script</maml:para> <maml:para>- A number relative to the current scope (0 through the number of scopes where 0 is the current scope and 1 is its parent)</maml:para> <maml:para></maml:para> <maml:para>The default value is Local. For more information, see about_Scopes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Export-Alias</maml:name> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the path to the output file. Wildcards are permitted, but the resulting path value must resolve to a single file name.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the names as an array of the aliases to export. Wildcards are permitted.</maml:para> <maml:para>By default, `Export-Alias` exports all aliases in the session or scope.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Append</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet appends the output to the specified file, rather than overwriting the existing contents of that file.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>As</maml:name> <maml:Description> <maml:para>Specifies the output format. CSV is the default. The acceptable values for this parameter are:</maml:para> <maml:para>- CSV. Comma-separated value (CSV) format. - Script. Creates a `Set-Alias` command for each exported alias. If you name the output file with a .ps1 file name extension, you can run it as a script to add the aliases to any session.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Csv</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Script</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.ExportAliasFormat</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.ExportAliasFormat</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Description</maml:name> <maml:Description> <maml:para>Specifies the description of the exported file. The description appears as a comment at the top of the file, following the header information.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Forces the command to run without asking for user confirmation.</maml:para> <maml:para>Overwrites the output file, even if the read-only attribute is set on the file.</maml:para> <maml:para>By default, `Export-Alias` overwrites files without warning, unless the read-only or hidden attribute is set or the NoClobber parameter is used in the command. The NoClobber parameter takes precedence over the Force parameter when both are used in a command.</maml:para> <maml:para>The Force parameter cannot force `Export-Alias` to overwrite files with the hidden attribute.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NoOverwrite"> <maml:name>NoClobber</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet prevents `Export-Alias` from overwriting any files, even if the Force parameter is used in the command.</maml:para> <maml:para>If the NoClobber parameter is omitted, `Export-Alias` will overwrite an existing file without warning, unless the read-only attribute is set on the file. NoClobber takes precedence over the Force parameter, which permits `Export-Alias` to overwrite a file with the read-only attribute. NoClobber does not prevent the Append parameter from adding content to an existing file.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope from which the aliases should be exported. The acceptable values for this parameter are:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Script</maml:para> <maml:para>- A number relative to the current scope (0 through the number of scopes where 0 is the current scope and 1 is its parent)</maml:para> <maml:para></maml:para> <maml:para>The default value is Local. For more information, see about_Scopes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Append</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet appends the output to the specified file, rather than overwriting the existing contents of that file.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>As</maml:name> <maml:Description> <maml:para>Specifies the output format. CSV is the default. The acceptable values for this parameter are:</maml:para> <maml:para>- CSV. Comma-separated value (CSV) format. - Script. Creates a `Set-Alias` command for each exported alias. If you name the output file with a .ps1 file name extension, you can run it as a script to add the aliases to any session.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.ExportAliasFormat</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.ExportAliasFormat</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Description</maml:name> <maml:Description> <maml:para>Specifies the description of the exported file. The description appears as a comment at the top of the file, following the header information.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Forces the command to run without asking for user confirmation.</maml:para> <maml:para>Overwrites the output file, even if the read-only attribute is set on the file.</maml:para> <maml:para>By default, `Export-Alias` overwrites files without warning, unless the read-only or hidden attribute is set or the NoClobber parameter is used in the command. The NoClobber parameter takes precedence over the Force parameter when both are used in a command.</maml:para> <maml:para>The Force parameter cannot force `Export-Alias` to overwrite files with the hidden attribute.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to the output file. Unlike Path , the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the names as an array of the aliases to export. Wildcards are permitted.</maml:para> <maml:para>By default, `Export-Alias` exports all aliases in the session or scope.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NoOverwrite"> <maml:name>NoClobber</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet prevents `Export-Alias` from overwriting any files, even if the Force parameter is used in the command.</maml:para> <maml:para>If the NoClobber parameter is omitted, `Export-Alias` will overwrite an existing file without warning, unless the read-only attribute is set on the file. NoClobber takes precedence over the Force parameter, which permits `Export-Alias` to overwrite a file with the read-only attribute. NoClobber does not prevent the Append parameter from adding content to an existing file.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the path to the output file. Wildcards are permitted, but the resulting path value must resolve to a single file name.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope from which the aliases should be exported. The acceptable values for this parameter are:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Script</maml:para> <maml:para>- A number relative to the current scope (0 through the number of scopes where 0 is the current scope and 1 is its parent)</maml:para> <maml:para></maml:para> <maml:para>The default value is Local. For more information, see about_Scopes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None.</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe objects to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None or System.Management.Automation.AliasInfo</maml:name> </dev:type> <maml:description> <maml:para>When you use the Passthru parameter, `Export-Alias` returns a System.Management.Automation.AliasInfo object that represents the alias. Otherwise, this cmdlet does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>* You can only Export-Aliases to a file.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------------ Example 1: Export an alias ------------------</maml:title> <dev:code>Export-Alias -Path "alias.csv"</dev:code> <dev:remarks> <maml:para>This command exports current alias information to a file named Alias.csv in the current directory.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 2: Export an alias unless the export file already exists</maml:title> <dev:code>Export-Alias -Path "alias.csv" -NoClobber</dev:code> <dev:remarks> <maml:para>This command exports the aliases in the current session to an Alias.csv file.</maml:para> <maml:para>Because the NoClobber parameter is specified, the command will fail if an Alias.csv file already exists in the current directory.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------- Example 3: Append aliases to a file -------------</maml:title> <dev:code>Export-Alias -Path "alias.csv" -Append -Description "Appended Aliases" -Force</dev:code> <dev:remarks> <maml:para>This command appends the aliases in the current session to the Alias.csv file.</maml:para> <maml:para>The command uses the Description parameter to add a description to the comments at the top of the file.</maml:para> <maml:para>The command also uses the Force parameter to overwrite any existing Alias.csv files, even if they have the read-only attribute.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------ Example 4: Export aliases as a script ------------</maml:title> <dev:code>Export-Alias -Path "alias.ps1" -As Script Add-Content -Path $Profile -Value (Get-Content alias.ps1) $S = New-PSSession -ComputerName Server01 Invoke-Command -Session $S -FilePath .\alias.ps1</dev:code> <dev:remarks> <maml:para>This example shows how to use the script file format that `Export-Alias` generates.</maml:para> <maml:para>The first command exports the aliases in the session to the Alias.ps1 file. It uses the As parameter with a value of Script to generate a file that contains a Set-Alias command for each alias.</maml:para> <maml:para>The second command adds the aliases in the Alias.ps1 file to the CurrentUser-CurrentHost profile. The path to the profile is saved in the `$Profile` variable. The command uses the `Get-Content` cmdlet to get the aliases from the Alias.ps1 file and the `Add-Content` cmdlet to add them to the profile. For more information, see about_Profiles.</maml:para> <maml:para>The third and fourth commands add the aliases in the Alias.ps1 file to a remote session on the Server01 computer. The third command uses the `New-PSSession` cmdlet to create the session. The fourth command uses the FilePath parameter of the `Invoke-Command` cmdlet to run the Alias.ps1 file in the new session.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/export-alias?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Import-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Export-Clixml</command:name> <command:verb>Export</command:verb> <command:noun>Clixml</command:noun> <maml:description> <maml:para>Creates an XML-based representation of an object or objects and stores it in a file.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Export-Clixml` cmdlet creates a Common Language Infrastructure (CLI) XML-based representation of an object or objects and stores it in a file. You can then use the `Import-Clixml` cmdlet to recreate the saved object based on the contents of that file. For more information about CLI, see Language independence (/dotnet/standard/language-independence).</maml:para> <maml:para>This cmdlet is similar to `ConvertTo-Xml`, except that `Export-Clixml` stores the resulting XML in a file. `ConvertTo-XML` returns the XML, so you can continue to process it in PowerShell.</maml:para> <maml:para>A valuable use of `Export-Clixml` on Windows computers is to export credentials and secure strings securely as XML. For an example, see Example 3.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Export-Clixml</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Depth</maml:name> <maml:Description> <maml:para>Specifies how many levels of contained objects are included in the XML representation. The default value is `2`.</maml:para> <maml:para>The default value can be overridden for the object type in the `Types.ps1xml` files. For more information, see about_Types.ps1xml (../Microsoft.PowerShell.Core/About/about_Types.ps1xml.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>2</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is Unicode .</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ASCII` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `BigEndianUnicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `Default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `OEM` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `Unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `UTF7` Uses UTF-7.</maml:para> <maml:para>- `UTF8` Uses UTF-8.</maml:para> <maml:para>- `UTF32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">ASCII</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">BigEndianUnicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Default</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OEM</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF7</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF8</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF32</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Unicode</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Forces the command to run without asking for user confirmation.</maml:para> <maml:para>Causes the cmdlet to clear the read-only attribute of the output file if necessary. The cmdlet will attempt to reset the read-only attribute when the command completes.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the object to be converted. Enter a variable that contains the objects, or type a command or expression that gets the objects. You can also pipe objects to `Export-Clixml`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to the file where the XML representation of the object will be stored. Unlike Path , the value of the LiteralPath parameter is used exactly as it's typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NoOverwrite"> <maml:name>NoClobber</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet doesn't overwrite the contents of an existing file. By default, if a file exists in the specified path, `Export-Clixml` overwrites the file without warning.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet isn't run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Export-Clixml</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the path to the file where the XML representation of the object will be stored.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Depth</maml:name> <maml:Description> <maml:para>Specifies how many levels of contained objects are included in the XML representation. The default value is `2`.</maml:para> <maml:para>The default value can be overridden for the object type in the `Types.ps1xml` files. For more information, see about_Types.ps1xml (../Microsoft.PowerShell.Core/About/about_Types.ps1xml.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>2</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is Unicode .</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ASCII` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `BigEndianUnicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `Default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `OEM` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `Unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `UTF7` Uses UTF-7.</maml:para> <maml:para>- `UTF8` Uses UTF-8.</maml:para> <maml:para>- `UTF32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">ASCII</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">BigEndianUnicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Default</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OEM</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF7</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF8</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF32</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Unicode</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Forces the command to run without asking for user confirmation.</maml:para> <maml:para>Causes the cmdlet to clear the read-only attribute of the output file if necessary. The cmdlet will attempt to reset the read-only attribute when the command completes.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the object to be converted. Enter a variable that contains the objects, or type a command or expression that gets the objects. You can also pipe objects to `Export-Clixml`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NoOverwrite"> <maml:name>NoClobber</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet doesn't overwrite the contents of an existing file. By default, if a file exists in the specified path, `Export-Clixml` overwrites the file without warning.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet isn't run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Depth</maml:name> <maml:Description> <maml:para>Specifies how many levels of contained objects are included in the XML representation. The default value is `2`.</maml:para> <maml:para>The default value can be overridden for the object type in the `Types.ps1xml` files. For more information, see about_Types.ps1xml (../Microsoft.PowerShell.Core/About/about_Types.ps1xml.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>2</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is Unicode .</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ASCII` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `BigEndianUnicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `Default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `OEM` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `Unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `UTF7` Uses UTF-7.</maml:para> <maml:para>- `UTF8` Uses UTF-8.</maml:para> <maml:para>- `UTF32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Unicode</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Forces the command to run without asking for user confirmation.</maml:para> <maml:para>Causes the cmdlet to clear the read-only attribute of the output file if necessary. The cmdlet will attempt to reset the read-only attribute when the command completes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the object to be converted. Enter a variable that contains the objects, or type a command or expression that gets the objects. You can also pipe objects to `Export-Clixml`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to the file where the XML representation of the object will be stored. Unlike Path , the value of the LiteralPath parameter is used exactly as it's typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NoOverwrite"> <maml:name>NoClobber</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet doesn't overwrite the contents of an existing file. By default, if a file exists in the specified path, `Export-Clixml` overwrites the file without warning.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the path to the file where the XML representation of the object will be stored.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet isn't run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipeline any object to `Export-Clixml`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.IO.FileInfo</maml:name> </dev:type> <maml:description> <maml:para>`Export-Clixml` creates a file that contains the XML.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>---------- Example 1: Export a string to an XML file ----------</maml:title> <dev:code>"This is a test" | Export-Clixml -Path .\sample.xml</dev:code> <dev:remarks> <maml:para>The string This is a test is sent down the pipeline. `Export-Clixml` uses the Path parameter to create an XML file named `sample.xml` in the current directory.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 2: Export an object to an XML file ----------</maml:title> <dev:code>Get-Acl C:\test.txt | Export-Clixml -Path .\FileACL.xml $fileacl = Import-Clixml -Path .\FileACL.xml</dev:code> <dev:remarks> <maml:para>The `Get-Acl` cmdlet gets the security descriptor of the `Test.txt` file. It sends the object down the pipeline to pass the security descriptor to `Export-Clixml`. The XML-based representation of the object is stored in a file named `FileACL.xml`.</maml:para> <maml:para>The `Import-Clixml` cmdlet creates an object from the XML in the `FileACL.xml` file. Then, it saves the object in the `$fileacl` variable.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 3: Encrypt an exported credential object -------</maml:title> <dev:code>$Credxmlpath = Join-Path (Split-Path $Profile) TestScript.ps1.credential $Credential | Export-Clixml $Credxmlpath $Credxmlpath = Join-Path (Split-Path $Profile) TestScript.ps1.credential $Credential = Import-Clixml $Credxmlpath</dev:code> <dev:remarks> <maml:para>The `Export-Clixml` cmdlet encrypts credential objects by using the Windows Data Protection API (/previous-versions/windows/apps/hh464970(v=win.10)). The encryption ensures that only your user account on only that computer can decrypt the contents of the credential object. The exported `CLIXML` file can't be used on a different computer or by a different user.</maml:para> <maml:para>In the example, the file in which the credential is stored is represented by `TestScript.ps1.credential`. Replace TestScript with the name of the script with which you're loading the credential.</maml:para> <maml:para>You send the credential object down the pipeline to `Export-Clixml`, and save it to the path, `$Credxmlpath`, that you specified in the first command.</maml:para> <maml:para>To import the credential automatically into your script, run the final two commands. Run `Import-Clixml` to import the secured credential object into your script. This import eliminates the risk of exposing plain-text passwords in your script.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/export-clixml?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-Html</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-Xml</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Export-Csv</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Import-Clixml</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Join-Path</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Securely Store Credentials on Disk</maml:linkText> <maml:uri>https://powershellcookbook.com/recipe/PukO/securely-store-credentials-on-disk</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Use PowerShell to Pass Credentials to Legacy Systems</maml:linkText> <maml:uri>https://devblogs.microsoft.com/scripting/use-powershell-to-pass-credentials-to-legacy-systems/</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Windows.Security.Cryptography.DataProtection</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Export-Csv</command:name> <command:verb>Export</command:verb> <command:noun>Csv</command:noun> <maml:description> <maml:para>Converts objects into a series of comma-separated value (CSV) strings and saves the strings to a file.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Export-CSV` cmdlet creates a CSV file of the objects that you submit. Each object is a row that includes a comma-separated list of the object's property values. You can use the `Export-CSV` cmdlet to create spreadsheets and share data with programs that accept CSV files as input.</maml:para> <maml:para>Do not format objects before sending them to the `Export-CSV` cmdlet. If `Export-CSV` receives formatted objects the CSV file contains the format properties rather than the object properties. To export only selected properties of an object, use the `Select-Object` cmdlet.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Export-Csv</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>A required parameter that specifies the location to save the CSV output file.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Delimiter</maml:name> <maml:Description> <maml:para>Specifies a delimiter to separate the property values. The default is a comma (`,`). Enter a character, such as a colon (`:`). To specify a semicolon (`;`), enclose it in quotation marks.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Char</command:parameterValue> <dev:type> <maml:name>System.Char</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>comma (,)</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Append</maml:name> <maml:Description> <maml:para>Use this parameter so that `Export-CSV` adds CSV output to the end of the specified file. Without this parameter, `Export-CSV` replaces the file contents without warning.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is `ASCII`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ASCII` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `BigEndianUnicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `Default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `OEM` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `Unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `UTF7` Uses UTF-7.</maml:para> <maml:para>- `UTF8` Uses UTF-8.</maml:para> <maml:para>- `UTF32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">ASCII</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">BigEndianUnicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Default</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OEM</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF7</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF8</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF32</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>ASCII</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>This parameter allows `Export-Csv` to overwrite files with the Read Only attribute.</maml:para> <maml:para>When Force and Append parameters are combined, objects that contain mismatched properties can be written to a CSV file. Only the properties that match are written to the file. The mismatched properties are discarded.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to export as CSV strings. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe objects to `Export-CSV`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to the CSV output file. Unlike Path , the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, use single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NoOverwrite"> <maml:name>NoClobber</maml:name> <maml:Description> <maml:para>Use this parameter so that `Export-CSV` does not overwrite an existing file. By default, if the file exists in the specified path, `Export-CSV` overwrites the file without warning.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NTI"> <maml:name>NoTypeInformation</maml:name> <maml:Description> <maml:para>Removes the #TYPE information header from the output. This parameter became the default in PowerShell 6.0 and is included for backwards compatibility.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Prevents the cmdlet from being processed or making changes. The output shows what would happen if the cmdlet were run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Export-Csv</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>A required parameter that specifies the location to save the CSV output file.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Append</maml:name> <maml:Description> <maml:para>Use this parameter so that `Export-CSV` adds CSV output to the end of the specified file. Without this parameter, `Export-CSV` replaces the file contents without warning.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is `ASCII`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ASCII` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `BigEndianUnicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `Default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `OEM` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `Unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `UTF7` Uses UTF-7.</maml:para> <maml:para>- `UTF8` Uses UTF-8.</maml:para> <maml:para>- `UTF32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">ASCII</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">BigEndianUnicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Default</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OEM</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF7</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF8</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF32</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>ASCII</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>This parameter allows `Export-Csv` to overwrite files with the Read Only attribute.</maml:para> <maml:para>When Force and Append parameters are combined, objects that contain mismatched properties can be written to a CSV file. Only the properties that match are written to the file. The mismatched properties are discarded.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to export as CSV strings. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe objects to `Export-CSV`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to the CSV output file. Unlike Path , the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, use single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NoOverwrite"> <maml:name>NoClobber</maml:name> <maml:Description> <maml:para>Use this parameter so that `Export-CSV` does not overwrite an existing file. By default, if the file exists in the specified path, `Export-CSV` overwrites the file without warning.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NTI"> <maml:name>NoTypeInformation</maml:name> <maml:Description> <maml:para>Removes the #TYPE information header from the output. This parameter became the default in PowerShell 6.0 and is included for backwards compatibility.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseCulture</maml:name> <maml:Description> <maml:para>Uses the list separator for the current culture as the item delimiter. To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Prevents the cmdlet from being processed or making changes. The output shows what would happen if the cmdlet were run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Append</maml:name> <maml:Description> <maml:para>Use this parameter so that `Export-CSV` adds CSV output to the end of the specified file. Without this parameter, `Export-CSV` replaces the file contents without warning.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Delimiter</maml:name> <maml:Description> <maml:para>Specifies a delimiter to separate the property values. The default is a comma (`,`). Enter a character, such as a colon (`:`). To specify a semicolon (`;`), enclose it in quotation marks.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Char</command:parameterValue> <dev:type> <maml:name>System.Char</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>comma (,)</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is `ASCII`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ASCII` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `BigEndianUnicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `Default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `OEM` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `Unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `UTF7` Uses UTF-7.</maml:para> <maml:para>- `UTF8` Uses UTF-8.</maml:para> <maml:para>- `UTF32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>ASCII</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>This parameter allows `Export-Csv` to overwrite files with the Read Only attribute.</maml:para> <maml:para>When Force and Append parameters are combined, objects that contain mismatched properties can be written to a CSV file. Only the properties that match are written to the file. The mismatched properties are discarded.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to export as CSV strings. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe objects to `Export-CSV`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to the CSV output file. Unlike Path , the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, use single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NoOverwrite"> <maml:name>NoClobber</maml:name> <maml:Description> <maml:para>Use this parameter so that `Export-CSV` does not overwrite an existing file. By default, if the file exists in the specified path, `Export-CSV` overwrites the file without warning.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NTI"> <maml:name>NoTypeInformation</maml:name> <maml:Description> <maml:para>Removes the #TYPE information header from the output. This parameter became the default in PowerShell 6.0 and is included for backwards compatibility.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>A required parameter that specifies the location to save the CSV output file.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseCulture</maml:name> <maml:Description> <maml:para>Uses the list separator for the current culture as the item delimiter. To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Prevents the cmdlet from being processed or making changes. The output shows what would happen if the cmdlet were run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe any object with an Extended Type System (ETS) adapter to `Export-CSV`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>The CSV list is sent to the file designated in the Path parameter.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>The `Export-CSV` cmdlet converts the objects that you submit into a series of CSV strings and saves them in the specified text file. You can use `Export-CSV` to save objects in a CSV file and then use the `Import-Csv` cmdlet to create objects from the CSV file.</maml:para> <maml:para>In the CSV file, each object is represented by a comma-separated list of the property values of the object. The property values are converted to strings using the ToString() method. The strings are represented by the property value name. `Export-CSV does not export the methods of the object.</maml:para> <maml:para>The CSV strings are output as follows:</maml:para> <maml:para>- By default the first string contains the #TYPE information header followed by the object type's fully qualified name. For example, #TYPE System.Diagnostics.Process . - If NoTypeInformation is used the first string includes the column headers. The headers contain the first object's property names as a comma-separated list. - The remaining strings contain comma-separated lists of each object's property values.</maml:para> <maml:para>When you submit multiple objects to `Export-CSV`, `Export-CSV` organizes the file based on the properties of the first object that you submit. If the remaining objects do not have one of the specified properties, the property value of that object is null, as represented by two consecutive commas. If the remaining objects have additional properties, those property values are not included in the file.</maml:para> <maml:para>You can use the `Import-Csv` cmdlet to recreate objects from the CSV strings in the files. The resulting objects are CSV versions of the original objects that consist of string representations of the property values and no methods.</maml:para> <maml:para>The `ConvertTo-Csv` and `ConvertFrom-Csv` cmdlets convert objects to CSV strings and from CSV strings. `Export-CSV` is the same as `ConvertTo-CSV`, except that it saves the CSV strings in a file.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------ Example 1: Export process properties to a CSV file ------</maml:title> <dev:code>Get-Process -Name WmiPrvSE | Select-Object -Property BasePriority,Id,SessionId,WorkingSet | Export-Csv -Path .\WmiData.csv -NoTypeInformation Import-Csv -Path .\WmiData.csv BasePriority Id SessionId WorkingSet ------------ -- --------- ---------- 8 976 0 20267008 8 2292 0 36786176 8 3816 0 30351360 8 8604 0 15011840 8 10008 0 8830976 8 11764 0 14237696 8 54632 0 9502720</dev:code> <dev:remarks> <maml:para>The `Get-Process` cmdlet gets the Process objects. The Name parameter filters the output to include only the WmiPrvSE process objects. The process objects are sent down the pipeline to the `Select-Object` cmdlet. `Select-Object` uses the Property parameter to select a subset of process object properties. The process objects are sent down the pipeline to the `Export-Csv` cmdlet. `Export-Csv` converts the process objects to a series of CSV strings. The Path parameter specifies that the WmiData.csv file is saved in the current directory. The NoTypeInformation parameter removes the #TYPE information header from the CSV output and is not required in PowerShell 6. The `Import-Csv` cmdlet uses the Path parameter to display the file located in the current directory.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 2: Export processes to a comma-delimited file ----</maml:title> <dev:code>Get-Process | Export-Csv -Path .\Processes.csv -NoTypeInformation Get-Content -Path .\Processes.csv "Name","SI","Handles","VM","WS","PM","NPM","Path","Parent","Company","CPU","FileVersion", ... "ApplicationFrameHost","4","511","2203597099008","35364864","21979136","30048", ...</dev:code> <dev:remarks> <maml:para>The `Get-Process` cmdlet gets Process objects. The process objects are sent down the pipeline to the `Export-Csv` cmdlet. `Export-Csv` converts the process objects to a series of CSV strings. The Path parameter specifies that the Processes.csv file is saved in the current directory. The NoTypeInformation parameter removes the #TYPE information header from the CSV output and is not required in PowerShell 6. The `Get-Content` cmdlet uses the Path parameter to display the file located in the current directory.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 3: Export processes to a semicolon delimited file --</maml:title> <dev:code>Get-Process | Export-Csv -Path .\Processes.csv -Delimiter ';' -NoTypeInformation Get-Content -Path .\Processes.csv "Name";"SI";"Handles";"VM";"WS";"PM";"NPM";"Path";"Parent";"Company";"CPU";"FileVersion"; ... "ApplicationFrameHost";"4";"509";"2203595321344";"34807808";"21770240";"29504"; ...</dev:code> <dev:remarks> <maml:para>The `Get-Process` cmdlet gets Process objects. The process objects are sent down the pipeline to the `Export-Csv` cmdlet. `Export-Csv` converts the process objects to a series of CSV strings. The Path parameter specifies that the Processes.csv file is saved in the current directory. The Delimiter parameter specifies a semicolon to separate the string values. The NoTypeInformation parameter removes the #TYPE information header from the CSV output and is not required in PowerShell 6. The `Get-Content` cmdlet uses the Path parameter to display the file located in the current directory.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 4: Export processes using the current culture's list separator</maml:title> <dev:code>(Get-Culture).TextInfo.ListSeparator Get-Process | Export-Csv -Path .\Processes.csv -UseCulture -NoTypeInformation Get-Content -Path .\Processes.csv "Name","SI","Handles","VM","WS","PM","NPM","Path","Parent","Company","CPU","FileVersion", ... "ApplicationFrameHost","4","511","2203597099008","35364864","21979136","30048", ...</dev:code> <dev:remarks> <maml:para>The `Get-Culture` cmdlet uses the nested properties TextInfo and ListSeparator and displays the current culture's default list separator. The `Get-Process` cmdlet gets Process objects. The process objects are sent down the pipeline to the `Export-Csv` cmdlet. `Export-Csv` converts the process objects to a series of CSV strings. The Path parameter specifies that the Processes.csv file is saved in the current directory. The UseCulture parameter uses the current culture's default list separator as the delimiter. The NoTypeInformation parameter removes the #TYPE information header from the CSV output and is not required in PowerShell 6. The `Get-Content` cmdlet uses the Path parameter to display the file located in the current directory.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 5: Export processes with type information ------</maml:title> <dev:code>Get-Process | Export-Csv -Path .\Processes.csv Get-Content -Path .\Processes.csv #TYPE System.Diagnostics.Process "Name","SI","Handles","VM","WS","PM","NPM","Path","Company","CPU","FileVersion", ... "ApplicationFrameHost","4","507","2203595001856","35139584","20934656","29504", ...</dev:code> <dev:remarks> <maml:para>The `Get-Process` cmdlet gets Process objects. The process objects are sent down the pipeline to the `Export-Csv` cmdlet. `Export-Csv` converts the process objects to a series of CSV strings. The Path parameter specifies that the Processes.csv file is saved in the current directory. The `Get-Content` cmdlet uses the Path parameter to display the file located in the current directory.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 6: Export and append objects to a CSV file ------</maml:title> <dev:code>$AppService = (Get-Service -DisplayName *Application* | Select-Object -Property DisplayName, Status) $AppService | Export-Csv -Path .\Services.Csv -NoTypeInformation Get-Content -Path .\Services.Csv $WinService = (Get-Service -DisplayName *Windows* | Select-Object -Property DisplayName, Status) $WinService | Export-Csv -Path ./Services.csv -NoTypeInformation -Append Get-Content -Path .\Services.Csv "DisplayName","Status" "Application Layer Gateway Service","Stopped" "Application Identity","Running" "Windows Audio Endpoint Builder","Running" "Windows Audio","Running" "Windows Event Log","Running"</dev:code> <dev:remarks> <maml:para>The `Get-Service` cmdlet gets service objects. The DisplayName parameter returns services that contain the word Application. The service objects are sent down the pipeline to the `Select-Object` cmdlet. `Select-Object` uses the Property parameter to specify the DisplayName and Status properties. The `$AppService` variable stores the objects.</maml:para> <maml:para>The `$AppService` objects are sent down the pipeline to the `Export-Csv` cmdlet. `Export-Csv` converts the service objects to a series of CSV strings. The Path parameter specifies that the Services.csv file is saved in the current directory. The NoTypeInformation parameter removes the #TYPE information header from the CSV output and is not required in PowerShell 6. The `Get-Content` cmdlet uses the Path parameter to display the file located in the current directory.</maml:para> <maml:para>The `Get-Service` and `Select-Object` cmdlets are repeated for services that contain the word Windows. The `$WinService` variable stores the service objects. The `Export-Csv` cmdlet uses the Append parameter to specify that the `$WinService` objects are added to the existing Services.csv file. The `Get-Content` cmdlet is repeated to display the updated file that includes the appended data.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 7: Format cmdlet within a pipeline creates unexpected results</maml:title> <dev:code>Get-Date | Select-Object -Property DateTime, Day, DayOfWeek, DayOfYear | Export-Csv -Path .\DateTime.csv -NoTypeInformation Get-Content -Path .\DateTime.csv "DateTime","Day","DayOfWeek","DayOfYear" "Wednesday, January 2, 2019 14:59:34","2","Wednesday","2" Get-Date | Format-Table -Property DateTime, Day, DayOfWeek, DayOfYear | Export-Csv -Path .\FTDateTime.csv -NoTypeInformation Get-Content -Path .\FTDateTime.csv "ClassId2e4f51ef21dd47e99d3c952918aff9cd","pageHeaderEntry","pageFooterEntry","autosizeInfo", ... "033ecb2bc07a4d43b5ef94ed5a35d280",,,,"Microsoft.PowerShell.Commands.Internal.Format. ... "9e210fe47d09416682b841769c78b8a3",,,,, "27c87ef9bbda4f709f6b4002fa4af63c",,,,, "4ec4f0187cb04f4cb6973460dfe252df",,,,, "cf522b78d86c486691226b40aa69e95c",,,,,</dev:code> <dev:remarks> <maml:para>The `Get-Date` cmdlet gets the DateTime object. The object is sent down the pipeline to the `Select-Object` cmdlet. `Select-Object` uses the Property parameter to select a subset of object properties. The object is sent down the pipeline to the `Export-Csv` cmdlet. `Export-Csv` converts the object to a CSV format. The Path parameter specifies that the DateTime.csv file is saved in the current directory. The NoTypeInformation parameter removes the #TYPE information header from the CSV output and is not required in PowerShell 6. The `Get-Content` cmdlet uses the Path parameter to display the CSV file located in the current directory.</maml:para> <maml:para>When the `Format-Table` cmdlet is used within the pipeline to select properties unexpected results are received. `Format-Table` sends table format objects down the pipeline to the `Export-Csv` cmdlet rather than the DateTime object. `Export-Csv` converts the table format objects to a series of CSV strings. The `Get-Content` cmdlet displays the CSV file which contains the table format objects.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 8: Using the Force parameter to overwrite read-only files</maml:title> <dev:code>New-Item -Path .\ReadOnly.csv -ItemType File Set-ItemProperty -Path .\ReadOnly.csv -Name IsReadOnly -Value $true Get-Process | Export-Csv -Path .\ReadOnly.csv -NoTypeInformation Export-Csv : Access to the path 'C:\ReadOnly.csv' is denied. At line:1 char:15 + Get-Process | Export-Csv -Path .\ReadOnly.csv -NoTypeInformation + ~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (:) [Export-Csv], UnauthorizedAccessException + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.ExportCsvCommand Get-Process | Export-Csv -Path .\ReadOnly.csv -NoTypeInformation -Force Get-Content -Path .\ReadOnly.csv "Name";"SI";"Handles";"VM";"WS";"PM";"NPM";"Path";"Parent";"Company";"CPU";"FileVersion"; ... "ApplicationFrameHost";"4";"509";"2203595321344";"34807808";"21770240";"29504"; ...</dev:code> <dev:remarks> <maml:para>The `New-Item` cmdlet uses the Path and ItemType parameters to create the ReadOnly.csv file in the current directory. The `Set-ItemProperty` cmdlet uses the Name and Value parameters to change the file's IsReadOnly property to true. The `Get-Process` cmdlet gets Process objects. The process objects are sent down the pipeline to the `Export-Csv` cmdlet. `Export-Csv` converts the process objects to a series of CSV strings. The Path parameter specifies that the ReadOnly.csv file is saved in the current directory. The NoTypeInformation parameter removes the #TYPE information header from the CSV output and is not required in PowerShell 6. The output shows that the file is not written because access is denied.</maml:para> <maml:para>The Force parameter is added to the `Export-Csv` cmdlet to force the export to write to the file. The `Get-Content` cmdlet uses the Path parameter to display the file located in the current directory.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 9: Using the Force parameter with Append -------</maml:title> <dev:code>$Content = [PSCustomObject]@{Name = 'PowerShell Core'; Version = '6.0'} $Content | Export-Csv -Path .\ParmFile.csv -NoTypeInformation $AdditionalContent = [PSCustomObject]@{Name = 'Windows PowerShell'; Edition = 'Desktop'} $AdditionalContent | Export-Csv -Path .\ParmFile.csv -NoTypeInformation -Append Export-Csv : Cannot append CSV content to the following file: ParmFile.csv. The appended object does not have a property that corresponds to the following column: Version. To continue with mismatched properties, add the -Force parameter, and then retry the command. At line:1 char:22 + $AdditionalContent | Export-Csv -Path .\ParmFile.csv -NoTypeInformation -Append + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (Version:String) [Export-Csv], InvalidOperationException + FullyQualifiedErrorId : CannotAppendCsvWithMismatchedPropertyNames,Microsoft.PowerShell. ... $AdditionalContent | Export-Csv -Path .\ParmFile.csv -NoTypeInformation -Append -Force Import-Csv -Path .\ParmFile.csv Name Version ---- ------- PowerShell Core 6.0 Windows PowerShell</dev:code> <dev:remarks> <maml:para>An expression creates the PSCustomObject with Name and Version properties. The values are stored in the `$Content` variable. The `$Content` variable is sent down the pipeline to the `Export-Csv` cmdlet. `Export-Csv` uses the Path parameter and saves the ParmFile.csv file in the current directory. The NoTypeInformation parameter removes the #TYPE information header from the CSV output and is not required in PowerShell 6.</maml:para> <maml:para>Another expression creates a PSCustomObject with the Name and Edition properties. The values are stored in the `$AdditionalContent` variable. The `$AdditionalContent` variable is sent down the pipeline to the `Export-Csv` cmdlet. The Append parameter is used to add the data to the file. The append fails because there is a property name mismatch between Version and Edition .</maml:para> <maml:para>The `Export-Csv` cmdlet Force parameter is used to force the export to write to the file. The Edition property is discarded. The `Import-Csv` cmdlet uses the Path parameter to display the file located in the current directory.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/export-csv?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertFrom-Csv</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-Csv</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-Table</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Import-Csv</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Select-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Export-FormatData</command:name> <command:verb>Export</command:verb> <command:noun>FormatData</command:noun> <maml:description> <maml:para>Saves formatting data from the current session in a formatting file.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Export-FormatData` cmdlet creates Windows PowerShell formatting files (format.ps1xml) from the formatting objects in the current session. It takes the ExtendedTypeDefinition objects that `Get-FormatData` returns and saves them in a file in XML format.</maml:para> <maml:para>Windows PowerShell uses the data in formatting files (format.ps1xml) to generate the default display of Microsoft .NET Framework objects in the session. You can view and edit the formatting files and use the Update-FormatData cmdlet to add the formatting data to a session.</maml:para> <maml:para>For more information about formatting files in Windows PowerShell, see about_Format.ps1xml (../Microsoft.PowerShell.Core/About/about_Format.ps1xml.md).</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Export-FormatData</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Forces the command to run without asking for user confirmation.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>IncludeScriptBlock</maml:name> <maml:Description> <maml:para>Indicates whether script blocks in the format data are exported.</maml:para> <maml:para>Because script blocks contain code and can be used maliciously, they are not exported by default.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the format data objects to be exported. Enter a variable that contains the objects or a command that gets the objects, such as a `Get-FormatData` command. You can also pipe the objects from `Get-FormatData` to `Export-FormatData`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ExtendedTypeDefinition[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ExtendedTypeDefinition[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies a location for the output file. Unlike the Path parameter, the value of LiteralPath is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NoOverwrite"> <maml:name>NoClobber</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet does not overwrite existing files. By default, `Export-FormatData` overwrites files without warning unless the file has the read-only attribute.</maml:para> <maml:para>To direct `Export-FormatData` to overwrite read-only files, use the Force parameter.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Export-FormatData</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Forces the command to run without asking for user confirmation.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>IncludeScriptBlock</maml:name> <maml:Description> <maml:para>Indicates whether script blocks in the format data are exported.</maml:para> <maml:para>Because script blocks contain code and can be used maliciously, they are not exported by default.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the format data objects to be exported. Enter a variable that contains the objects or a command that gets the objects, such as a `Get-FormatData` command. You can also pipe the objects from `Get-FormatData` to `Export-FormatData`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ExtendedTypeDefinition[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ExtendedTypeDefinition[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NoOverwrite"> <maml:name>NoClobber</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet does not overwrite existing files. By default, `Export-FormatData` overwrites files without warning unless the file has the read-only attribute.</maml:para> <maml:para>To direct `Export-FormatData` to overwrite read-only files, use the Force parameter.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="FilePath"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies a location for the output file. Enter a path (optional) and file name with a format.ps1xml file name extension. If you omit the path, `Export-FormatData` creates the file in the current directory.</maml:para> <maml:para>If you use a file name extension other than .ps1xml, the `Update-FormatData` cmdlet will not recognize the file.</maml:para> <maml:para>If you specify an existing file, `Export-FormatData` overwrites the file without warning, unless the file has the read-only attribute. To overwrite a read-only file, use the Force parameter. To prevent files from being overwritten, use the NoClobber parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Forces the command to run without asking for user confirmation.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>IncludeScriptBlock</maml:name> <maml:Description> <maml:para>Indicates whether script blocks in the format data are exported.</maml:para> <maml:para>Because script blocks contain code and can be used maliciously, they are not exported by default.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the format data objects to be exported. Enter a variable that contains the objects or a command that gets the objects, such as a `Get-FormatData` command. You can also pipe the objects from `Get-FormatData` to `Export-FormatData`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ExtendedTypeDefinition[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ExtendedTypeDefinition[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies a location for the output file. Unlike the Path parameter, the value of LiteralPath is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NoOverwrite"> <maml:name>NoClobber</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet does not overwrite existing files. By default, `Export-FormatData` overwrites files without warning unless the file has the read-only attribute.</maml:para> <maml:para>To direct `Export-FormatData` to overwrite read-only files, use the Force parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="FilePath"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies a location for the output file. Enter a path (optional) and file name with a format.ps1xml file name extension. If you omit the path, `Export-FormatData` creates the file in the current directory.</maml:para> <maml:para>If you use a file name extension other than .ps1xml, the `Update-FormatData` cmdlet will not recognize the file.</maml:para> <maml:para>If you specify an existing file, `Export-FormatData` overwrites the file without warning, unless the file has the read-only attribute. To overwrite a read-only file, use the Force parameter. To prevent files from being overwritten, use the NoClobber parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.ExtendedTypeDefinition</maml:name> </dev:type> <maml:description> <maml:para>You can pipe ExtendedTypeDefinition objects from `Get-FormatData` to `Export-FormatData`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>`Export-FormatData` does not return any objects. It generates a file and saves it in the specified path.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>- To use any formatting file, including an exported formatting file, the execution policy for the session must allow scripts and configuration files to run. For more information, see about_Execution_Policies (../Microsoft.PowerShell.Core/About/about_Execution_Policies.md).</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------ Example 1: Export session format data ------------</maml:title> <dev:code>Get-FormatData -TypeName "*" | Export-FormatData -Path "allformat.ps1xml" -IncludeScriptBlock</dev:code> <dev:remarks> <maml:para>This command exports all of the format data in the session to the AllFormat.ps1xml file.</maml:para> <maml:para>The command uses the `Get-FormatData` cmdlet to get the format data in the session. A value of `*` (all) for the TypeName parameter directs the cmdlet to get all of the data in the session.</maml:para> <maml:para>The command uses a pipeline operator (`|`) to send the format data from the `Get-FormatData` command to the `Export-FormatData` cmdlet, which exports the format data to the AllFormat.ps1 file.</maml:para> <maml:para>The `Export-FormatData` command uses the IncludeScriptBlock parameter to include script blocks in the format data in the file.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 2: Export format data for a type -----------</maml:title> <dev:code>$F = Get-FormatData -TypeName "helpinfoshort" Export-FormatData -InputObject $F -Path "c:\test\help.format.ps1xml" -IncludeScriptBlock</dev:code> <dev:remarks> <maml:para>These commands export the format data for the HelpInfoShort type to the Help.format.ps1xml file.</maml:para> <maml:para>The first command uses the `Get-FormatData` cmdlet to get the format data for the HelpInfoShort type, and it saves it in the `$F` variable.</maml:para> <maml:para>The second command uses the InputObject parameter of the `Export-FormatData` cmdlet to enter the format data saved in the `$F` variable. It also uses the IncludeScriptBlock parameter to include script blocks in the output.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 3: Export format data without a script block -----</maml:title> <dev:code>Get-FormatData -TypeName "System.Diagnostics.Process" | Export-FormatData -Path process.format.ps1xml Update-FormatData -PrependPath ".\process.format.ps1xml" Get-Process p* Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- 323 5600 powershell 336 3900 powershell_ise 138 4076 PresentationFontCache</dev:code> <dev:remarks> <maml:para>This example shows the effect of omitting the IncludeScriptBlock parameter from an `Export-FormatData` command.</maml:para> <maml:para>The first command uses the `Get-FormatData` cmdlet to get the format data for the System.Diagnostics.Process object that the Get-Process cmdlet returns. The command uses a pipeline operator (`|`) to send the formatting data to the `Export-FormatData` cmdlet, which exports it to the Process.format.ps1xml file in the current directory.</maml:para> <maml:para>In this case, the `Export-FormatData` command does not use the IncludeScriptBlock parameter.</maml:para> <maml:para>The second command uses the `Update-FormatData` cmdlet to add the Process.format.ps1xml file to the current session. The command uses the PrependPath parameter to ensure that the formatting data for process objects in the Process.format.ps1xml file is found before the standard formatting data for process objects.</maml:para> <maml:para>The third command shows the effects of this change. The command uses the `Get-Process` cmdlet to get processes that have names that begin with P. The output shows that property values that are calculated by using script blocks are missing from the display.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/export-formatdata?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-FormatData</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Update-FormatData</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Export-PSSession</command:name> <command:verb>Export</command:verb> <command:noun>PSSession</command:noun> <maml:description> <maml:para>Exports commands from another session and saves them in a PowerShell module.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Export-PSSession` cmdlet gets cmdlets, functions, aliases, and other command types from another PowerShell session (PSSession) on a local or remote computer and saves them in a PowerShell module. To add the commands from the module to the current session, use the `Import-Module` cmdlet.</maml:para> <maml:para>Unlike `Import-PSSession`, which imports commands from another PSSession into the current session, `Export-PSSession` saves the commands in a module. The commands are not imported into the current session.</maml:para> <maml:para>To export commands, use the `New-PSSession` cmdlet to create a PSSession that has the commands that you want to export. Then use the `Export-PSSession` cmdlet to export the commands.</maml:para> <maml:para>To prevent command name conflicts, the default for `Export-PSSession` is to export all commands, except for commands that exist in the current session. You can use the CommandName parameter to specify the commands to export.</maml:para> <maml:para>The `Export-PSSession` cmdlet uses the implicit remoting feature of PowerShell. When you import commands into the current session, they run implicitly in the original session or in a similar session on the originating computer.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Export-PSSession</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Session</maml:name> <maml:Description> <maml:para>Specifies the PSSession from which the commands are exported. Enter a variable that contains a session object or a command that gets a session object, such as a `Get-PSSession` command. This parameter is required.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Runspaces.PSSession</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.PSSession</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="PSPath, ModuleName"> <maml:name>OutputModule</maml:name> <maml:Description> <maml:para>Specifies an optional path and name for the module created by `Export-PSSession`. The default path is `$home\Documents\WindowsPowerShell\Modules`. This parameter is required.</maml:para> <maml:para>If the module subdirectory or any of the files that `Export-PSSession` creates already exist, the command fails. To overwrite existing files, use the Force parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>$home\Documents\WindowsPowerShell\Modules</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="2" aliases="Name"> <maml:name>CommandName</maml:name> <maml:Description> <maml:para>Exports only the commands with the specified names or name patterns. Wildcards are permitted. Use CommandName or its alias, Name .</maml:para> <maml:para>By default, `Export-PSSession` exports all commands from the PSSession except for commands that have the same names as commands in the current session. This prevents commands from being hidden or replaced by commands in the current session. To export all commands, even those that hide or replace other commands, use the AllowClobber parameter.</maml:para> <maml:para>If you use the CommandName parameter, the formatting files for the commands are not exported unless you use the FormatTypeName parameter. Similarly, if you use the FormatTypeName parameter, no commands are exported unless you use the CommandName parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>All commands in the session.</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="3" aliases="none"> <maml:name>FormatTypeName</maml:name> <maml:Description> <maml:para>Exports formatting instructions only for the specified Microsoft .NET Framework types. Enter the type names. By default, `Export-PSSession` exports formatting instructions for all .NET Framework types that are not in the System.Management.Automation namespace.</maml:para> <maml:para>The value of this parameter must be the name of a type that is returned by a `Get-FormatData` command in the session from which the commands are being imported. To get all of the formatting data in the remote session, type `*`.</maml:para> <maml:para>If you use the FormatTypeName parameter, no commands are exported unless you use the CommandName parameter.</maml:para> <maml:para>If you use the CommandName parameter, the formatting files for the commands are not exported unless you use the FormatTypeName parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AllowClobber</maml:name> <maml:Description> <maml:para>Exports the specified commands, even if they have the same names as commands in the current session.</maml:para> <maml:para>If you export a command with the same name as a command in the current session, the exported command hides or replaces the original commands. For more information, see about_Command_Precedence (../Microsoft.PowerShell.Core/About/about_Command_Precedence.md).</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Args"> <maml:name>ArgumentList</maml:name> <maml:Description> <maml:para>Exports the variant of the command that results from using the specified arguments (parameter values).</maml:para> <maml:para>For example, to export the variant of the `Get-Item` command in the certificate (Cert:) drive in the PSSession in `$S`, type `Export-PSSession -Session $S -Command Get-Item -ArgumentList cert:`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Certificate</maml:name> <maml:Description> <maml:para>Specifies the client certificate that is used to sign the format files (*.Format.ps1xml) or script module files (.psm1) in the module that `Export-PSSession` creates. Enter a variable that contains a certificate or a command or expression that gets the certificate.</maml:para> <maml:para>To find a certificate, use the `Get-PfxCertificate` cmdlet or use the `Get-ChildItem` cmdlet in the Certificate (Cert:) drive. If the certificate is not valid or does not have sufficient authority, the command fails.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Security.Cryptography.X509Certificates.X509Certificate2</command:parameterValue> <dev:type> <maml:name>System.Security.Cryptography.X509Certificates.X509Certificate2</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Type"> <maml:name>CommandType</maml:name> <maml:Description> <maml:para>Exports only the specified types of command objects. Use CommandType or its alias, Type .</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- Alias. All PowerShell aliases in the current session.</maml:para> <maml:para>- All. All command types. It is the equivalent of `Get-Command -Name *`.</maml:para> <maml:para>- Application. All files other than PowerShell files in paths listed in the Path environment</maml:para> <maml:para> variable (`$env:path`), including .txt, .exe, and .dll files. - Cmdlet. The cmdlets in the current session. Cmdlet is the default.</maml:para> <maml:para>- Configuration. A PowerShell configuration. For more information, see about_Session_Configurations (../Microsoft.PowerShell.Core/About/about_Session_Configurations.md). - ExternalScript. All .ps1 files in the paths listed in the Path environment variable (`$env:path`). - Filter and Function. All PowerShell functions.</maml:para> <maml:para>- Script. Script blocks in the current session.</maml:para> <maml:para>- Workflow. A PowerShell workflow. For more information, see about_Workflows (../PSWorkflow/About/about_Workflows.md).</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Alias</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">All</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Application</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Cmdlet</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Configuration</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ExternalScript</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Filter</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Function</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Script</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Workflow</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.CommandTypes</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.CommandTypes</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>All commands in the session.</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is `UTF8`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ASCII` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `BigEndianUnicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `Default` Uses the encoding that corresponds to the system's active code page.</maml:para> <maml:para>- `OEM` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `Unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `UTF7` Uses UTF-7.</maml:para> <maml:para>- `UTF8` Uses UTF-8.</maml:para> <maml:para>- `UTF32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">ASCII</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">BigEndianUnicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Default</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OEM</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF7</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF8</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF32</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>UTF8</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Overwrites one or more existing output files, even if the file has the read-only attribute.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>FullyQualifiedModule</maml:name> <maml:Description> <maml:para>Specifies modules with names that are specified in the form of ModuleSpecification objects. See the Remarks section of ModuleSpecification Constructor (Hashtable) (https://msdn.microsoft.com/library/jj136290).</maml:para> <maml:para>For example, the FullyQualifiedModule parameter accepts a module name that is specified in either of these formats:</maml:para> <maml:para>`@{ModuleName = "modulename"; ModuleVersion = "version_number"}`</maml:para> <maml:para>`@{ModuleName = "modulename"; ModuleVersion = "version_number"; Guid = "GUID"}` ModuleName and ModuleVersion are required, but Guid is optional. You cannot specify the FullyQualifiedModule parameter in the same command as a Module parameter; the two parameters are mutually exclusive.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.ModuleSpecification[]</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.ModuleSpecification[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSSnapin"> <maml:name>Module</maml:name> <maml:Description> <maml:para>Exports only the commands in the specified PowerShell snap-ins and modules. Enter the snap-in and module names. Wildcards are not permitted.</maml:para> <maml:para>For more information, see `Import-Module` and about_PSSnapins (../Microsoft.PowerShell.Core/About/about_PSSnapins.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>All commands in the session.</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AllowClobber</maml:name> <maml:Description> <maml:para>Exports the specified commands, even if they have the same names as commands in the current session.</maml:para> <maml:para>If you export a command with the same name as a command in the current session, the exported command hides or replaces the original commands. For more information, see about_Command_Precedence (../Microsoft.PowerShell.Core/About/about_Command_Precedence.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Args"> <maml:name>ArgumentList</maml:name> <maml:Description> <maml:para>Exports the variant of the command that results from using the specified arguments (parameter values).</maml:para> <maml:para>For example, to export the variant of the `Get-Item` command in the certificate (Cert:) drive in the PSSession in `$S`, type `Export-PSSession -Session $S -Command Get-Item -ArgumentList cert:`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Certificate</maml:name> <maml:Description> <maml:para>Specifies the client certificate that is used to sign the format files (*.Format.ps1xml) or script module files (.psm1) in the module that `Export-PSSession` creates. Enter a variable that contains a certificate or a command or expression that gets the certificate.</maml:para> <maml:para>To find a certificate, use the `Get-PfxCertificate` cmdlet or use the `Get-ChildItem` cmdlet in the Certificate (Cert:) drive. If the certificate is not valid or does not have sufficient authority, the command fails.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Security.Cryptography.X509Certificates.X509Certificate2</command:parameterValue> <dev:type> <maml:name>System.Security.Cryptography.X509Certificates.X509Certificate2</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="2" aliases="Name"> <maml:name>CommandName</maml:name> <maml:Description> <maml:para>Exports only the commands with the specified names or name patterns. Wildcards are permitted. Use CommandName or its alias, Name .</maml:para> <maml:para>By default, `Export-PSSession` exports all commands from the PSSession except for commands that have the same names as commands in the current session. This prevents commands from being hidden or replaced by commands in the current session. To export all commands, even those that hide or replace other commands, use the AllowClobber parameter.</maml:para> <maml:para>If you use the CommandName parameter, the formatting files for the commands are not exported unless you use the FormatTypeName parameter. Similarly, if you use the FormatTypeName parameter, no commands are exported unless you use the CommandName parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>All commands in the session.</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Type"> <maml:name>CommandType</maml:name> <maml:Description> <maml:para>Exports only the specified types of command objects. Use CommandType or its alias, Type .</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- Alias. All PowerShell aliases in the current session.</maml:para> <maml:para>- All. All command types. It is the equivalent of `Get-Command -Name *`.</maml:para> <maml:para>- Application. All files other than PowerShell files in paths listed in the Path environment</maml:para> <maml:para> variable (`$env:path`), including .txt, .exe, and .dll files. - Cmdlet. The cmdlets in the current session. Cmdlet is the default.</maml:para> <maml:para>- Configuration. A PowerShell configuration. For more information, see about_Session_Configurations (../Microsoft.PowerShell.Core/About/about_Session_Configurations.md). - ExternalScript. All .ps1 files in the paths listed in the Path environment variable (`$env:path`). - Filter and Function. All PowerShell functions.</maml:para> <maml:para>- Script. Script blocks in the current session.</maml:para> <maml:para>- Workflow. A PowerShell workflow. For more information, see about_Workflows (../PSWorkflow/About/about_Workflows.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.CommandTypes</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.CommandTypes</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>All commands in the session.</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is `UTF8`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ASCII` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `BigEndianUnicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `Default` Uses the encoding that corresponds to the system's active code page.</maml:para> <maml:para>- `OEM` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `Unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `UTF7` Uses UTF-7.</maml:para> <maml:para>- `UTF8` Uses UTF-8.</maml:para> <maml:para>- `UTF32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>UTF8</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Overwrites one or more existing output files, even if the file has the read-only attribute.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="3" aliases="none"> <maml:name>FormatTypeName</maml:name> <maml:Description> <maml:para>Exports formatting instructions only for the specified Microsoft .NET Framework types. Enter the type names. By default, `Export-PSSession` exports formatting instructions for all .NET Framework types that are not in the System.Management.Automation namespace.</maml:para> <maml:para>The value of this parameter must be the name of a type that is returned by a `Get-FormatData` command in the session from which the commands are being imported. To get all of the formatting data in the remote session, type `*`.</maml:para> <maml:para>If you use the FormatTypeName parameter, no commands are exported unless you use the CommandName parameter.</maml:para> <maml:para>If you use the CommandName parameter, the formatting files for the commands are not exported unless you use the FormatTypeName parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>FullyQualifiedModule</maml:name> <maml:Description> <maml:para>Specifies modules with names that are specified in the form of ModuleSpecification objects. See the Remarks section of ModuleSpecification Constructor (Hashtable) (https://msdn.microsoft.com/library/jj136290).</maml:para> <maml:para>For example, the FullyQualifiedModule parameter accepts a module name that is specified in either of these formats:</maml:para> <maml:para>`@{ModuleName = "modulename"; ModuleVersion = "version_number"}`</maml:para> <maml:para>`@{ModuleName = "modulename"; ModuleVersion = "version_number"; Guid = "GUID"}` ModuleName and ModuleVersion are required, but Guid is optional. You cannot specify the FullyQualifiedModule parameter in the same command as a Module parameter; the two parameters are mutually exclusive.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.ModuleSpecification[]</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.ModuleSpecification[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSSnapin"> <maml:name>Module</maml:name> <maml:Description> <maml:para>Exports only the commands in the specified PowerShell snap-ins and modules. Enter the snap-in and module names. Wildcards are not permitted.</maml:para> <maml:para>For more information, see `Import-Module` and about_PSSnapins (../Microsoft.PowerShell.Core/About/about_PSSnapins.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>All commands in the session.</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="PSPath, ModuleName"> <maml:name>OutputModule</maml:name> <maml:Description> <maml:para>Specifies an optional path and name for the module created by `Export-PSSession`. The default path is `$home\Documents\WindowsPowerShell\Modules`. This parameter is required.</maml:para> <maml:para>If the module subdirectory or any of the files that `Export-PSSession` creates already exist, the command fails. To overwrite existing files, use the Force parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>$home\Documents\WindowsPowerShell\Modules</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Session</maml:name> <maml:Description> <maml:para>Specifies the PSSession from which the commands are exported. Enter a variable that contains a session object or a command that gets a session object, such as a `Get-PSSession` command. This parameter is required.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Runspaces.PSSession</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.PSSession</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe objects to `Export-PSSession`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.IO.FileInfo</maml:name> </dev:type> <maml:description> <maml:para>`Export-PSSession` returns a list of files that comprise the module that it created.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>`Export-PSSession` relies on the PowerShell remoting infrastructure. To use this cmdlet, the computer must be configured for remoting. For more information, see about_Remote_Requirements (../Microsoft.PowerShell.Core/About/about_Remote_Requirements.md).</maml:para> <maml:para>You cannot use `Export-PSSession` to export a PowerShell provider.</maml:para> <maml:para>Exported commands run implicitly in the PSSession from which they were exported. The details of running the commands remotely are handled entirely by PowerShell. You can run the exported commands just as you would run local commands.</maml:para> <maml:para>`Export-ModuleMember` captures and saves information about the PSSession in the module that it exports. If the PSSession from which the commands were exported is closed when you import the module, and there are no active PSSessions to the same computer, the commands in the module attempt to recreate the PSSession. If attempts to recreate the PSSession fail, the exported commands will not run.</maml:para> <maml:para>The session information that `Export-ModuleMember` captures and saves in the module does not include session options, such as those that you specify in the `$PSSessionOption` preference variable or by using the SessionOption parameter of the `New-PSSession`, `Enter-PSSession`, or `Invoke-Command` cmdlets. If the original PSSession is closed when you import the module, the module will use another PSSession to the same computer, if one is available. To enable the imported commands to run in a correctly configured session, create a PSSession with the options that you want before you import the module.</maml:para> <maml:para>To find the commands to export, `Export-PSSession` uses the `Invoke-Command` cmdlet to run a `Get-Command` command in the PSSession. To get and save formatting data for the commands, it uses the `Get-FormatData` and `Export-FormatData` cmdlets. You might see error messages from `Invoke-Command`, `Get-Command`, `Get-FormatData`, and `Export-FormatData` when you run an `Export-PSSession` command. Also, `Export-PSSession` cannot export commands from a session that does not include the `Get-Command`, `Get-FormatData`, `Select-Object`, and `Get-Help` cmdlets.</maml:para> <maml:para>`Export-PSSession` uses the `Write-Progress` cmdlet to display the progress of the command. You might see the progress bar while the command is running.</maml:para> <maml:para>Exported commands have the same limitations as other remote commands, including the inability to start a program with a user interface, such as Notepad.</maml:para> <maml:para>Because PowerShell profiles are not run in PSSessions, the commands that a profile adds to a session are not available to `Export-PSSession`. To export commands from a profile, use an `Invoke-Command` command to run the profile in the PSSession manually before exporting commands.</maml:para> <maml:para>The module that `Export-PSSession` creates might include a formatting file, even if the command does not import formatting data. If the command does not import formatting data, any formatting files that are created will not contain formatting data.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1: Export commands from a PSSession ---------</maml:title> <dev:code>$S = New-PSSession -ComputerName Server01 Export-PSSession -Session $S -OutputModule Server01</dev:code> <dev:remarks> <maml:para>The `New-PSSession` command creates a PSSession on the Server01 computer. The PSSession is stored in the `$S` variable. The `Export-PSSession` command exports the `$S` variable's commands and formatting data into the Server01 module.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 2: Export the Get and Set commands ----------</maml:title> <dev:code>$S = New-PSSession -ConnectionUri https://exchange.microsoft.com/mailbox -Credential exchangeadmin01@hotmail.com -Authentication Negotiate Export-PSSession -Session $S -Module exch* -CommandName Get-*, Set-* -FormatTypeName * -OutputModule $PSHOME\Modules\Exchange -Encoding ASCII</dev:code> <dev:remarks> <maml:para>These commands export the `Get` and `Set` commands from a Microsoft Exchange Server snap-in on a remote computer to an Exchange module in the `$PSHOME\Modules` directory on the local computer. Placing the module in the `$PSHOME\Modules` directory makes it accessible to all users of the computer.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 3: Export commands from a remote computer ------</maml:title> <dev:code>$S = New-PSSession -ComputerName Server01 -Credential Server01\User01 Export-PSSession -Session $S -OutputModule TestCmdlets -Type Cmdlet -CommandName *test* -FormatTypeName * Remove-PSSession $S Import-Module TestCmdlets Get-Help Test* Test-Files</dev:code> <dev:remarks> <maml:para>The `New-PSSession` command creates a PSSession on the Server01 computer and saves it in the `$S` variable. The `Export-PSSession` command exports the cmdlets whose names begin with Test from the PSSession in `$S` to the TestCmdlets module on the local computer.</maml:para> <maml:para>The `Remove-PSSession` cmdlet deletes the PSSession in `$S` from the current session. This command shows that the PSSession need not be active to use the commands that were imported from the session. The `Import-Module` cmdlet adds the cmdlets in the TestCmdlets module to the current session. The command can be run in any session at any time.</maml:para> <maml:para>The `Get-Help` cmdlet gets help for cmdlets whose names begin with Test. After the commands in a module are added to the current session, you can use the `Get-Help` and `Get-Command` cmdlets to learn about the imported commands. The `Test-Files` cmdlet was exported from the Server01 computer and added to the session. The `Test-Files` cmdlet runs in a remote session on the computer from which the command was imported. PowerShell creates a session from information that is stored in the TestCmdlets module.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title> Example 4: Export and clobber commands in the current session </maml:title> <dev:code>Export-PSSession -Session $S -AllowClobber -OutputModule AllCommands</dev:code> <dev:remarks> <maml:para>This `Export-PSSession` command exports all commands and all formatting data from the PSSession in the `$S` variable into the current session. The AllowClobber parameter includes commands with the same names as commands in the current session.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 5: Export commands from a closed PSSession ------</maml:title> <dev:code>$Options = New-PSSessionOption -NoMachineProfile $S = New-PSSession -ComputerName Server01 -SessionOption $Options Export-PSSession -Session $S -OutputModule Server01 Remove-PSSession $S New-PSSession -ComputerName Server01 -SessionOption $Options Import-Module Server01</dev:code> <dev:remarks> <maml:para>The `New-PSSessionOption` cmdlet creates a PSSessionOption object, and it saves the object in the `$Options` variable. The `New-PSSession` command creates a PSSession on the Server01 computer. The SessionOption parameter uses the object stored in `$Options`. The session is stored in the `$S` variable.</maml:para> <maml:para>The `Export-PSSession` cmdlet exports commands from the PSSession in `$S` to the Server01 module. The `Remove-PSSession` cmdlet deletes the PSSession in the `$S` variable.</maml:para> <maml:para>The `New-PSSession` cmdlet creates a new PSSession that connects to the Server01 computer. The SessionOption parameter uses the object stored in `$Options`. The `Import-Module` cmdlet imports the commands from the Server01 module. The commands in the module are run in the PSSession on the Server01 computer.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/export-pssession?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Command_Precedence</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_PSSessions</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_PSSnapins</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Remote_Requirements</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Import-Module</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Import-PSSession</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Invoke-Command</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-PSSession</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-PSSessionOption</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-PSSession</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Format-Custom</command:name> <command:verb>Format</command:verb> <command:noun>Custom</command:noun> <maml:description> <maml:para>Uses a customized view to format the output.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Format-Custom` cmdlet formats the output of a command as defined in an alternate view. `Format-Custom` is designed to display views that are not just tables or just lists. You can use the views defined in the *format.PS1XML files in the PowerShell directory, or you can create your own views in new PS1XML files and use the Update-FormatData cmdlet to add them to PowerShell.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Format-Custom</maml:name> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the object properties that appear in the display and the order in which they appear. Wildcards are permitted.</maml:para> <maml:para>If you omit this parameter, the properties that appear in the display depend on the object being displayed. The parameter name ("Property") is optional. You cannot use the Property and View parameters in the same command.</maml:para> <maml:para>The value of the Property parameter can be a new calculated property. To create a calculated property, use a hash table. Valid keys are:</maml:para> <maml:para>- Expression <string> or <script block></maml:para> <maml:para>- Depth <int32></maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Depth</maml:name> <maml:Description> <maml:para>Specifies the number of columns in the display.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisplayError</maml:name> <maml:Description> <maml:para>Displays errors at the command line. This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a `Format-Custom` command, and the expressions do not appear to be working.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Expand</maml:name> <maml:Description> <maml:para>Formats the collection object, as well as the objects in the collection. This parameter is designed to format objects that support the ICollection (System.Collections) interface. The default value is EnumOnly .</maml:para> <maml:para>Valid values are:</maml:para> <maml:para>- EnumOnly: Displays the properties of the objects in the collection.</maml:para> <maml:para>- CoreOnly: Displays the properties of the collection object.</maml:para> <maml:para>- Both: Displays the properties of the collection object and the properties of objects in the collection.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">CoreOnly</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">EnumOnly</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Both</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>EnumOnly</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Directs the cmdlet to display all of the error information. Use with the DisplayError or ShowError parameters. By default, when an error object is written to the error or display streams, only some of the error information is displayed.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>GroupBy</maml:name> <maml:Description> <maml:para>Formats the output in groups based on a shared property or value. Enter an expression or a property of the output.</maml:para> <maml:para>The value of the GroupBy parameter can be a new calculated property. To create a calculated, property, use a hash table. Valid keys are:</maml:para> <maml:para>- Name (or Label) <string></maml:para> <maml:para>- Expression <string> or <script block></maml:para> <maml:para>- FormatString <string></maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be formatted. Enter a variable that contains the objects or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ShowError</maml:name> <maml:Description> <maml:para>Sends errors through the pipeline. This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a `Format-Custom` command, and the expressions do not appear to be working.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>View</maml:name> <maml:Description> <maml:para>Specifies the name of an alternate format or "view." If you omit this parameter, `Format-Custom` uses a default custom view. You cannot use the Property and View parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Depth</maml:name> <maml:Description> <maml:para>Specifies the number of columns in the display.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisplayError</maml:name> <maml:Description> <maml:para>Displays errors at the command line. This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a `Format-Custom` command, and the expressions do not appear to be working.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Expand</maml:name> <maml:Description> <maml:para>Formats the collection object, as well as the objects in the collection. This parameter is designed to format objects that support the ICollection (System.Collections) interface. The default value is EnumOnly .</maml:para> <maml:para>Valid values are:</maml:para> <maml:para>- EnumOnly: Displays the properties of the objects in the collection.</maml:para> <maml:para>- CoreOnly: Displays the properties of the collection object.</maml:para> <maml:para>- Both: Displays the properties of the collection object and the properties of objects in the collection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>EnumOnly</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Directs the cmdlet to display all of the error information. Use with the DisplayError or ShowError parameters. By default, when an error object is written to the error or display streams, only some of the error information is displayed.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>GroupBy</maml:name> <maml:Description> <maml:para>Formats the output in groups based on a shared property or value. Enter an expression or a property of the output.</maml:para> <maml:para>The value of the GroupBy parameter can be a new calculated property. To create a calculated, property, use a hash table. Valid keys are:</maml:para> <maml:para>- Name (or Label) <string></maml:para> <maml:para>- Expression <string> or <script block></maml:para> <maml:para>- FormatString <string></maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be formatted. Enter a variable that contains the objects or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the object properties that appear in the display and the order in which they appear. Wildcards are permitted.</maml:para> <maml:para>If you omit this parameter, the properties that appear in the display depend on the object being displayed. The parameter name ("Property") is optional. You cannot use the Property and View parameters in the same command.</maml:para> <maml:para>The value of the Property parameter can be a new calculated property. To create a calculated property, use a hash table. Valid keys are:</maml:para> <maml:para>- Expression <string> or <script block></maml:para> <maml:para>- Depth <int32></maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ShowError</maml:name> <maml:Description> <maml:para>Sends errors through the pipeline. This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a `Format-Custom` command, and the expressions do not appear to be working.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>View</maml:name> <maml:Description> <maml:para>Specifies the name of an alternate format or "view." If you omit this parameter, `Format-Custom` uses a default custom view. You cannot use the Property and View parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe any object to Format-Custom.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.Internal.Format</maml:name> </dev:type> <maml:description> <maml:para>`Format-Custom` returns the format objects that represent the display.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>`Format-Custom` is designed to display views that are not just tables or just lists. To display an alternate table view, use `Format-Table`. To display an alternate list view, use `Format-List`.</maml:para> <maml:para>You can also refer to `Format-Custom` by its built-in alias, "fc". For more information, see about_Aliases (../Microsoft.PowerShell.Core/About/about_Aliases.md).</maml:para> <maml:para>The GroupBy parameter assumes that the objects are sorted. Before using `Format-Custom` to group the objects, use `Sort-Object` to sort them.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1: Format output with a custom view ---------</maml:title> <dev:code>Get-Command Start-Transcript | Format-Custom -View MyView</dev:code> <dev:remarks> <maml:para>This command formats information about the `Start-Transcript` cmdlet in the format defined by the MyView view, a custom view created by the user. To run this command successfully, you must first create a new PS1XML file, define the MyView view, and then use the `Update-FormatData` command to add the PS1XML file to PowerShell.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 2: Format output with the default view --------</maml:title> <dev:code>Get-Process Winlogon | Format-Custom</dev:code> <dev:remarks> <maml:para>This command formats information about the Winlogon process in an alternate customized view. Because the command does not use the View parameter, `Format-Custom` uses a default custom view to format the data.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 3: Troubleshooting format errors -----------</maml:title> <dev:code>PC /> Get-Date | Format-Custom DayOfWeek,{ $_ / $null } -DisplayError class DateTime { DayOfWeek = Friday $_ / $null = #ERR } PC /> Get-Date | Format-Custom DayOfWeek,{ $_ / $null } -ShowError class DateTime { DayOfWeek = Friday $_ / $null = } Failed to evaluate expression " $_ / $null ". + CategoryInfo : InvalidArgument: (12/21/2018 8:01:04 AM:PSObject) [], RuntimeException + FullyQualifiedErrorId : PSPropertyExpressionError</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/format-custom?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-Hex</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-List</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-Table</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-Wide</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Process</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Format-List</command:name> <command:verb>Format</command:verb> <command:noun>List</command:noun> <maml:description> <maml:para>Formats the output as a list of properties in which each property appears on a new line.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Format-List` cmdlet formats the output of a command as a list of properties in which each property is displayed on a separate line. You can use `Format-List` to format and display all or selected properties of an object as a list (format-list *).</maml:para> <maml:para>Because more space is available for each item in a list than in a table, PowerShell displays more properties of the object in the list, and the property values are less likely to be truncated.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Format-List</maml:name> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the object properties that appear in the display and the order in which they appear. Wildcards are permitted.</maml:para> <maml:para>If you omit this parameter, the properties that appear in the display depend on the object being displayed. The parameter name "Property" is optional. You cannot use the Property and View parameters in the same command.</maml:para> <maml:para>The value of the Property parameter can be a new calculated property. To create a calculated property, use a hash table. Valid keys are:</maml:para> <maml:para>- Name (or Label) <string></maml:para> <maml:para>- Expression <string> or <script block></maml:para> <maml:para>- FormatString <string></maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisplayError</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet displays errors at the command line. This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a `Format-List` command, and the expressions do not appear to be working.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Expand</maml:name> <maml:Description> <maml:para>Specifies the formatted collection object, as well as the objects in the collection. This parameter is designed to format objects that support the ICollection (System.Collections) interface. The default value is EnumOnly. The acceptable values for this parameter are:</maml:para> <maml:para>- EnumOnly. Displays the properties of the objects in the collection.</maml:para> <maml:para>- CoreOnly. Displays the properties of the collection object.</maml:para> <maml:para>- Both. Displays the properties of the collection object and the properties of objects in the</maml:para> <maml:para> collection.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">CoreOnly</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">EnumOnly</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Both</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet displays all of the error information. Use with the DisplayError or ShowError parameter. By default, when an error object is written to the error or display streams, only some of the error information is displayed.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>GroupBy</maml:name> <maml:Description> <maml:para>Specifies the output in groups based on a shared property or value. Enter an expression or a property of the output.</maml:para> <maml:para>The value of the GroupBy parameter can be a new calculated property. To create a calculated, property, use a hash table. Valid keys are:</maml:para> <maml:para>- Name (or Label) <string></maml:para> <maml:para>- Expression <string> or <script block></maml:para> <maml:para>- FormatString <string></maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be formatted. Enter a variable that contains the objects or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ShowError</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends errors through the pipeline. This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a `Format-List` command, and the expressions do not appear to be working.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>View</maml:name> <maml:Description> <maml:para>Specifies the name of an alternate list format or view. You cannot use the Property and View parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisplayError</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet displays errors at the command line. This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a `Format-List` command, and the expressions do not appear to be working.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Expand</maml:name> <maml:Description> <maml:para>Specifies the formatted collection object, as well as the objects in the collection. This parameter is designed to format objects that support the ICollection (System.Collections) interface. The default value is EnumOnly. The acceptable values for this parameter are:</maml:para> <maml:para>- EnumOnly. Displays the properties of the objects in the collection.</maml:para> <maml:para>- CoreOnly. Displays the properties of the collection object.</maml:para> <maml:para>- Both. Displays the properties of the collection object and the properties of objects in the</maml:para> <maml:para> collection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet displays all of the error information. Use with the DisplayError or ShowError parameter. By default, when an error object is written to the error or display streams, only some of the error information is displayed.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>GroupBy</maml:name> <maml:Description> <maml:para>Specifies the output in groups based on a shared property or value. Enter an expression or a property of the output.</maml:para> <maml:para>The value of the GroupBy parameter can be a new calculated property. To create a calculated, property, use a hash table. Valid keys are:</maml:para> <maml:para>- Name (or Label) <string></maml:para> <maml:para>- Expression <string> or <script block></maml:para> <maml:para>- FormatString <string></maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be formatted. Enter a variable that contains the objects or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the object properties that appear in the display and the order in which they appear. Wildcards are permitted.</maml:para> <maml:para>If you omit this parameter, the properties that appear in the display depend on the object being displayed. The parameter name "Property" is optional. You cannot use the Property and View parameters in the same command.</maml:para> <maml:para>The value of the Property parameter can be a new calculated property. To create a calculated property, use a hash table. Valid keys are:</maml:para> <maml:para>- Name (or Label) <string></maml:para> <maml:para>- Expression <string> or <script block></maml:para> <maml:para>- FormatString <string></maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ShowError</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends errors through the pipeline. This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a `Format-List` command, and the expressions do not appear to be working.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>View</maml:name> <maml:Description> <maml:para>Specifies the name of an alternate list format or view. You cannot use the Property and View parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe any object to `Format-List`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.Internal.Format</maml:name> </dev:type> <maml:description> <maml:para>`Format-List` returns the format objects that represent the list.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>You can also refer to Format-List by its built-in alias, FL. For more information, see about_Aliases (../Microsoft.PowerShell.Core/About/about_Aliases.md).</maml:para> <maml:para>The format cmdlets, such as `Format-List`, arrange the data to be displayed but do not display it. The data is displayed by the output features of PowerShell and by the cmdlets that contain the Out verb (the Out cmdlets), such as `Out-Host` or `Out-File`.</maml:para> <maml:para>If you do not use a format cmdlet, PowerShell applies that default format for each object that it displays.</maml:para> <maml:para>The GroupBy parameter assumes that the objects are sorted. Use Sort-Object before using `Format-List` to group the objects.</maml:para> <maml:para>The View parameter lets you specify an alternate format for the table. You can use the views defined in the `*.format.PS1XML` files in the PowerShell directory, or you can create your own views in new PS1XML files and use the Update-FormatData cmdlet to include them in PowerShell.</maml:para> <maml:para>The alternate view for the View parameter must use the list format, otherwise, the command fails. If the alternate view is a table, use `Format-Table`. If the alternate view is not a list or a table, use `Format-Custom`.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------- Example 1: Format computer services -------------</maml:title> <dev:code>Get-Service | Format-List</dev:code> <dev:remarks> <maml:para>This command formats information about services on the computer as a list. By default, the services are formatted as a table. The `Get-Service` cmdlet gets objects representing the services on the computer. The pipeline operator (|) passes the results through the pipeline to `Format-List`. Then, the `Format-List` command formats the service information in a list and sends it to the default output cmdlet for display.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------------- Example 2: Format PS1XML files ----------------</maml:title> <dev:code>$A = Get-ChildItem $pshome\*.ps1xml Format-List -InputObject $A</dev:code> <dev:remarks> <maml:para>The first command gets the objects representing the files and stores them in the `$A` variable.</maml:para> <maml:para>The second command uses `Format-List` to format information about objects stored in `$A`. This command uses the InputObject parameter to pass the variable to `Format-List`, which then sends the formatted output to the default output cmdlet for display.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 3: Format process properties by name ---------</maml:title> <dev:code>Get-Process | Format-List -Property name, basepriority, priorityclass</dev:code> <dev:remarks> <maml:para>It uses the `Get-Process` cmdlet to get an object representing each process. The pipeline operator (|) passes the process objects through the pipeline to `Format-List`. `Format-List` formats the processes as a list of the specified properties. The Property parameter name is optional, so you can omit it.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 4: Format all properties for a process --------</maml:title> <dev:code>Get-Process winlogon | Format-List -Property *</dev:code> <dev:remarks> <maml:para>It uses the Get-Process cmdlet to get an object representing the Winlogon process. The pipeline operator (|) passes the Winlogon process object through the pipeline to `Format-List`. The command uses the Property parameter to specify the properties and the * to indicate all properties. Because the name of the Property parameter is optional, you can omit it and type the command as `Format-List *`. `Format-List` automatically sends the results to the default output cmdlet for display.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 5: Troubleshooting format errors -----------</maml:title> <dev:code>PC /> Get-Date | Format-List DayOfWeek,{ $_ / $null } -DisplayError DayOfWeek : Friday $_ / $null : #ERR PC /> Get-Date | Format-List DayOfWeek,{ $_ / $null } -ShowError DayOfWeek : Friday $_ / $null : Failed to evaluate expression " $_ / $null ". + CategoryInfo : InvalidArgument: (12/21/2018 7:59:23 AM:PSObject) [], RuntimeException + FullyQualifiedErrorId : PSPropertyExpressionError</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/format-list?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-Custom</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-Hex</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-Table</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-Wide</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Format-Table</command:name> <command:verb>Format</command:verb> <command:noun>Table</command:noun> <maml:description> <maml:para>Formats the output as a table.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Format-Table` cmdlet formats the output of a command as a table with the selected properties of the object in each column. The object type determines the default layout and properties that are displayed in each column. You can use the Property parameter to select the properties that you want to display.</maml:para> <maml:para>PowerShell uses default formatters to define how object types are displayed. You can use `.ps1xml` files to create custom views that display an output table with specified properties. After a custom view is created, use the View parameter to display the table with your custom view. For more information about views, see about_Format.ps1xml (../Microsoft.PowerShell.Core/About/about_Format.ps1xml.md).</maml:para> <maml:para>You can use a hash table to add calculated properties to an object before displaying it and to specify the column headings in the table. To add a calculated property, use the Property or GroupBy parameter. For more information about hash tables, see about_Hash_Tables (../Microsoft.PowerShell.Core/About/about_Hash_Tables.md).</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Format-Table</maml:name> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the object properties that appear in the display and the order in which they appear. Type one or more property names, separated by commas, or use a hash table to display a calculated property. Wildcards are permitted.</maml:para> <maml:para>If you omit this parameter, the properties that appear in the display depend on the first object's properties. For example, if the first object has PropertyA and PropertyB but subsequent objects have PropertyA , PropertyB , and PropertyC , then only the PropertyA and PropertyB headers will display.</maml:para> <maml:para>The Property parameter is optional. You can't use the Property and View parameters in the same command.</maml:para> <maml:para>The value of the Property parameter can be a new calculated property. To create a calculated property, use a hash table. The valid keys are as follows:</maml:para> <maml:para>- Name (or Label) = `<string>`</maml:para> <maml:para>- Expression = `<string>` or `<script block>`</maml:para> <maml:para>- FormatString = `<string>`</maml:para> <maml:para>- Width = `<int32>`</maml:para> <maml:para>- Alignment = value can be Left, Center, or Right</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AutoSize</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet adjusts the column size and number of columns based on the width of the data. By default, the column size and number are determined by the view.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisplayError</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet displays errors on the command line. This parameter can be used as a debugging aid when you're formatting expressions in a `Format-Table` command and need to troubleshoot the expressions.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Expand</maml:name> <maml:Description> <maml:para>Specifies the format of the collection object and the objects in the collection. This parameter is designed to format objects that support the ICollection (/dotnet/api/system.collections.icollection)( System.Collections (/dotnet/api/system.collections))interface. The default value is EnumOnly . The acceptable values for this parameter are as follows:</maml:para> <maml:para>- EnumOnly : Displays the properties of the objects in the collection. - CoreOnly : Displays the properties of the collection object. - Both : Displays the properties of the collection object and the properties of objects in the collection.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">CoreOnly</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">EnumOnly</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Both</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet directs the cmdlet to display all the error information. Use with the DisplayError or ShowError parameter. By default, when an error object is written to the error or display streams, only some of the error information is displayed.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>GroupBy</maml:name> <maml:Description> <maml:para>Specifies sorted output in separate tables based on a property value. For example, you can use GroupBy to list services in separate tables based on their status.</maml:para> <maml:para>Enter an expression or a property. The GroupBy parameter expects that the objects are sorted. Use the `Sort-Object` cmdlet before using `Format-Table` to group the objects.</maml:para> <maml:para>The value of the GroupBy parameter can be a new calculated property. To create a calculated, property, use a hash table. The valid keys are as follows:</maml:para> <maml:para>- Name (or Label) = `<string>`</maml:para> <maml:para>- Expression = `<string>` or `<script block>`</maml:para> <maml:para>- FormatString = `<string>`</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>HideTableHeaders</maml:name> <maml:Description> <maml:para>Omits the column headings from the table.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to format. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>RepeatHeader</maml:name> <maml:Description> <maml:para>Repeats displaying the header of a table after every screen full. The repeated header is useful when the output is piped to a pager such as `less` or `more` or paging with a screen reader.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ShowError</maml:name> <maml:Description> <maml:para>This parameter sends errors through the pipeline. This parameter can be used as a debugging aid when you're formatting expressions in a `Format-Table` command and need to troubleshoot the expressions.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>View</maml:name> <maml:Description> <maml:para>In PowerShell 5.1 and earlier versions, the default views are defined in `*.format.ps1xml` files stored in `$PSHOME`.</maml:para> <maml:para>The View parameter lets you specify an alternate format or custom view for the table. You can use the default PowerShell views or create custom views. For more information about how to create a custom view, see about_Format.ps1xml (../Microsoft.PowerShell.Core/About/about_Format.ps1xml.md).</maml:para> <maml:para>The alternate and custom views for the View parameter must use the table format, otherwise, `Format-Table` fails. If the alternate view is a list, use the `Format-List` cmdlet. If the alternate view isn't a list or a table, use the `Format-Custom` cmdlet.</maml:para> <maml:para>You can't use the Property and View parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Wrap</maml:name> <maml:Description> <maml:para>Displays text that exceeds the column width on the next line. By default, text that exceeds the column width is truncated.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AutoSize</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet adjusts the column size and number of columns based on the width of the data. By default, the column size and number are determined by the view.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisplayError</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet displays errors on the command line. This parameter can be used as a debugging aid when you're formatting expressions in a `Format-Table` command and need to troubleshoot the expressions.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Expand</maml:name> <maml:Description> <maml:para>Specifies the format of the collection object and the objects in the collection. This parameter is designed to format objects that support the ICollection (/dotnet/api/system.collections.icollection)( System.Collections (/dotnet/api/system.collections))interface. The default value is EnumOnly . The acceptable values for this parameter are as follows:</maml:para> <maml:para>- EnumOnly : Displays the properties of the objects in the collection. - CoreOnly : Displays the properties of the collection object. - Both : Displays the properties of the collection object and the properties of objects in the collection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet directs the cmdlet to display all the error information. Use with the DisplayError or ShowError parameter. By default, when an error object is written to the error or display streams, only some of the error information is displayed.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>GroupBy</maml:name> <maml:Description> <maml:para>Specifies sorted output in separate tables based on a property value. For example, you can use GroupBy to list services in separate tables based on their status.</maml:para> <maml:para>Enter an expression or a property. The GroupBy parameter expects that the objects are sorted. Use the `Sort-Object` cmdlet before using `Format-Table` to group the objects.</maml:para> <maml:para>The value of the GroupBy parameter can be a new calculated property. To create a calculated, property, use a hash table. The valid keys are as follows:</maml:para> <maml:para>- Name (or Label) = `<string>`</maml:para> <maml:para>- Expression = `<string>` or `<script block>`</maml:para> <maml:para>- FormatString = `<string>`</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>HideTableHeaders</maml:name> <maml:Description> <maml:para>Omits the column headings from the table.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to format. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the object properties that appear in the display and the order in which they appear. Type one or more property names, separated by commas, or use a hash table to display a calculated property. Wildcards are permitted.</maml:para> <maml:para>If you omit this parameter, the properties that appear in the display depend on the first object's properties. For example, if the first object has PropertyA and PropertyB but subsequent objects have PropertyA , PropertyB , and PropertyC , then only the PropertyA and PropertyB headers will display.</maml:para> <maml:para>The Property parameter is optional. You can't use the Property and View parameters in the same command.</maml:para> <maml:para>The value of the Property parameter can be a new calculated property. To create a calculated property, use a hash table. The valid keys are as follows:</maml:para> <maml:para>- Name (or Label) = `<string>`</maml:para> <maml:para>- Expression = `<string>` or `<script block>`</maml:para> <maml:para>- FormatString = `<string>`</maml:para> <maml:para>- Width = `<int32>`</maml:para> <maml:para>- Alignment = value can be Left, Center, or Right</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>RepeatHeader</maml:name> <maml:Description> <maml:para>Repeats displaying the header of a table after every screen full. The repeated header is useful when the output is piped to a pager such as `less` or `more` or paging with a screen reader.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ShowError</maml:name> <maml:Description> <maml:para>This parameter sends errors through the pipeline. This parameter can be used as a debugging aid when you're formatting expressions in a `Format-Table` command and need to troubleshoot the expressions.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>View</maml:name> <maml:Description> <maml:para>In PowerShell 5.1 and earlier versions, the default views are defined in `*.format.ps1xml` files stored in `$PSHOME`.</maml:para> <maml:para>The View parameter lets you specify an alternate format or custom view for the table. You can use the default PowerShell views or create custom views. For more information about how to create a custom view, see about_Format.ps1xml (../Microsoft.PowerShell.Core/About/about_Format.ps1xml.md).</maml:para> <maml:para>The alternate and custom views for the View parameter must use the table format, otherwise, `Format-Table` fails. If the alternate view is a list, use the `Format-List` cmdlet. If the alternate view isn't a list or a table, use the `Format-Custom` cmdlet.</maml:para> <maml:para>You can't use the Property and View parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Wrap</maml:name> <maml:Description> <maml:para>Displays text that exceeds the column width on the next line. By default, text that exceeds the column width is truncated.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can send any object down the pipeline to `Format-Table`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.Internal.Format</maml:name> </dev:type> <maml:description> <maml:para>`Format-Table` returns format objects that represent the table.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------- Example 1: Format PowerShell host --------------</maml:title> <dev:code>Get-Host | Format-Table -AutoSize</dev:code> <dev:remarks> <maml:para>The `Get-Host` cmdlet gets System.Management.Automation.Internal.Host.InternalHost objects that represent the host. The objects are sent down the pipeline to `Format-Table` and displayed in a table. The AutoSize parameter adjusts the column widths to minimize truncation.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 2: Format processes by BasePriority ---------</maml:title> <dev:code>Get-Process | Sort-Object -Property BasePriority | Format-Table -GroupBy BasePriority -Wrap</dev:code> <dev:remarks> <maml:para>The `Get-Process` cmdlet gets objects that represent each process on the computer and sends them down the pipeline to `Sort-Object`. The objects are sorted in the order of their BasePriority property.</maml:para> <maml:para>The sorted objects are sent down the pipeline to `Format-Table`. The GroupBy parameter arranges the process data into groups based on their BasePriority property's value. The Wrap parameter ensures that data isn't truncated.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 3: Format processes by start date ----------</maml:title> <dev:code>Get-Process | Sort-Object StartTime | Format-Table -View StartTime</dev:code> <dev:remarks> <maml:para>`Get-Process` gets the System.Diagnostics.Process objects that represent the processes running on the computer. The objects are sent down the pipeline to `Sort-Object`, and are sorted based on the StartTime property.</maml:para> <maml:para>The sorted objects are sent down the pipeline to `Format-Table`. The View parameter specifies the StartTime view that's defined in the PowerShell `DotNetTypes.format.ps1xml` file for System.Diagnostics.Process objects. The StartTime view converts each processes start time to a short date and then groups the processes by the start date.</maml:para> <maml:para>The `DotNetTypes.format.ps1xml` file contains a Priority view for processes. You can create your own `format.ps1xml` files with customized views.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 4: Use a custom view for table output --------</maml:title> <dev:code>Get-ChildItem -Path C:\Test | Format-Table -View mygciview Directory: C:\Test Mode LastWriteTime CreationTime Length Name ---- ------------- ------------ ------ ---- d----- 11/4/2019 15:54 9/24/2019 15:54 Archives d----- 8/27/2019 14:22 8/27/2019 14:22 Drawings d----- 10/23/2019 09:38 2/25/2019 09:38 Files -a---- 11/7/2019 11:07 11/7/2019 11:07 11345 Alias.txt -a---- 2/27/2019 15:15 2/27/2019 15:15 258 alias_out.txt -a---- 2/27/2019 15:16 2/27/2019 15:16 258 alias_out2.txt</dev:code> <dev:remarks> <maml:para>`Get-ChildItem` gets the contents of the current directory, `C:\Test`. The System.IO.DirectoryInfo and System.IO.FileInfo objects are sent down the pipeline. `Format-Table` uses the View parameter to specify the custom view mygciview that includes the CreationTime column.</maml:para> <maml:para>The default `Format-Table` output for `Get-ChildItem` doesn't include the CreationTime column.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 5: Use properties for table output ----------</maml:title> <dev:code>Get-Service | Format-Table -Property Name, DependentServices</dev:code> <dev:remarks> <maml:para>`Get-Service` gets all the services on the computer and sends the System.ServiceProcess.ServiceController objects down the pipeline. `Format-Table` uses the Property parameter to specify that the Name and DependentServices properties are displayed in the table. Name and DependentServices are two of the object type's properties. To view all the properties: `Get-Service | Get-Member -MemberType Properties`.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 6: Format a process and calculate its running time --</maml:title> <dev:code>Get-Process notepad | Format-Table ProcessName, @{Label="TotalRunningTime"; Expression={(Get-Date) - $_.StartTime}} ProcessName TotalRunningTime ----------- ---------------- notepad 03:20:00.2751767 notepad 00:00:16.7710520</dev:code> <dev:remarks> <maml:para>`Get-Process` gets all the local computer's notepad processes and sends the objects down the pipeline. `Format-Table` displays a table with two columns: ProcessName , a `Get-Process` property, and TotalRunningTime , a calculated property.</maml:para> <maml:para>The TotalRunningTime property is specified by a hash table with two keys, Label and Expression . The Label key specifies the property name. The Expression key specifies the calculation. The expression gets the StartTime property of each process object and subtracts it from the result of a `Get-Date` command, which gets the current date and time.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------- Example 7: Format Notepad processes -------------</maml:title> <dev:code>$Processes = Get-CimInstance -Class win32_process -Filter "name='notepad.exe'" $Processes | Format-Table ProcessName, @{ Label = "Total Running Time"; Expression={(Get-Date) - $_.CreationDate}} ProcessName Total Running Time ----------- ------------------ notepad.exe 03:39:39.6260693 notepad.exe 00:19:56.1376922</dev:code> <dev:remarks> <maml:para>`Get-CimInstance` gets instances of the WMI Win32_Process class that describes all the local computer's processes named notepad.exe . The process objects are stored in the `$Processes` variable.</maml:para> <maml:para>The process objects in the `$Processes` variable are sent down the pipeline to `Format-Table`, which displays the ProcessName property and a new calculated property, Total Running Time .</maml:para> <maml:para>The command assigns the name of the new calculated property, Total Running Time , to the Label key. The Expression key's script block calculates how long the process has been running by subtracting the processes creation date from the current date. The `Get-Date` cmdlet gets the current date. The creation date is subtracted from the current date. The result is the value of Total Running Time .</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 8: Troubleshooting format errors -----------</maml:title> <dev:code>Get-Date | Format-Table DayOfWeek,{ $_ / $null } -DisplayError DayOfWeek $_ / $null --------- ------------ Wednesday #ERR Get-Date | Format-Table DayOfWeek,{ $_ / $null } -ShowError DayOfWeek $_ / $null --------- ------------ Wednesday Failed to evaluate expression " $_ / $null ". + CategoryInfo : InvalidArgument: (11/27/2019 12:53:41:PSObject) [], RuntimeException + FullyQualifiedErrorId : mshExpressionError</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/format-table?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Format.ps1xml</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Hash_Tables</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Export-FormatData</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-Custom</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-Hex</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-List</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-Wide</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-FormatData</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Member</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-CimInstance</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Update-FormatData</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Format-Wide</command:name> <command:verb>Format</command:verb> <command:noun>Wide</command:noun> <maml:description> <maml:para>Formats objects as a wide table that displays only one property of each object.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Format-Wide` cmdlet formats objects as a wide table that displays only one property of each object. You can use the Property parameter to determine which property is displayed.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Format-Wide</maml:name> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the object properties that appear in the display and the order in which they appear. Wildcards are permitted.</maml:para> <maml:para>If you omit this parameter, the properties that appear in the display depend on the object being displayed. The parameter name "Property" is optional. You cannot use the Property and View parameters in the same command.</maml:para> <maml:para>The value of the Property parameter can be a new calculated property. To create a calculated property, use a hash table. Valid keys are:</maml:para> <maml:para>- Expression <string> or <script block></maml:para> <maml:para>- FormatString <string></maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AutoSize</maml:name> <maml:Description> <maml:para>Adjusts the column size and number of columns based on the width of the data. By default, the column size and number are determined by the view. You cannot use the AutoSize and Column parameters in the same command.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Column</maml:name> <maml:Description> <maml:para>Specifies the number of columns in the display. You cannot use the AutoSize and Column parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisplayError</maml:name> <maml:Description> <maml:para>Displays errors at the command line. This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a `Format-Wide` command, and the expressions do not appear to be working.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Expand</maml:name> <maml:Description> <maml:para>Formats the collection object, as well as the objects in the collection. This parameter is designed to format objects that support the ICollection (System.Collections) interface. The default value is EnumOnly .</maml:para> <maml:para>Valid values are:</maml:para> <maml:para>- EnumOnly: Displays the properties of the objects in the collection.</maml:para> <maml:para>- CoreOnly: Displays the properties of the collection object.</maml:para> <maml:para>- Both: Displays the properties of the collection object and the properties of objects in the</maml:para> <maml:para> collection.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">CoreOnly</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">EnumOnly</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Both</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>EnumOnly</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet overrides restrictions that prevent the command from succeeding, just so the changes do not compromise security. For example, Force will override the read-only attribute or create directories to complete a file path, but it will not attempt to change file permissions.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>GroupBy</maml:name> <maml:Description> <maml:para>Formats the output in groups based on a shared property or value. Enter an expression or a property of the output.</maml:para> <maml:para>The value of the GroupBy parameter can be a new calculated property. To create a calculated, property, use a hash table. The acceptable values for this parameter are:</maml:para> <maml:para>- Name (or Label) <string></maml:para> <maml:para>- Expression <string> or <script block></maml:para> <maml:para>- FormatString <string></maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to format. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ShowError</maml:name> <maml:Description> <maml:para>Sends errors through the pipeline. This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a `Format-Wide` command, and the expressions do not appear to be working.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>View</maml:name> <maml:Description> <maml:para>Specifies the name of an alternate table format or view. You cannot use the Property and View parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AutoSize</maml:name> <maml:Description> <maml:para>Adjusts the column size and number of columns based on the width of the data. By default, the column size and number are determined by the view. You cannot use the AutoSize and Column parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Column</maml:name> <maml:Description> <maml:para>Specifies the number of columns in the display. You cannot use the AutoSize and Column parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisplayError</maml:name> <maml:Description> <maml:para>Displays errors at the command line. This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a `Format-Wide` command, and the expressions do not appear to be working.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Expand</maml:name> <maml:Description> <maml:para>Formats the collection object, as well as the objects in the collection. This parameter is designed to format objects that support the ICollection (System.Collections) interface. The default value is EnumOnly .</maml:para> <maml:para>Valid values are:</maml:para> <maml:para>- EnumOnly: Displays the properties of the objects in the collection.</maml:para> <maml:para>- CoreOnly: Displays the properties of the collection object.</maml:para> <maml:para>- Both: Displays the properties of the collection object and the properties of objects in the</maml:para> <maml:para> collection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>EnumOnly</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet overrides restrictions that prevent the command from succeeding, just so the changes do not compromise security. For example, Force will override the read-only attribute or create directories to complete a file path, but it will not attempt to change file permissions.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>GroupBy</maml:name> <maml:Description> <maml:para>Formats the output in groups based on a shared property or value. Enter an expression or a property of the output.</maml:para> <maml:para>The value of the GroupBy parameter can be a new calculated property. To create a calculated, property, use a hash table. The acceptable values for this parameter are:</maml:para> <maml:para>- Name (or Label) <string></maml:para> <maml:para>- Expression <string> or <script block></maml:para> <maml:para>- FormatString <string></maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to format. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the object properties that appear in the display and the order in which they appear. Wildcards are permitted.</maml:para> <maml:para>If you omit this parameter, the properties that appear in the display depend on the object being displayed. The parameter name "Property" is optional. You cannot use the Property and View parameters in the same command.</maml:para> <maml:para>The value of the Property parameter can be a new calculated property. To create a calculated property, use a hash table. Valid keys are:</maml:para> <maml:para>- Expression <string> or <script block></maml:para> <maml:para>- FormatString <string></maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ShowError</maml:name> <maml:Description> <maml:para>Sends errors through the pipeline. This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a `Format-Wide` command, and the expressions do not appear to be working.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>View</maml:name> <maml:Description> <maml:para>Specifies the name of an alternate table format or view. You cannot use the Property and View parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe any object to `Format-Wide`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.Internal.Format</maml:name> </dev:type> <maml:description> <maml:para>`Format-Wide` returns format objects that represent the table.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>You can also refer to `Format-Wide` by its built-in alias, `fw`. For more information, see about_Aliases (../Microsoft.PowerShell.Core/About/about_Aliases.md).</maml:para> <maml:para>The GroupBy parameter assumes that the objects are sorted. Use `Sort-Object` before using `Format-Custom` to group the objects.</maml:para> <maml:para>The View parameter lets you specify an alternate format for the table. You can use the views defined in the `*.format.PS1XML` files in the PowerShell directory or you can create your own views in new PS1XML files and use the `Update-FormatData` cmdlet to include them in PowerShell.</maml:para> <maml:para>The alternate view for the View parameter must use table format; if it does not, the command fails. If the alternate view is a list, use `Format-List`. If the alternate view is neither a list nor a table, use Format-Custom.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-- Example 1: Format names of files in the current directory --</maml:title> <dev:code>Get-ChildItem | Format-Wide -Column 3</dev:code> <dev:remarks> <maml:para>The Get-ChildItem cmdlet gets objects representing each file in the directory. The pipeline operator (|) passes the file objects through the pipeline to `Format-Wide`, which formats them for output. The Column parameter specifies the number of columns.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 2: Format names of registry keys -----------</maml:title> <dev:code>Get-ChildItem HKCU:\software\microsoft | Format-Wide -Property pschildname -AutoSize</dev:code> <dev:remarks> <maml:para>The Get-ChildItem cmdlet gets objects representing the keys. The path is specified as HKCU:, one of the drives exposed by the PowerShell Registry provider, followed by the key path. The pipeline operator (|) passes the registry key objects through the pipeline to `Format-Wide`, which formats them for output. The Property parameter specifies the name of the property, and the AutoSize parameter adjusts the columns for readability.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 3: Troubleshooting format errors -----------</maml:title> <dev:code>PS /> Get-Date | Format-Wide { $_ / $null } -DisplayError #ERR PS /> Get-Date | Format-Wide { $_ / $null } -ShowError Failed to evaluate expression " $_ / $null ". + CategoryInfo : InvalidArgument: (12/21/2018 8:18:01 AM:PSObject) [], RuntimeException + FullyQualifiedErrorId : PSPropertyExpressionError</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/format-wide?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-Custom</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-Hex</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-List</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-Table</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-Alias</command:name> <command:verb>Get</command:verb> <command:noun>Alias</command:noun> <maml:description> <maml:para>Gets the aliases for the current session.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Get-Alias cmdlet gets the aliases in the current session. This includes built-in aliases, aliases that you have set or imported, and aliases that you have added to your PowerShell profile.</maml:para> <maml:para>By default, Get-Alias takes an alias and returns the command name. When you use the Definition parameter, Get-Alias takes a command name and returns its aliases.</maml:para> <maml:para>Beginning in Windows PowerShell 3.0, Get-Alias displays non-hyphenated alias names in an `<alias> -> <definition>` format to make it even easier to find the information that you need.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-Alias</maml:name> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Definition</maml:name> <maml:Description> <maml:para>Gets the aliases for the specified item. Enter the name of a cmdlet, function, script, file, or executable file.</maml:para> <maml:para>This parameter is called Definition , because it searches for the item name in the Definition property of the alias object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Exclude</maml:name> <maml:Description> <maml:para>Omits the specified items. The value of this parameter qualifies the Name and Definition parameters. Enter a name, a definition, or a pattern, such as "s*". Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope for which this cmdlet gets aliases. The acceptable values for this parameter are:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Script</maml:para> <maml:para>- A number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent)</maml:para> <maml:para></maml:para> <maml:para>Local is the default. For more information, see about_Scopes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Local</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-Alias</maml:name> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the aliases that this cmdlet gets. Wildcards are permitted. By default, `Get-Alias` retrieves all aliases defined for the current session. The parameter name Name is optional. You can also pipe alias names to `Get-Alias`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>All aliases</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Exclude</maml:name> <maml:Description> <maml:para>Omits the specified items. The value of this parameter qualifies the Name and Definition parameters. Enter a name, a definition, or a pattern, such as "s*". Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope for which this cmdlet gets aliases. The acceptable values for this parameter are:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Script</maml:para> <maml:para>- A number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent)</maml:para> <maml:para></maml:para> <maml:para>Local is the default. For more information, see about_Scopes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Local</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Definition</maml:name> <maml:Description> <maml:para>Gets the aliases for the specified item. Enter the name of a cmdlet, function, script, file, or executable file.</maml:para> <maml:para>This parameter is called Definition , because it searches for the item name in the Definition property of the alias object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Exclude</maml:name> <maml:Description> <maml:para>Omits the specified items. The value of this parameter qualifies the Name and Definition parameters. Enter a name, a definition, or a pattern, such as "s*". Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the aliases that this cmdlet gets. Wildcards are permitted. By default, `Get-Alias` retrieves all aliases defined for the current session. The parameter name Name is optional. You can also pipe alias names to `Get-Alias`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>All aliases</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope for which this cmdlet gets aliases. The acceptable values for this parameter are:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Script</maml:para> <maml:para>- A number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent)</maml:para> <maml:para></maml:para> <maml:para>Local is the default. For more information, see about_Scopes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Local</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe alias names to Get-Alias .</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.AliasInfo</maml:name> </dev:type> <maml:description> <maml:para>Get-Alias returns an object that represents each alias. Get-Alias returns the same object for every alias, but PowerShell uses an arrow-based format to display the names of non-hyphenated aliases.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>- To create a new alias, use Set-Alias or New-Alias. To delete an alias, use Remove-Item.</maml:para> <maml:para>- The arrow-based alias name format is not used for aliases that include a hyphen. These are likely to be preferred substitute names for cmdlets and functions, instead of typical abbreviations or nicknames.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------ Example 1: Get all aliases in the current session ------</maml:title> <dev:code>PS C:\> Get-Alias CommandType Name ----------- ---- Alias % -> ForEach-Object Alias ? -> Where-Object Alias ac -> Add-Content Alias asnp -> Add-PSSnapin Alias cat -> Get-Content Alias cd -> Set-Location Alias chdir -> Set-Location Alias clc -> Clear-Content Alias clear -> Clear-Host Alias clhy -> Clear-History ...</dev:code> <dev:remarks> <maml:para>This command gets all aliases in the current session.</maml:para> <maml:para>The output shows the `<alias> -> <definition>` format that was introduced in Windows PowerShell 3.0. This format is used only for aliases that do not include hyphens, because aliases with hyphens are typically preferred names for cmdlets and functions, rather than nicknames.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------------- Example 2: Get aliases by name ----------------</maml:title> <dev:code>Get-Alias -Name gp*, sp* -Exclude *ps</dev:code> <dev:remarks> <maml:para>This command gets all aliases that begin with gp or sp, except for aliases that end with ps.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------- Example 3: Get aliases for a cmdlet -------------</maml:title> <dev:code>Get-Alias -Definition Get-ChildItem</dev:code> <dev:remarks> <maml:para>This command gets the aliases for the Get-ChildItem cmdlet.</maml:para> <maml:para>By default, the Get-Alias cmdlet gets the item name when you know the alias. The Definition parameter gets the alias when you know the item name.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------------- Example 4: Get aliases by property --------------</maml:title> <dev:code>Get-Alias | Where-Object {$_.Options -Match "ReadOnly"}</dev:code> <dev:remarks> <maml:para>This command gets all aliases in which the value of the Options property is ReadOnly. This command provides a quick way to find the aliases that are built into PowerShell, because they have the ReadOnly option.</maml:para> <maml:para>Options is just one property of the AliasInfo objects that Get-Alias gets. To find all properties and methods of AliasInfo objects, type `Get-Alias | get-member`.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title> Example 5: Get aliases by name and filter by beginning letter </maml:title> <dev:code>Get-Alias -Definition "*-PSSession" -Exclude e* -Scope Global</dev:code> <dev:remarks> <maml:para>This example gets aliases for commands that have names that end in "-PSSession", except for those that begin with "e".</maml:para> <maml:para>The command uses the Scope parameter to apply the command in the global scope. This is useful in scripts when you want to get the aliases in the session.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-alias?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Export-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Import-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Alias Provider</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Aliases</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-Culture</command:name> <command:verb>Get</command:verb> <command:noun>Culture</command:noun> <maml:description> <maml:para>Gets the current culture set in the operating system.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Get-Culture cmdlet gets information about the current culture settings. This includes information about the current language settings on the system, such as the keyboard layout, and the display format of items such as numbers, currency, and dates.</maml:para> <maml:para>You can also use the Get-UICulture cmdlet, which gets the current user interface culture on the system, and the Set-Culture (https://go.microsoft.com/fwlink/?LinkID=242258)cmdlet in the International module. The user-interface (UI) culture determines which text strings are used for user interface elements, such as menus and messages.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-Culture</maml:name> </command:syntaxItem> </command:syntax> <command:parameters /> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe input to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Globalization.CultureInfo</maml:name> </dev:type> <maml:description> <maml:para>Get-Culture returns an object that represents the current culture.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>* You can also use the $PsCulture and $PsUICulture variables. The $PsCulture variable stores the name of the current culture and the $PsUICulture variable stores the name of the current UI culture.</maml:para> <maml:para>*</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------------- Example 1: Get culture settings ---------------</maml:title> <dev:code>PS C:\> Get-Culture</dev:code> <dev:remarks> <maml:para>This command displays information about the regional settings on the computer.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 2: Format the properties of a culture object -----</maml:title> <dev:code>PS C:\> $C = Get-Culture PS C:\> $C | Format-List -Property * Parent : en LCID : 1033 KeyboardLayoutId : 1033 Name : en-US IetfLanguageTag : en-US DisplayName : English (United States) NativeName : English (United States) EnglishName : English (United States) TwoLetterISOLanguageName : en ThreeLetterISOLanguageName : eng ThreeLetterWindowsLanguageName : ENU CompareInfo : CompareInfo - 1033 TextInfo : TextInfo - 1033 IsNeutralCulture : False CultureTypes : SpecificCultures, InstalledWin32Cultures, FrameworkCultures NumberFormat : System.Globalization.NumberFormatInfo DateTimeFormat : System.Globalization.DateTimeFormatInfo Calendar : System.Globalization.GregorianCalendar OptionalCalendars : {System.Globalization.GregorianCalendar, System.Globalization.GregorianCalendar} UseUserOverride : True IsReadOnly : False PS C:\> $C.Calendar MinSupportedDateTime : 1/1/0001 12:00:00 AM MaxSupportedDateTime : 12/31/9999 11:59:59 PM AlgorithmType : SolarCalendar CalendarType : Localized Eras : {1} TwoDigitYearMax : 2029 IsReadOnly : False PS C:\> $C.DateTimeFormat AMDesignator : AM Calendar : System.Globalization.GregorianCalendar DateSeparator : / FirstDayOfWeek : Sunday CalendarWeekRule : FirstDay FullDateTimePattern : dddd, MMMM dd, yyyy h:mm:ss tt LongDatePattern : dddd, MMMM dd, yyyy LongTimePattern : h:mm:ss tt MonthDayPattern : MMMM dd PMDesignator : PM RFC1123Pattern : ddd, dd MMM yyyy HH':'mm':'ss 'GMT' ShortDatePattern : M/d/yyyy ShortTimePattern : h:mm tt SortableDateTimePattern : yyyy'-'MM'-'dd'T'HH':'mm':'ss TimeSeparator : : UniversalSortableDateTimePattern : yyyy'-'MM'-'dd HH':'mm':'ss'Z' YearMonthPattern : MMMM, yyyy AbbreviatedDayNames : {Sun, Mon, Tue, Wed...} ShortestDayNames : {Su, Mo, Tu, We...} DayNames : {Sunday, Monday, Tuesday, Wednesday...} AbbreviatedMonthNames : {Jan, Feb, Mar, Apr...} MonthNames : {January, February, March, April...} IsReadOnly : False NativeCalendarName : Gregorian Calendar AbbreviatedMonthGenitiveNames : {Jan, Feb, Mar, Apr...} MonthGenitiveNames : {January, February, March, April...} PS C:\> $C.DateTimeFormat.FirstDayOfWeek Sunday</dev:code> <dev:remarks> <maml:para>This example demonstrates the vast amount of data in the culture object. It shows how to display the properties and sub-properties of the object.</maml:para> <maml:para>The first command uses the Get-Culture cmdlet to get the current culture settings on the computer. It stores the resulting culture object in the $C variable.</maml:para> <maml:para>The second command displays all of the properties of the culture object. It uses a pipeline operator (|) to send the culture object in $C to the Format-List cmdlet. It uses the Property parameter to display all (*) properties of the object. This command can be abbreviated as `$c | fl *`.</maml:para> <maml:para>The remaining commands explore the properties of the culture object by using dot notation to display the values of the object properties. You can use this notation to display the value of any property of the object.</maml:para> <maml:para>The third command uses dot notation to display the value of the Calendar property of the culture object.</maml:para> <maml:para>The fourth command uses dot notation to display the value of the DataTimeFormat property of the culture object.</maml:para> <maml:para>Many object properties have properties. The fifth command uses dot notation to display the value of the FirstDayOfWeek property of the DateTimeFormat property.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-culture?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-Culture</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-UICulture</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-Date</command:name> <command:verb>Get</command:verb> <command:noun>Date</command:noun> <maml:description> <maml:para>Gets the current date and time.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Get-Date` cmdlet gets a DateTime object that represents the current date or a date that you specify. `Get-Date` can format the date and time in several .NET and UNIX formats. You can use `Get-Date` to generate a date or time character string, and then send the string to other cmdlets or programs.</maml:para> <maml:para>`Get-Date` uses the computer's culture settings to determine how the output is formatted. To view your computer's settings, use `(Get-Culture).DateTimeFormat`.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-Date</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="LastWriteTime"> <maml:name>Date</maml:name> <maml:Description> <maml:para>Specifies a date and time. Time is optional and if not specified, returns 00:00:00.</maml:para> <maml:para>Enter the date and time in a format that is standard for the system locale.</maml:para> <maml:para>For example, in US English:</maml:para> <maml:para>`Get-Date -Date "6/25/2019 12:30:22"` returns Tuesday, June 25, 2019 12:30:22</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.DateTime</command:parameterValue> <dev:type> <maml:name>System.DateTime</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Day</maml:name> <maml:Description> <maml:para>Specifies the day of the month that is displayed. Enter a value from 1 to 31.</maml:para> <maml:para>If the specified value is greater than the number of days in a month, PowerShell adds the number of days to the month. For example, `Get-Date -Month 2 -Day 31` displays March 3 , not February 31 .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisplayHint</maml:name> <maml:Description> <maml:para>Determines which elements of the date and time are displayed.</maml:para> <maml:para>The accepted values are as follows:</maml:para> <maml:para>- Date : displays only the date - Time : displays only the time - DateTime : displays the date and time</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Date</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Time</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DateTime</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.DisplayHintType</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.DisplayHintType</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Format</maml:name> <maml:Description> <maml:para>Displays the date and time in the Microsoft .NET Framework format indicated by the format specifier. The Format parameter outputs a String object.</maml:para> <maml:para>For a list of available .NET format specifiers, see Custom date and time format strings (/dotnet/standard/base-types/custom-date-and-time-format-strings?view=netframework-4.8).</maml:para> <maml:para>When the Format parameter is used, `Get-Date` only gets the DateTime object's properties necessary to display the date. As a result, some of the properties and methods of DateTime objects might not be available.</maml:para> <maml:para>Starting in PowerShell 5.0, you can use the following additional formats as values for the Format parameter.</maml:para> <maml:para>- FileDate . A file or path-friendly representation of the current date in local time. The format is `yyyyMMdd` (case-sensitive, using a 4-digit year, 2-digit month, and 2-digit day). For example: 20190627.</maml:para> <maml:para>- FileDateUniversal . A file or path-friendly representation of the current date in universal time (UTC). The format is `yyyyMMddZ` (case-sensitive, using a 4-digit year, 2-digit month, 2-digit day, and the letter `Z` as the UTC indicator). For example: 20190627Z.</maml:para> <maml:para>- FileDateTime . A file or path-friendly representation of the current date and time in local time, in 24-hour format. The format is `yyyyMMddTHHmmssffff` (case-sensitive, using a 4-digit year, 2-digit month, 2-digit day, the letter `T` as a time separator, 2-digit hour, 2-digit minute, 2-digit second, and 4-digit millisecond). For example: 20190627T0840107271.</maml:para> <maml:para>- FileDateTimeUniversal . A file or path-friendly representation of the current date and time in universal time (UTC), in 24-hour format. The format is `yyyyMMddTHHmmssffffZ` (case-sensitive, using a 4-digit year, 2-digit month, 2-digit day, the letter `T` as a time separator, 2-digit hour, 2-digit minute, 2-digit second, 4-digit millisecond, and the letter `Z` as the UTC indicator). For example: 20190627T1540500718Z.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Hour</maml:name> <maml:Description> <maml:para>Specifies the hour that is displayed. Enter a value from 0 to 23.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Millisecond</maml:name> <maml:Description> <maml:para>Specifies the milliseconds in the date. Enter a value from 0 to 999.</maml:para> <maml:para>This parameter was introduced in PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Minute</maml:name> <maml:Description> <maml:para>Specifies the minute that is displayed. Enter a value from 0 to 59.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Month</maml:name> <maml:Description> <maml:para>Specifies the month that is displayed. Enter a value from 1 to 12.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Second</maml:name> <maml:Description> <maml:para>Specifies the second that is displayed. Enter a value from 0 to 59.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Year</maml:name> <maml:Description> <maml:para>Specifies the year that is displayed. Enter a value from 1 to 9999.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-Date</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="LastWriteTime"> <maml:name>Date</maml:name> <maml:Description> <maml:para>Specifies a date and time. Time is optional and if not specified, returns 00:00:00.</maml:para> <maml:para>Enter the date and time in a format that is standard for the system locale.</maml:para> <maml:para>For example, in US English:</maml:para> <maml:para>`Get-Date -Date "6/25/2019 12:30:22"` returns Tuesday, June 25, 2019 12:30:22</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.DateTime</command:parameterValue> <dev:type> <maml:name>System.DateTime</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Day</maml:name> <maml:Description> <maml:para>Specifies the day of the month that is displayed. Enter a value from 1 to 31.</maml:para> <maml:para>If the specified value is greater than the number of days in a month, PowerShell adds the number of days to the month. For example, `Get-Date -Month 2 -Day 31` displays March 3 , not February 31 .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisplayHint</maml:name> <maml:Description> <maml:para>Determines which elements of the date and time are displayed.</maml:para> <maml:para>The accepted values are as follows:</maml:para> <maml:para>- Date : displays only the date - Time : displays only the time - DateTime : displays the date and time</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Date</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Time</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DateTime</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.DisplayHintType</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.DisplayHintType</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Hour</maml:name> <maml:Description> <maml:para>Specifies the hour that is displayed. Enter a value from 0 to 23.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Millisecond</maml:name> <maml:Description> <maml:para>Specifies the milliseconds in the date. Enter a value from 0 to 999.</maml:para> <maml:para>This parameter was introduced in PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Minute</maml:name> <maml:Description> <maml:para>Specifies the minute that is displayed. Enter a value from 0 to 59.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Month</maml:name> <maml:Description> <maml:para>Specifies the month that is displayed. Enter a value from 1 to 12.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Second</maml:name> <maml:Description> <maml:para>Specifies the second that is displayed. Enter a value from 0 to 59.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UFormat</maml:name> <maml:Description> <maml:para>Displays the date and time in UNIX format. The UFormat parameter outputs a string object. UFormat specifiers are preceded by a percent sign (`%`), for example, `%m`, `%d`, and `%Y`. The Notes (#notes)section contains a table of valid UFormat specifiers .</maml:para> <maml:para>When the UFormat parameter is used, `Get-Date` only gets the DateTime object's properties necessary to display the date. As a result, some of the properties and methods of DateTime objects might not be available.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Year</maml:name> <maml:Description> <maml:para>Specifies the year that is displayed. Enter a value from 1 to 9999.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="LastWriteTime"> <maml:name>Date</maml:name> <maml:Description> <maml:para>Specifies a date and time. Time is optional and if not specified, returns 00:00:00.</maml:para> <maml:para>Enter the date and time in a format that is standard for the system locale.</maml:para> <maml:para>For example, in US English:</maml:para> <maml:para>`Get-Date -Date "6/25/2019 12:30:22"` returns Tuesday, June 25, 2019 12:30:22</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.DateTime</command:parameterValue> <dev:type> <maml:name>System.DateTime</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Day</maml:name> <maml:Description> <maml:para>Specifies the day of the month that is displayed. Enter a value from 1 to 31.</maml:para> <maml:para>If the specified value is greater than the number of days in a month, PowerShell adds the number of days to the month. For example, `Get-Date -Month 2 -Day 31` displays March 3 , not February 31 .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisplayHint</maml:name> <maml:Description> <maml:para>Determines which elements of the date and time are displayed.</maml:para> <maml:para>The accepted values are as follows:</maml:para> <maml:para>- Date : displays only the date - Time : displays only the time - DateTime : displays the date and time</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.DisplayHintType</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.DisplayHintType</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Format</maml:name> <maml:Description> <maml:para>Displays the date and time in the Microsoft .NET Framework format indicated by the format specifier. The Format parameter outputs a String object.</maml:para> <maml:para>For a list of available .NET format specifiers, see Custom date and time format strings (/dotnet/standard/base-types/custom-date-and-time-format-strings?view=netframework-4.8).</maml:para> <maml:para>When the Format parameter is used, `Get-Date` only gets the DateTime object's properties necessary to display the date. As a result, some of the properties and methods of DateTime objects might not be available.</maml:para> <maml:para>Starting in PowerShell 5.0, you can use the following additional formats as values for the Format parameter.</maml:para> <maml:para>- FileDate . A file or path-friendly representation of the current date in local time. The format is `yyyyMMdd` (case-sensitive, using a 4-digit year, 2-digit month, and 2-digit day). For example: 20190627.</maml:para> <maml:para>- FileDateUniversal . A file or path-friendly representation of the current date in universal time (UTC). The format is `yyyyMMddZ` (case-sensitive, using a 4-digit year, 2-digit month, 2-digit day, and the letter `Z` as the UTC indicator). For example: 20190627Z.</maml:para> <maml:para>- FileDateTime . A file or path-friendly representation of the current date and time in local time, in 24-hour format. The format is `yyyyMMddTHHmmssffff` (case-sensitive, using a 4-digit year, 2-digit month, 2-digit day, the letter `T` as a time separator, 2-digit hour, 2-digit minute, 2-digit second, and 4-digit millisecond). For example: 20190627T0840107271.</maml:para> <maml:para>- FileDateTimeUniversal . A file or path-friendly representation of the current date and time in universal time (UTC), in 24-hour format. The format is `yyyyMMddTHHmmssffffZ` (case-sensitive, using a 4-digit year, 2-digit month, 2-digit day, the letter `T` as a time separator, 2-digit hour, 2-digit minute, 2-digit second, 4-digit millisecond, and the letter `Z` as the UTC indicator). For example: 20190627T1540500718Z.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Hour</maml:name> <maml:Description> <maml:para>Specifies the hour that is displayed. Enter a value from 0 to 23.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Millisecond</maml:name> <maml:Description> <maml:para>Specifies the milliseconds in the date. Enter a value from 0 to 999.</maml:para> <maml:para>This parameter was introduced in PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Minute</maml:name> <maml:Description> <maml:para>Specifies the minute that is displayed. Enter a value from 0 to 59.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Month</maml:name> <maml:Description> <maml:para>Specifies the month that is displayed. Enter a value from 1 to 12.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Second</maml:name> <maml:Description> <maml:para>Specifies the second that is displayed. Enter a value from 0 to 59.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UFormat</maml:name> <maml:Description> <maml:para>Displays the date and time in UNIX format. The UFormat parameter outputs a string object. UFormat specifiers are preceded by a percent sign (`%`), for example, `%m`, `%d`, and `%Y`. The Notes (#notes)section contains a table of valid UFormat specifiers .</maml:para> <maml:para>When the UFormat parameter is used, `Get-Date` only gets the DateTime object's properties necessary to display the date. As a result, some of the properties and methods of DateTime objects might not be available.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Year</maml:name> <maml:Description> <maml:para>Specifies the year that is displayed. Enter a value from 1 to 9999.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>Pipeline input</maml:name> </dev:type> <maml:description> <maml:para>`Get-Date` accepts pipeline input. For example, `Get-ChildItem | Get-Date`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.DateTime or System.String</maml:name> </dev:type> <maml:description> <maml:para>`Get-Date` returns a DateTime object except when the Format and UFormat parameters are used. The Format or UFormat parameters return String objects.</maml:para> <maml:para>When a DateTime object is sent down the pipeline to a cmdlet such as `Add-Content` that expects string input, PowerShell converts the object to a String object.</maml:para> <maml:para>The method `(Get-Date).ToString()` converts a DateTime object a String object.</maml:para> <maml:para>To display an object's properties and methods, send the object down the pipeline to `Get-Member`. For example, `Get-Date | Get-Member`.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>DateTime objects are in long-date and long-time formats for the system locale.</maml:para> <maml:para>The valid UFormat specifiers are displayed in the following table:</maml:para> <maml:para>| Format specifier | Meaning | Example | | ---- | ----------------------------------------------------------------------- | ------------------------ | | `%A` | Day of the week - full name | Monday | | `%a` | Day of the week - abbreviated name | Mon | | `%B` | Month name - full | January | | `%b` | Month name - abbreviated | Jan | | `%C` | Century | 20 for 2019 | | `%c` | Date and time - abbreviated | Thu Jun 27 08:44:18 2019 | | `%D` | Date in mm/dd/yy format | 06/27/19 | | `%d` | Day of the month - 2 digits | 05 | | `%e` | Day of the month - digit preceded by a space | <space>5 | | `%G` | Same as 'Y' | | | `%g` | Same as 'y' | | | `%H` | Hour in 24-hour format | 17 | | `%h` | Same as 'b' | | | `%I` | Hour in 12-hour format | 05 | | `%j` | Day of the year | 1-366 | | `%k` | Same as 'H' | | | `%l` | Same as 'I' (Upper-case I) | 05 | | `%M` | Minutes | 35 | | `%m` | Month number | 06 | | `%n` | newline character | | | `%p` | AM or PM | | | `%R` | Time in 24-hour format -no seconds | 17:45 | | `%r` | Time in 12-hour format | 09:15:36 AM | | `%S` | Seconds | 05 | | `%s` | Seconds elapsed since January 1, 1970 00:00:00 | 1150451174.95705 | | `%t` | Horizontal tab character | | | `%T` | Time in 24-hour format | 17:45:52 | | `%U` | Same as 'W' | | | `%u` | Day of the week - number | Monday = 1 | | `%V` | Week of the year | 01-53 | | `%w` | Same as 'u' | | | `%W` | Week of the year | 00-52 | | `%X` | Same as 'T' | | | `%x` | Date in standard format for locale | 06/27/19 for English-US | | `%Y` | Year in 4-digit format | 2019 | | `%y` | Year in 2-digit format | 19 | | `%Z` | Time zone offset from Universal Time Coordinate (UTC) | -07 |</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>----------- Example 1: Get the current date and time -----------</maml:title> <dev:code>Get-Date Tuesday, June 25, 2019 14:53:32</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 2: Get elements of the current date and time -----</maml:title> <dev:code>Get-Date -DisplayHint Date Tuesday, June 25, 2019</dev:code> <dev:remarks> <maml:para>`Get-Date` uses the DisplayHint parameter with the Date argument to get only the date.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title> Example 3: Get the date and time with a .NET format specifier </maml:title> <dev:code>Get-Date -Format "dddd MM/dd/yyyy HH:mm K" Tuesday 06/25/2019 16:17 -07:00</dev:code> <dev:remarks> <maml:para>`Get-Date` uses the Format parameter to specify several format specifiers.</maml:para> <maml:para>The .NET format specifiers used in this example are defined as follows:</maml:para> <maml:para>| Specifier | Definition | | --- | --- | | `dddd` | Day of the week - full name | | `MM` | Month number | | `dd` | Day of the month - 2 digits | | `yyyy` | Year in 4-digit format | | `HH:mm` | Time in 24-hour format -no seconds | | `K` | Time zone offset from Universal Time Coordinate (UTC) |</maml:para> <maml:para>For more information about .NET format specifiers, see Custom date and time format strings (/dotnet/standard/base-types/custom-date-and-time-format-strings?view=netframework-4.8).</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 4: Get the date and time with a UFormat specifier --</maml:title> <dev:code>Get-Date -UFormat "%A %m/%d/%Y %R %Z" Tuesday 06/25/2019 16:19 -07</dev:code> <dev:remarks> <maml:para>`Get-Date` uses the UFormat parameter to specify several format specifiers.</maml:para> <maml:para>The UFormat format specifiers used in this example are defined as follows:</maml:para> <maml:para>| Specifier | Definition | | --- | --- | | `%A` | Day of the week - full name | | `%m` | Month number | | `%d` | Day of the month - 2 digits | | `%Y` | Year in 4-digit format | | `%R` | Time in 24-hour format -no seconds | | `%Z` | Time zone offset from Universal Time Coordinate (UTC) |</maml:para> <maml:para>For a list of valid UFormat format specifiers, see the Notes (#notes)section.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 5: Get a date's day of the year -----------</maml:title> <dev:code>(Get-Date -Year 2020 -Month 12 -Day 31).DayOfYear 366</dev:code> <dev:remarks> <maml:para>`Get-Date` uses three parameters to specify the date: Year , Month , and Day . The command is wrapped with parentheses so that the result is evaluated by the DayofYear property.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 6: Check if a date is adjusted for daylight savings time</maml:title> <dev:code>$DST = Get-Date $DST.IsDaylightSavingTime() True</dev:code> <dev:remarks> <maml:para>A variable, `$DST` stores the result of `Get-Date`. `$DST` uses the IsDaylightSavingTime method to test if the date is adjusted for daylight savings time.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 7: Convert the current time to UTC time -------</maml:title> <dev:code>Get-Date -UFormat "%A %B/%d/%Y %T %Z" $Time = Get-Date $Time.ToUniversalTime() Wednesday June/26/2019 10:45:26 -07 Wednesday, June 26, 2019 17:45:26</dev:code> <dev:remarks> <maml:para>`Get-Date` uses the UFormat parameter with format specifiers to display the current system date and time. The format specifier %Z represents the UTC offset of -07 .</maml:para> <maml:para>The `$Time` variable stores the current system date and time. `$Time` uses the ToUniversalTime() method to convert the time based on the computer's UTC offset.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------------- Example 8: Create a timestamp ----------------</maml:title> <dev:code>$timestamp = Get-Date -Format o | ForEach-Object { $_ -replace ":", "." } New-Item -Path C:\Test\$timestamp -Type Directory Directory: C:\Test Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 6/27/2019 07:59 2019-06-27T07.59.24.4603750-07.00</dev:code> <dev:remarks> <maml:para>The `$timestamp` variable stores the results of a `Get-Date` command. `Get-Date` uses the Format parameter with the format specifier of lowercase `o` to create a timestamp String object. The object is sent down the pipeline to `ForEach-Object`. A ScriptBlock contains the `$_` variable that represents the current pipeline object. The timestamp string is delimited by colons that are replaced by periods.</maml:para> <maml:para>`New-Item` uses the Path parameter to specify the location for a new directory. The path includes the `$timestamp` variable as the directory name. The Type parameter specifies that a directory is created.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-date?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ForEach-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Culture</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Member</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Item</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-TimeSpan</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-Date</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-Event</command:name> <command:verb>Get</command:verb> <command:noun>Event</command:noun> <maml:description> <maml:para>Gets the events in the event queue.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Get-Event cmdlet gets events in the Windows PowerShell event queue for the current session. You can get all events or use the EventIdentifier or SourceIdentifier parameter to specify the events.</maml:para> <maml:para>When an event occurs, it is added to the event queue. The event queue includes events for which you have registered, events created by using the New-Event cmdlet, and the event that is raised when Windows PowerShell exits. You can use Get-Event or Wait-Event to get the events.</maml:para> <maml:para>This cmdlet does not get events from the Event Viewer logs. To get those events, use Get-WinEvent or Get-EventLog.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-Event</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="Id"> <maml:name>EventIdentifier</maml:name> <maml:Description> <maml:para>Specifies the event identifiers for which this cmdlet gets events.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-Event</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>SourceIdentifier</maml:name> <maml:Description> <maml:para>Specifies source identifiers for which this cmdlet gets events. The default is all events in the event queue. Wildcards are not permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="Id"> <maml:name>EventIdentifier</maml:name> <maml:Description> <maml:para>Specifies the event identifiers for which this cmdlet gets events.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>SourceIdentifier</maml:name> <maml:Description> <maml:para>Specifies source identifiers for which this cmdlet gets events. The default is all events in the event queue. Wildcards are not permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe input to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.PSEventArgs</maml:name> </dev:type> <maml:description> <maml:para>Get-Event returns a PSEventArgs object for each event. To see a description of this object, type `Get-Help Get-Event -Full` and see the Notes section of the help topic.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>* Events, event subscriptions, and the event queue exist only in the current session. If you close the current session, the event queue is discarded and the event subscription is canceled.</maml:para> <maml:para> The Get-Event cmdlet returns a PSEventArgs object ( System.Management.Automation.PSEventArgs ) with the following properties:</maml:para> <maml:para> - ComputerName. The name of the computer on which the event occurred. This property value is populated only when the event is forwarded from a remote computer.</maml:para> <maml:para> - RunspaceId. A GUID that uniquely identifies the session in which the event occurred. This property value is populated only when the event is forwarded from a remote computer.</maml:para> <maml:para> - EventIdentifier. An integer (Int32) that uniquely identifies the event notification in the current session.</maml:para> <maml:para> - Sender. The object that generated the event. In the value of the Action parameter, the $Sender automatic variable contains the sender object.</maml:para> <maml:para> - SourceEventArgs. The first parameter that derives from EventArgs, if it exists. For example, in a timer elapsed event in which the signature has the form Object sender, Timers.ElapsedEventArgs e, the SourceEventArgs property would contain the Timers.ElapsedEventArgs. In the value of the Action parameter, the $EventArgs automatic variable contains this value.</maml:para> <maml:para> - SourceArgs. All parameters of the original event signature. For a standard event signature, $Args[0] represents the sender, and $Args[1] represents the SourceEventArgs. In the value of the Action parameter, the $Args automatic variable contains this value.</maml:para> <maml:para> - SourceIdentifier. A string that identifies the event subscription. In the value of the Action parameter, the SourceIdentifier property of the $Event automatic variable contains this value.</maml:para> <maml:para> - TimeGenerated. A DateTime object that represents the time at which the event was generated. In the value of the Action parameter, the TimeGenerated property of the $Event automatic variable contains this value.</maml:para> <maml:para> --MessageData. Data associated with the event subscription. Users specify this data when they register an event. In the value of the Action parameter, the MessageData property of the $Event automatic variable contains this value.</maml:para> <maml:para>*</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------------ Example 1: Get all events ------------------</maml:title> <dev:code>PS C:\> Get-Event</dev:code> <dev:remarks> <maml:para>This command gets all events in the event queue.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 2: Get events by source identifier ----------</maml:title> <dev:code>PS C:\> Get-Event -SourceIdentifier "PowerShell.ProcessCreated"</dev:code> <dev:remarks> <maml:para>This command gets events in which the value of the SourceIdentifier property is PowerShell.ProcessCreated.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 3: Get an event based on the time it was generated --</maml:title> <dev:code>PS C:\> $Events = Get-Event PS C:\> $Events[0] | Format-List -Property * ComputerName : RunspaceId : c2153740-256d-46c0-a57c-b805917d1b7b EventIdentifier : 1 Sender : System.Management.ManagementEventWatcher SourceEventArgs : System.Management.EventArrivedEventArgs SourceArgs : {System.Management.ManagementEventWatcher, System.Management.EventArrivedEventArgs} SourceIdentifier : ProcessStarted TimeGenerated : 11/13/2008 12:09:32 PM MessageData : PS C:\> Get-Event | Where {$_.TimeGenerated -ge "11/13/2008 12:15:00 PM"} ComputerName : RunspaceId : c2153740-256d-46c0-a57c-b8059325d1a0 EventIdentifier : 1 Sender : System.Management.ManagementEventWatcher SourceEventArgs : System.Management.EventArrivedEventArgs SourceArgs : {System.Management.ManagementEventWatcher, System.Management.EventArrivedEventArgs} SourceIdentifier : ProcessStarted TimeGenerated : 11/13/2008 12:15:00 PM MessageData :</dev:code> <dev:remarks> <maml:para>This example shows how to get events by using properties other than SourceIdentifier.</maml:para> <maml:para>The first command gets all events in the event queue and saves them in the $Events variable.</maml:para> <maml:para>The second command uses array notation to get the first (0-index) event in the array in the $Events variable. The command uses a pipeline operator (|) to send the event to the Format-List command, which displays all properties of the event in a list. This allows you to examine the properties of the event object.</maml:para> <maml:para>The third command shows how to use the Where-Object cmdlet to get an event based on the time that it was generated.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 4: Get an event by its identifier ----------</maml:title> <dev:code>PS C:\> Get-Event -EventIdentifier 2</dev:code> <dev:remarks> <maml:para>This command gets the event with an event identifier of 2.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-event?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-EngineEvent</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-ObjectEvent</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Unregister-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Wait-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-EventSubscriber</command:name> <command:verb>Get</command:verb> <command:noun>EventSubscriber</command:noun> <maml:description> <maml:para>Gets the event subscribers in the current session.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Get-EventSubscriber cmdlet gets the event subscribers in the current session.</maml:para> <maml:para>When you subscribe to an event by using a Register event cmdlet, an event subscriber is added to your Windows PowerShell session, and the events to which you subscribed are added to your event queue whenever they are raised. To cancel an event subscription, delete the event subscriber by using the Unregister-Event cmdlet.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-EventSubscriber</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>SourceIdentifier</maml:name> <maml:Description> <maml:para>Specifies the SourceIdentifier property value that gets only the event subscribers. By default, Get-EventSubscriber gets all event subscribers in the session. Wildcards are not permitted. This parameter is case-sensitive.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet gets all event subscribers, including subscribers for events that are hidden by using the SupportEvent parameter of Register-ObjectEvent, Register-WmiEvent, and Register-EngineEvent.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-EventSubscriber</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="Id"> <maml:name>SubscriptionId</maml:name> <maml:Description> <maml:para>Specifies the subscription identifier that this cmdlet gets. By default, Get-EventSubscriber gets all event subscribers in the session.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet gets all event subscribers, including subscribers for events that are hidden by using the SupportEvent parameter of Register-ObjectEvent, Register-WmiEvent, and Register-EngineEvent.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet gets all event subscribers, including subscribers for events that are hidden by using the SupportEvent parameter of Register-ObjectEvent, Register-WmiEvent, and Register-EngineEvent.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>SourceIdentifier</maml:name> <maml:Description> <maml:para>Specifies the SourceIdentifier property value that gets only the event subscribers. By default, Get-EventSubscriber gets all event subscribers in the session. Wildcards are not permitted. This parameter is case-sensitive.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="Id"> <maml:name>SubscriptionId</maml:name> <maml:Description> <maml:para>Specifies the subscription identifier that this cmdlet gets. By default, Get-EventSubscriber gets all event subscribers in the session.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe input to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.PSEventSubscriber</maml:name> </dev:type> <maml:description> <maml:para>Get-EventSubscriber returns an object that represents each event subscriber.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>The New-Event cmdlet, which creates a custom event, does not generate a subscriber. Therefore, the Get-EventSubscriber cmdlet will not find a subscriber object for these events. However, if you use the Register-EngineEvent cmdlet to subscribe to a custom event (in order to forward the event or to specify an action), Get-EventSubscriber will find the subscriber that Register-EngineEvent * generates.</maml:para> <maml:para> Events, event subscriptions, and the event queue exist only in the current session. If you close the current session, the event queue is discarded and the event subscription is canceled.</maml:para> <maml:para>*</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>---- Example 1: Get the event subscriber for a timer event ----</maml:title> <dev:code>PS C:\> $Timer = New-Object Timers.Timer PS C:\> $Timer | Get-Member -Type Event PS C:\> Register-ObjectEvent -InputObject $Timer -EventName Elapsed -SourceIdentifier Timer.Elapsed PS C:\> Get-EventSubscriber PS C:\> $Timer = New-Object Timers.Timer PS C:\> $Timer | Get-Member -Type Event TypeName: System.Timers.Timer Name MemberType Definition ---- ---------- ---------- Disposed Event System.EventHandler Disposed(System.Object, System.EventArgs) Elapsed Event System.Timers.ElapsedEventHandler Elapsed(System.Object, System.Timers.ElapsedEventArgs) PS C:\> Register-ObjectEvent -InputObject $Timer -EventName Elapsed -SourceIdentifier Timer.Elapsed PS C:\> Get-EventSubscriber SubscriptionId : 4 SourceObject : System.Timers.Timer EventName : Elapsed SourceIdentifier : Timer.Elapsed Action : HandlerDelegate : SupportEvent : False ForwardEvent : False</dev:code> <dev:remarks> <maml:para>This example uses a Get-EventSubscriber command to get the event subscriber for a timer event.</maml:para> <maml:para>The first command uses the New-Object cmdlet to create an instance of a timer object. It saves the new timer object in the $Timer variable.</maml:para> <maml:para>The second command uses the Get-Member cmdlet to display the events that are available for timer objects. The command uses the Type parameter of the Get-Member cmdlet with a value of Event.</maml:para> <maml:para>The third command uses the Register-ObjectEvent cmdlet to register for the Elapsed event on the timer object.</maml:para> <maml:para>The fourth command uses the Get-EventSubscriber cmdlet to get the event subscriber for the Elapsed event.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 2: Use the dynamic module in PSEventJob in the Action property of the event subscriber</maml:title> <dev:code>PS C:\> $Timer = New-Object Timers.Timer PS C:\> $Timer.Interval = 500 PS C:\> Register-ObjectEvent -InputObject $Timer -EventName Elapsed -SourceIdentifier Timer.Random -Action { $Random = Get-Random -Min 0 -Max 100 } Id Name State HasMoreData Location Command -- ---- ----- ----------- -------- ------- 3 Timer.Random NotStarted False $Random = Get-Random ... PS C:\> $Timer.Enabled = $True PS C:\> $Subscriber = Get-EventSubscriber -SourceIdentifier Timer.Random PS C:\> ($Subscriber.action).gettype().fullname System.Management.Automation.PSEventJob PS C:\> $Subscriber.action | Format-List -Property * State : Running Module : __DynamicModule_6b5cbe82-d634-41d1-ae5e-ad7fe8d57fe0 StatusMessage : HasMoreData : True Location : Command : $random = Get-Random -Min 0 -Max 100 JobStateInfo : Running Finished : System.Threading.ManualResetEvent InstanceId : 88944290-133d-4b44-8752-f901bd8012e2 Id : 1 Name : Timer.Random ChildJobs : {} ... PS C:\> & $Subscriber.action.module {$Random} 96 PS C:\> & $Subscriber.action.module {$Random} 23</dev:code> <dev:remarks> <maml:para>This example shows how to use the dynamic module in the PSEventJob object in the Action property of the event subscriber.</maml:para> <maml:para>The first command uses the New-Object cmdlet to create a timer object. The second command sets the interval of the timer to 500 (milliseconds).</maml:para> <maml:para>The third command uses the Register-ObjectEvent cmdlet to register the Elapsed event of the timer object. The command includes an action that handles the event. Whenever the timer interval elapses, an event is raised and the commands in the action run. In this case, the Get-Random cmdlet generates a random number between 0 and 100 and saves it in the $Random variable. The source identifier of the event is Timer.Random.</maml:para> <maml:para>When you use an Action parameter in a Register-ObjectEvent command, the command returns a PSEventJob object that represents the action.</maml:para> <maml:para>The fourth command enables the timer.</maml:para> <maml:para>The fifth command uses the Get-EventSubscriber cmdlet to get the event subscriber of the Timer.Random event. It saves the event subscriber object in the $Subscriber variable.</maml:para> <maml:para>The sixth command shows that the Action property of the event subscriber object contains a PSEventJob object. In fact, it contains the same PSEventJob object that the Register-ObjectEvent command returned.</maml:para> <maml:para>The seventh command uses the Format-List cmdlet to display all of the properties of the PSEventJob object in the Action property in a list. The result reveals that the PSEventJob object has a Module property that contains a dynamic script module that implements the action.</maml:para> <maml:para>The remaining commands use the call operator (&) to invoke the command in the module and display the value of the $Random variable. You can use the call operator to invoke any command in a module, including commands that are not exported. In this case, the commands show the random number that is being generated when the Elapsed event occurs.</maml:para> <maml:para>For more information about modules, see about_Modules (../Microsoft.PowerShell.Core/About/about_Modules.md).</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-eventsubscriber?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-EngineEvent</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-ObjectEvent</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Unregister-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Wait-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-FormatData</command:name> <command:verb>Get</command:verb> <command:noun>FormatData</command:noun> <maml:description> <maml:para>Gets the formatting data in the current session.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Get-FormatData` cmdlet gets the formatting data in the current session.</maml:para> <maml:para>The formatting data in the session includes formatting data from `Format.ps1xml` formatting files, such as those in the `$PSHOME` directory, formatting data for modules that you import into the session, and formatting data for commands that you import into your session by using the `Import-PSSession` cmdlet.</maml:para> <maml:para>You can use this cmdlet to examine the formatting data. Then, you can use the `Export-FormatData` cmdlet to serialize the objects, convert them to XML, and save them in `Format.ps1xml` files.</maml:para> <maml:para>For more information about formatting files in PowerShell, see about_Format.ps1xml (../Microsoft.PowerShell.Core/About/about_Format.ps1xml.md).</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-FormatData</maml:name> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>TypeName</maml:name> <maml:Description> <maml:para>Specifies the type names that this cmdlet gets for the formatting data. Enter the type names. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PowerShellVersion</maml:name> <maml:Description> <maml:para>Specify the version of PowerShell this cmdlet gets for the formatting data. Enter a two digit number separated by a period.</maml:para> <maml:para>This parameter was added in PowerShell 5.1 to improve compatibility when remoting computers running older versions of PowerShell.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Version</command:parameterValue> <dev:type> <maml:name>System.Version</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PowerShellVersion</maml:name> <maml:Description> <maml:para>Specify the version of PowerShell this cmdlet gets for the formatting data. Enter a two digit number separated by a period.</maml:para> <maml:para>This parameter was added in PowerShell 5.1 to improve compatibility when remoting computers running older versions of PowerShell.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Version</command:parameterValue> <dev:type> <maml:name>System.Version</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>TypeName</maml:name> <maml:Description> <maml:para>Specifies the type names that this cmdlet gets for the formatting data. Enter the type names. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe input to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.ExtendedTypeDefinition</maml:name> </dev:type> <maml:description> <maml:para></maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------- Example 1: Get all formatting data --------------</maml:title> <dev:code>Get-FormatData</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 2: Get formatting data by type name ---------</maml:title> <dev:code>Get-FormatData -TypeName 'System.Management.Automation.Cmd*'</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 3: Examine a formatting data object ---------</maml:title> <dev:code>$F = Get-FormatData -TypeName 'System.Management.Automation.Cmd*' $F TypeName FormatViewDefinition -------- -------------------- HelpInfoShort {help , TableControl} $F.FormatViewDefinition[0].control Headers : {System.Management.Automation.TableControlColumnHeader, System.Management.Automation.TableControlColumnHeader, System.Management.Automation.TableControlColumnHeader, System.Management.Automation.TableControlColumnHeader} Rows : {System.Management.Automation.TableControlRow} AutoSize : False HideTableHeaders : False GroupBy : OutOfBand : False $F.FormatViewDefinition[0].control.Headers Label Alignment Width ----- --------- ----- CommandType Undefined 15 Name Undefined 50 Version Undefined 10 Source Undefined 0</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 4: Get formatting data and export it ---------</maml:title> <dev:code>$A = Get-FormatData Import-Module bitstransfer $B = Get-FormatData Compare-Object $A $B InputObject SideIndicator ----------- ------------- Microsoft.BackgroundIntelligentTransfer.Management.BitsJob => Get-FormatData *bits* | Export-FormatData -FilePath c:\test\bits.format.ps1xml Get-Content c:\test\bits.format.ps1xml <?xml version="1.0" encoding="utf-8"?><Configuration><ViewDefinitions> <View><Name>Microsoft.BackgroundIntelligentTransfer.Management.BitsJob</Name> ...</dev:code> <dev:remarks> <maml:para>The first four commands use the `Get-FormatData`, `Import-Module`, and `Compare-Object` cmdlets to identify the format type that the BitsTransfer module adds to the session.</maml:para> <maml:para>The fifth command uses the `Get-FormatData` cmdlet to get the format type that the BitsTransfer module adds. It uses a pipeline operator (`|`) to send the format type object to the `Export-FormatData` cmdlet, which converts it back to XML and saves it in the specified `format.ps1xml` file.</maml:para> <maml:para>The final command shows an excerpt of the `format.ps1xml` file content.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 5: Get formatting data based on the specified version of PowerShell</maml:title> <dev:code>Get-FormatData -TypeName 'Microsoft.Powershell.Utility.FileHash' -PowerShellVersion $PSVersionTable.PSVersion TypeNames FormatViewDefinition --------- -------------------- {Microsoft.Powershell.Utility.FileHash} {Microsoft.Powershell.Utility.FileHash}</dev:code> <dev:remarks> <maml:para>> [!IMPORTANT] > To ensure that the complete type formatting information is returned, you should always include the > PowerShellVersion parameter with the appropriate version. If the parameter and value are > omitted, you may not get all the correct type information.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-formatdata?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Export-FormatData</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Update-FormatData</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-Host</command:name> <command:verb>Get</command:verb> <command:noun>Host</command:noun> <maml:description> <maml:para>Gets an object that represents the current host program.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Get-Host` cmdlet gets an object that represents the program that is hosting Windows PowerShell.</maml:para> <maml:para>The default display includes the Windows PowerShell version number and the current region and language settings that the host is using, but the host object contains a wealth of information, including detailed information about the version of Windows PowerShell that is currently running and the current culture and UI culture of Windows PowerShell. You can also use this cmdlet to customize features of the host program user interface, such as the text and background colors.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-Host</maml:name> </command:syntaxItem> </command:syntax> <command:parameters /> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe input to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.Internal.Host.InternalHost</maml:name> </dev:type> <maml:description> <maml:para>`Get-Host` returns a System.Management.Automation.Internal.Host.InternalHost object.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>The `$Host` automatic variable contains the same object that `Get-Host` returns, and you can use it in the same way. Similarly, the `$PSCulture` and `$PSUICulture` automatic variables contain the same objects that the CurrentCulture and CurrentUICulture properties of the host object contain. You can use these features interchangeably.</maml:para> <maml:para>For more information, see about_Automatic_Variables (../Microsoft.PowerShell.Core/About/about_Automatic_Variables.md).</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>- Example 1: Get information about the PowerShell console host -</maml:title> <dev:code>PS C:\> Get-Host Name : ConsoleHost Version : 2.0 InstanceId : e4e0ab54-cc5e-4261-9117-4081f20ce7a2 UI : System.Management.Automation.Internal.Host.InternalHostUserInterface CurrentCulture : en-US CurrentUICulture : en-US PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy IsRunspacePushed : False Runspace : System.Management.Automation.Runspaces.LocalRunspace</dev:code> <dev:remarks> <maml:para>This command displays information about the Windows PowerShell console, which is the current host program for Windows PowerShell in this example. It includes the name of the host, the version of Windows PowerShell that is running in the host, and current culture and UI culture.</maml:para> <maml:para>The Version, UI, CurrentCulture, CurrentUICulture, PrivateData, and Runspace properties each contain an object with very useful properties. Later examples examine these properties.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 2: Resize the PowerShell window -----------</maml:title> <dev:code>PS C:\> $H = Get-Host PS C:\> $Win = $H.UI.RawUI.WindowSize PS C:\> $Win.Height = 10 PS C:\> $Win.Width = 10 PS C:\> $H.UI.RawUI.Set_WindowSize($Win)</dev:code> <dev:remarks> <maml:para>This command resizes the Windows PowerShell window to 10 pixels by 10 pixels.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 3: Get the PowerShell version for the host ------</maml:title> <dev:code>PS C:\> (Get-Host).Version | Format-List -Property * Major : 2 Minor : 0 Build : -1 Revision : -1 MajorRevision : -1 MinorRevision : -1</dev:code> <dev:remarks> <maml:para>This command gets detailed information about the version of Windows PowerShell running in the host. You can view, but not change, these values.</maml:para> <maml:para>The Version property of `Get-Host` contains a System.Version object. This command uses a pipeline operator (|) to send the version object to the `Format-List` cmdlet. The `Format-List` command uses the Property parameter with a value of all (*) to display all of the properties and property values of the version object.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 4: Get the current culture for the host -------</maml:title> <dev:code>PS C:\> (Get-Host).CurrentCulture | Format-List -Property * Parent : en LCID : 1033 KeyboardLayoutId : 1033 Name : en-US IetfLanguageTag : en-US DisplayName : English (United States) NativeName : English (United States) EnglishName : English (United States) TwoLetterISOLanguageName : en ThreeLetterISOLanguageName : eng ThreeLetterWindowsLanguageName : ENU CompareInfo : CompareInfo - 1033 TextInfo : TextInfo - 1033 IsNeutralCulture : False CultureTypes : SpecificCultures, InstalledWin32Cultures, FrameworkCultures NumberFormat : System.Globalization.NumberFormatInfo DateTimeFormat : System.Globalization.DateTimeFormatInfo Calendar : System.Globalization.GregorianCalendar OptionalCalendars : {System.Globalization.GregorianCalendar, System.Globalization.GregorianCalendar} UseUserOverride : True IsReadOnly : False</dev:code> <dev:remarks> <maml:para>This command gets detailed information about the current culture set for Windows PowerShell running in the host. This is the same information that is returned by the `Get-Culture` cmdlet.</maml:para> <maml:para>Similarly, the CurrentUICulture property returns the same object that `Get-UICulture` returns.</maml:para> <maml:para>The CurrentCulture property of the host object contains a System.Globalization.CultureInfo object. This command uses a pipeline operator (|) to send the CultureInfo object to the `Format-List` cmdlet. The `Format-List` command uses the Property parameter with a value of all ( ) to display all of the properties and property values of the CultureInfo * object.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 5: Get the DateTimeFormat for the current culture --</maml:title> <dev:code>PS C:\> (Get-Host).CurrentCulture.DateTimeFormat | Format-List -Property * AMDesignator : AM Calendar : System.Globalization.GregorianCalendar DateSeparator : / FirstDayOfWeek : Sunday CalendarWeekRule : FirstDay FullDateTimePattern : dddd, MMMM dd, yyyy h:mm:ss tt LongDatePattern : dddd, MMMM dd, yyyy LongTimePattern : h:mm:ss tt MonthDayPattern : MMMM dd PMDesignator : PM RFC1123Pattern : ddd, dd MMM yyyy HH':'mm':'ss 'GMT' ShortDatePattern : M/d/yyyy ShortTimePattern : h:mm tt SortableDateTimePattern : yyyy'-'MM'-'dd'T'HH':'mm':'ss TimeSeparator : : UniversalSortableDateTimePattern : yyyy'-'MM'-'dd HH':'mm':'ss'Z' YearMonthPattern : MMMM, yyyy AbbreviatedDayNames : {Sun, Mon, Tue, Wed...} ShortestDayNames : {Su, Mo, Tu, We...} DayNames : {Sunday, Monday, Tuesday, Wednesday...} AbbreviatedMonthNames : {Jan, Feb, Mar, Apr...} MonthNames : {January, February, March, April...} IsReadOnly : False NativeCalendarName : Gregorian Calendar AbbreviatedMonthGenitiveNames : {Jan, Feb, Mar, Apr...} MonthGenitiveNames : {January, February, March, April...}</dev:code> <dev:remarks> <maml:para>This command returns detailed information about the DateTimeFormat of the current culture that is being used for Windows PowerShell.</maml:para> <maml:para>The CurrentCulture property of the host object contains a CultureInfo object that, in turn, has many useful properties. Among them, the DateTimeFormat property contains a DateTimeFormatInfo object with many useful properties.</maml:para> <maml:para>To find the type of an object that is stored in an object property, use the `Get-Member` cmdlet. To display the property values of the object, use the `Format-List` cmdlet.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 6: Get the RawUI property for the host --------</maml:title> <dev:code>PS C:\> (Get-Host).UI.RawUI | Format-List -Property * ForegroundColor : DarkYellow BackgroundColor : DarkBlue CursorPosition : 0,390 WindowPosition : 0,341 CursorSize : 25 BufferSize : 120,3000 WindowSize : 120,50 MaxWindowSize : 120,81 MaxPhysicalWindowSize : 182,81 KeyAvailable : False WindowTitle : Windows PowerShell 2.0 (04/11/2008 00:08:14)</dev:code> <dev:remarks> <maml:para>This command displays the properties of the RawUI property of the host object. By changing these values, you can change the appearance of the host program.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 7: Set the background color for the PowerShell console</maml:title> <dev:code>PS C:\> (Get-Host).UI.RawUI.BackgroundColor = "Black" PS C:\> cls</dev:code> <dev:remarks> <maml:para>These commands change the background color of the Windows PowerShell console to black. The cls command is an alias for the `Clear-Host` function, which clears the screen and changes the whole screen to the new color.</maml:para> <maml:para>This change is effective only in the current session. To change the background color of the console for all sessions, add the command to your Windows PowerShell profile.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 8: Set the background color for error messages ----</maml:title> <dev:code>PS C:\> $Host.PrivateData.ErrorBackgroundColor = "white"</dev:code> <dev:remarks> <maml:para>This command changes the background color of error messages to white.</maml:para> <maml:para>This command uses the `$Host` automatic variable, which contains the host object for the current host program. `Get-Host` returns the same object that `$Host` contains, so you can use them interchangeably.</maml:para> <maml:para>This command uses the PrivateData property of `$Host` as its ErrorBackgroundColor property. To see all of the properties of the object in the `$Host`.PrivateData property, type `$host.privatedata | format-list *`.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-host?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Clear-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Read-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-Member</command:name> <command:verb>Get</command:verb> <command:noun>Member</command:noun> <maml:description> <maml:para>Gets the properties and methods of objects.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Get-Member` cmdlet gets the members, the properties and methods, of objects.</maml:para> <maml:para>To specify the object, use the InputObject parameter or pipe an object to `Get-Member`. To get information about static members, the members of the class, not of the instance, use the Static parameter. To get only certain types of members, such as NoteProperties , use the MemberType parameter.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-Member</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the names of one or more properties or methods of the object. `Get-Member` gets only the specified properties and methods.</maml:para> <maml:para>If you use the Name parameter with the MemberType , View , or Static parameter, `Get-Member` gets only the members that satisfy the criteria of all parameters.</maml:para> <maml:para>To get a static member by name, use the Static parameter with the Name parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Adds the intrinsic members and the compiler-generated get_ and set_ methods to the display. The following list describes the properties that are added when you use the Force parameter:</maml:para> <maml:para>- PSBase : The original properties of the .NET object without extension or adaptation. These are the properties defined for the object class. - PSAdapted . The properties and methods defined in the PowerShell extended type system. - PSExtended . The properties and methods that were added in the `Types.ps1xml` files or by using the `Add-Member` cmdlet. - PSObject . The adapter that converts the base object to a PowerShell PSObject object. - PSTypeNames . A list of object types that describe the object, in order of specificity. When formatting the object, PowerShell searches for the types in the `Format.ps1xml` files in the PowerShell installation directory (`$PSHOME`). It uses the formatting definition for the first type that it finds.</maml:para> <maml:para>By default, `Get-Member` gets these properties in all views except Base and Adapted , but does not display them.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the object whose members are retrieved.</maml:para> <maml:para>Using the InputObject parameter is not the same as piping an object to `Get-Member`. The differences are as follows:</maml:para> <maml:para>- When you pipe a collection of objects to `Get-Member`, `Get-Member` gets the members of the individual objects in the collection, such as the properties of each string in an array of strings. - When you use InputObject to submit a collection of objects, `Get-Member` gets the members of the collection, such as the properties of the array in an array of strings.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Type"> <maml:name>MemberType</maml:name> <maml:Description> <maml:para>Specifies the member type that this cmdlet gets. The default is All .</maml:para> <maml:para>The acceptable values for this parameter are:</maml:para> <maml:para>- AliasProperty</maml:para> <maml:para>- CodeProperty</maml:para> <maml:para>- Property</maml:para> <maml:para>- NoteProperty</maml:para> <maml:para>- ScriptProperty</maml:para> <maml:para>- Properties</maml:para> <maml:para>- PropertySet</maml:para> <maml:para>- Method</maml:para> <maml:para>- CodeMethod</maml:para> <maml:para>- ScriptMethod</maml:para> <maml:para>- Methods</maml:para> <maml:para>- ParameterizedProperty</maml:para> <maml:para>- MemberSet</maml:para> <maml:para>- Event</maml:para> <maml:para>- Dynamic</maml:para> <maml:para>- All</maml:para> <maml:para></maml:para> <maml:para>For information about these values, see PSMemberTypes Enumeration (/dotnet/api/system.management.automation.psmembertypes).</maml:para> <maml:para>Not all objects have every type of member. If you specify a member type that the object does not have, PowerShell returns a null value.</maml:para> <maml:para>To get related types of members, such as all extended members, use the View parameter. If you use the MemberType parameter with the Static or View parameters, `Get-Member` gets the members that belong to both sets.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">AliasProperty</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">CodeProperty</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Property</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">NoteProperty</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ScriptProperty</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Properties</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">PropertySet</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Method</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">CodeMethod</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ScriptMethod</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Methods</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ParameterizedProperty</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">MemberSet</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Event</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Dynamic</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">All</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSMemberTypes</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSMemberTypes</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Static</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet gets only the static properties and methods of the object. Static properties and methods are defined on the class of objects, not on any particular instance of the class.</maml:para> <maml:para>If you use the Static parameter with the View parameter, the View parameter is ignored. If you use the Static parameter with the MemberType parameter, `Get-Member` gets only the members that belong to both sets.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>View</maml:name> <maml:Description> <maml:para>Specifies that this cmdlet gets only particular types properties and methods. Specify one or more of the values. The default is Adapted , Extended .</maml:para> <maml:para>The acceptable values for this parameter are:</maml:para> <maml:para>- Base. Gets only the original properties and methods of the .NET object (without extension or adaptation). - Adapted. Gets only the properties and methods defined in the PowerShell extended type system.</maml:para> <maml:para>- Extended. Gets only the properties and methods that were added in a `Types.ps1xml` files or by</maml:para> <maml:para> using the `Add-Member` cmdlet. - All. Gets the members in the Base, Adapted, and Extended views.</maml:para> <maml:para>The View parameter determines the members retrieved, not just the display of those members.</maml:para> <maml:para>To get particular member types, such as script properties, use the MemberType parameter. If you use the MemberType and View parameters in the same command, `Get-Member` gets the members that belong to both sets. If you use the Static and View parameters in the same command, the View parameter is ignored.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Extended</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Adapted</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Base</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">All</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSMemberViewTypes</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSMemberViewTypes</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Adapted, Extended</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Adds the intrinsic members and the compiler-generated get_ and set_ methods to the display. The following list describes the properties that are added when you use the Force parameter:</maml:para> <maml:para>- PSBase : The original properties of the .NET object without extension or adaptation. These are the properties defined for the object class. - PSAdapted . The properties and methods defined in the PowerShell extended type system. - PSExtended . The properties and methods that were added in the `Types.ps1xml` files or by using the `Add-Member` cmdlet. - PSObject . The adapter that converts the base object to a PowerShell PSObject object. - PSTypeNames . A list of object types that describe the object, in order of specificity. When formatting the object, PowerShell searches for the types in the `Format.ps1xml` files in the PowerShell installation directory (`$PSHOME`). It uses the formatting definition for the first type that it finds.</maml:para> <maml:para>By default, `Get-Member` gets these properties in all views except Base and Adapted , but does not display them.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the object whose members are retrieved.</maml:para> <maml:para>Using the InputObject parameter is not the same as piping an object to `Get-Member`. The differences are as follows:</maml:para> <maml:para>- When you pipe a collection of objects to `Get-Member`, `Get-Member` gets the members of the individual objects in the collection, such as the properties of each string in an array of strings. - When you use InputObject to submit a collection of objects, `Get-Member` gets the members of the collection, such as the properties of the array in an array of strings.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Type"> <maml:name>MemberType</maml:name> <maml:Description> <maml:para>Specifies the member type that this cmdlet gets. The default is All .</maml:para> <maml:para>The acceptable values for this parameter are:</maml:para> <maml:para>- AliasProperty</maml:para> <maml:para>- CodeProperty</maml:para> <maml:para>- Property</maml:para> <maml:para>- NoteProperty</maml:para> <maml:para>- ScriptProperty</maml:para> <maml:para>- Properties</maml:para> <maml:para>- PropertySet</maml:para> <maml:para>- Method</maml:para> <maml:para>- CodeMethod</maml:para> <maml:para>- ScriptMethod</maml:para> <maml:para>- Methods</maml:para> <maml:para>- ParameterizedProperty</maml:para> <maml:para>- MemberSet</maml:para> <maml:para>- Event</maml:para> <maml:para>- Dynamic</maml:para> <maml:para>- All</maml:para> <maml:para></maml:para> <maml:para>For information about these values, see PSMemberTypes Enumeration (/dotnet/api/system.management.automation.psmembertypes).</maml:para> <maml:para>Not all objects have every type of member. If you specify a member type that the object does not have, PowerShell returns a null value.</maml:para> <maml:para>To get related types of members, such as all extended members, use the View parameter. If you use the MemberType parameter with the Static or View parameters, `Get-Member` gets the members that belong to both sets.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSMemberTypes</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSMemberTypes</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the names of one or more properties or methods of the object. `Get-Member` gets only the specified properties and methods.</maml:para> <maml:para>If you use the Name parameter with the MemberType , View , or Static parameter, `Get-Member` gets only the members that satisfy the criteria of all parameters.</maml:para> <maml:para>To get a static member by name, use the Static parameter with the Name parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Static</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet gets only the static properties and methods of the object. Static properties and methods are defined on the class of objects, not on any particular instance of the class.</maml:para> <maml:para>If you use the Static parameter with the View parameter, the View parameter is ignored. If you use the Static parameter with the MemberType parameter, `Get-Member` gets only the members that belong to both sets.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>View</maml:name> <maml:Description> <maml:para>Specifies that this cmdlet gets only particular types properties and methods. Specify one or more of the values. The default is Adapted , Extended .</maml:para> <maml:para>The acceptable values for this parameter are:</maml:para> <maml:para>- Base. Gets only the original properties and methods of the .NET object (without extension or adaptation). - Adapted. Gets only the properties and methods defined in the PowerShell extended type system.</maml:para> <maml:para>- Extended. Gets only the properties and methods that were added in a `Types.ps1xml` files or by</maml:para> <maml:para> using the `Add-Member` cmdlet. - All. Gets the members in the Base, Adapted, and Extended views.</maml:para> <maml:para>The View parameter determines the members retrieved, not just the display of those members.</maml:para> <maml:para>To get particular member types, such as script properties, use the MemberType parameter. If you use the MemberType and View parameters in the same command, `Get-Member` gets the members that belong to both sets. If you use the Static and View parameters in the same command, the View parameter is ignored.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSMemberViewTypes</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSMemberViewTypes</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Adapted, Extended</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe any object to `Get-Member`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.MemberDefinition</maml:name> </dev:type> <maml:description> <maml:para>`Get-Member` returns an object for each property or method that its gets.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>You can get information about a collection object either by using the InputObject parameter or by piping the object, preceded by a comma, to `Get-Member`.</maml:para> <maml:para>You can use the `$This` automatic variable in script blocks that define the values of new properties and methods. The `$This` variable refers to the instance of the object to which the properties and methods are being added. For more information about the `$This` variable, see about_Automatic_Variables (../Microsoft.PowerShell.Core/About/about_Automatic_Variables.md).</maml:para> <maml:para>If you pass an object representing a type , like a type literal such as `[int]`, `Get-Member` return information about the `[System.RuntimeType]` type. However, when you use the Static parameter, `Get-Member` returns the static members of the specific type represented by the `System.RuntimeType` instance.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------- Example 1: Get the members of process objects --------</maml:title> <dev:code>Get-Service | Get-Member TypeName: System.ServiceProcess.ServiceController Name MemberType Definition ---- ---------- ---------- Name AliasProperty Name = ServiceName RequiredServices AliasProperty RequiredServices = ServicesDependedOn Disposed Event System.EventHandler Disposed(System.Object, System.EventArgs) Close Method void Close() Continue Method void Continue() CreateObjRef Method System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType) Dispose Method void Dispose(), void IDisposable.Dispose() Equals Method bool Equals(System.Object obj) ExecuteCommand Method void ExecuteCommand(int command) GetHashCode Method int GetHashCode() GetLifetimeService Method System.Object GetLifetimeService() GetType Method type GetType() InitializeLifetimeService Method System.Object InitializeLifetimeService() Pause Method void Pause() Refresh Method void Refresh() Start Method void Start(), void Start(string[] args) Stop Method void Stop() WaitForStatus Method void WaitForStatus(System.ServiceProcess.ServiceControllerSt... CanPauseAndContinue Property bool CanPauseAndContinue {get;} CanShutdown Property bool CanShutdown {get;} CanStop Property bool CanStop {get;} Container Property System.ComponentModel.IContainer Container {get;} DependentServices Property System.ServiceProcess.ServiceController[] DependentServices {get;} DisplayName Property string DisplayName {get;set;} MachineName Property string MachineName {get;set;} ServiceHandle Property System.Runtime.InteropServices.SafeHandle ServiceHandle {get;} ServiceName Property string ServiceName {get;set;} ServicesDependedOn Property System.ServiceProcess.ServiceController[] ServicesDependedOn {get;} ServiceType Property System.ServiceProcess.ServiceType ServiceType {get;} Site Property System.ComponentModel.ISite Site {get;set;} StartType Property System.ServiceProcess.ServiceStartMode StartType {get;} Status Property System.ServiceProcess.ServiceControllerStatus Status {get;} ToString ScriptMethod System.Object ToString();</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 2: Get members of service objects ----------</maml:title> <dev:code>Get-Service | Get-Member -Force (Get-Service Schedule).PSBase</dev:code> <dev:remarks> <maml:para>The `Get-Member` command uses the Force parameter to add the intrinsic members and compiler-generated members of the objects to the display. You can use these properties and methods in the same way that you would use an adapted method of the object. The second command shows how to display the value of the PSBase property of the Schedule service.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 3: Get extended members of service objects ------</maml:title> <dev:code>Get-Service | Get-Member -View Extended TypeName: System.ServiceProcess.ServiceController Name MemberType Definition ---- ---------- ---------- Name AliasProperty Name = ServiceName RequiredServices AliasProperty RequiredServices = ServicesDependedOn ToString ScriptMethod System.Object ToString();</dev:code> <dev:remarks> <maml:para>The `Get-Member` command uses the View parameter to get only the extended members of the service objects. In this case, the extended member is the Name property, which is an alias property of the ServiceName property.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 4: Get script properties of event log objects ----</maml:title> <dev:code>Get-WinEvent -LogName System -MaxEvents 1 | Get-Member -MemberType NoteProperty TypeName: System.Diagnostics.Eventing.Reader.EventLogRecord Name MemberType Definition ---- ---------- ---------- Message NoteProperty string Message=The machine-default permission settings do not grant Local ...</dev:code> <dev:remarks> <maml:para>The MemberType parameter gets only objects with a value of `NoteProperty` for their MemberType property.</maml:para> <maml:para>The command returns the Message property of the EventLogRecord object.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 5: Get objects with a specified property -------</maml:title> <dev:code>$list = "Get-Process", "Get-Service", "Get-Culture", "Get-PSDrive", "Get-ExecutionPolicy" foreach ($cmdlet in $list) {& $cmdlet | Get-Member -Name MachineName} TypeName: System.Diagnostics.Process Name MemberType Definition ---- ---------- ---------- MachineName Property string MachineName {get;} TypeName: System.ServiceProcess.ServiceController Name MemberType Definition ---- ---------- ---------- MachineName Property string MachineName {get;set;}</dev:code> <dev:remarks> <maml:para>The results show that only process objects and service objects have a MachineName property.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------- Example 6: Get members for an array -------------</maml:title> <dev:code>$array = @(1,'hello') $array | Get-Member TypeName: System.Int32 Name MemberType Definition ---- ---------- ---------- CompareTo Method int CompareTo(System.Object value), int CompareTo(int value), int ICompar... Equals Method bool Equals(System.Object obj), bool Equals(int obj), bool IEquatable[int... GetHashCode Method int GetHashCode() GetType Method type GetType() GetTypeCode Method System.TypeCode GetTypeCode(), System.TypeCode IConvertible.GetTypeCode() ToBoolean Method bool IConvertible.ToBoolean(System.IFormatProvider provider) ToByte Method byte IConvertible.ToByte(System.IFormatProvider provider) ... TypeName: System.String Name MemberType Definition ---- ---------- ---------- Clone Method System.Object Clone(), System.Object ICloneable.Clone() CompareTo Method int CompareTo(System.Object value), int CompareTo(str... Contains Method bool Contains(string value), bool Contains(string val... CopyTo Method void CopyTo(int sourceIndex, char[] destination, int ... EndsWith Method bool EndsWith(string value), bool EndsWith(string val... EnumerateRunes Method System.Text.StringRuneEnumerator EnumerateRunes() Equals Method bool Equals(System.Object obj), bool Equals(string va... GetEnumerator Method System.CharEnumerator GetEnumerator(), System.Collect... GetHashCode Method int GetHashCode(), int GetHashCode(System.StringCompa... ... Get-Member -InputObject $array TypeName: System.Object[] Name MemberType Definition ---- ---------- ---------- Add Method int IList.Add(System.Object value) Address Method System.Object&, System.Private.CoreLib, Version=4.0.0.0, Cu... Clear Method void IList.Clear() Clone Method System.Object Clone(), System.Object ICloneable.Clone() CompareTo Method int IStructuralComparable.CompareTo(System.Object other, Sy... ...</dev:code> <dev:remarks> <maml:para>The `$array` variable contains an Int32 object and a string object, as seen when the array is piped to `Get-Member`. When `$array` is passed using the InputObject parameter `Get-Member` returns the members of the Object[] type.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--- Example 7: Determine which object properties you can set ---</maml:title> <dev:code>$File = Get-Item c:\test\textFile.txt $File.PSObject.Properties | Where-Object isSettable | Select-Object -Property Name Name ---- PSPath PSParentPath PSChildName PSDrive PSProvider PSIsContainer IsReadOnly CreationTime CreationTimeUtc LastAccessTime LastAccessTimeUtc LastWriteTime LastWriteTimeUtc Attributes</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-member?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Add-Member</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-PSBreakpoint</command:name> <command:verb>Get</command:verb> <command:noun>PSBreakpoint</command:noun> <maml:description> <maml:para>Gets the breakpoints that are set in the current session.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Get-PSBreakPoint cmdlet gets the breakpoints that are set in the current session. You can use the cmdlet parameters to get particular breakpoints.</maml:para> <maml:para>A breakpoint is a point in a command or script where execution stops temporarily so that you can examine the instructions. Get-PSBreakpoint is one of several cmdlets designed for debugging Windows PowerShell scripts and commands. For more information about the Windows PowerShell debugger, see about_Debuggers.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-PSBreakpoint</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Command</maml:name> <maml:Description> <maml:para>Specifies an array of command breakpoints that are set on the specified command names. Enter the command names, such as the name of a cmdlet or function.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>Script</maml:name> <maml:Description> <maml:para>Specifies an array of scripts that contain the breakpoints. Enter the path (optional) and names of one or more script files. If you omit the path, the default location is the current directory.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-PSBreakpoint</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Id</maml:name> <maml:Description> <maml:para>Specifies the breakpoint IDs that this cmdlet gets. Enter the IDs in a comma-separated list. You can also pipe breakpoint IDs to Get-PSBreakpoint .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-PSBreakpoint</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>Script</maml:name> <maml:Description> <maml:para>Specifies an array of scripts that contain the breakpoints. Enter the path (optional) and names of one or more script files. If you omit the path, the default location is the current directory.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-PSBreakpoint</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>Script</maml:name> <maml:Description> <maml:para>Specifies an array of scripts that contain the breakpoints. Enter the path (optional) and names of one or more script files. If you omit the path, the default location is the current directory.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Variable</maml:name> <maml:Description> <maml:para>Specifies an array of variable breakpoints that are set on the specified variable names. Enter the variable names without dollar signs.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-PSBreakpoint</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Type</maml:name> <maml:Description> <maml:para>Specifies an array of breakpoint types that this cmdlet gets. Enter one or more types. The acceptable values for this parameter are:</maml:para> <maml:para>- Line</maml:para> <maml:para>- Command</maml:para> <maml:para>- Variable</maml:para> <maml:para></maml:para> <maml:para>You can also pipe breakpoint types to Get-PSBreakPoint .</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Line</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Variable</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Command</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.BreakpointType[]</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.BreakpointType[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>Script</maml:name> <maml:Description> <maml:para>Specifies an array of scripts that contain the breakpoints. Enter the path (optional) and names of one or more script files. If you omit the path, the default location is the current directory.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Command</maml:name> <maml:Description> <maml:para>Specifies an array of command breakpoints that are set on the specified command names. Enter the command names, such as the name of a cmdlet or function.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Id</maml:name> <maml:Description> <maml:para>Specifies the breakpoint IDs that this cmdlet gets. Enter the IDs in a comma-separated list. You can also pipe breakpoint IDs to Get-PSBreakpoint .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>Script</maml:name> <maml:Description> <maml:para>Specifies an array of scripts that contain the breakpoints. Enter the path (optional) and names of one or more script files. If you omit the path, the default location is the current directory.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Type</maml:name> <maml:Description> <maml:para>Specifies an array of breakpoint types that this cmdlet gets. Enter one or more types. The acceptable values for this parameter are:</maml:para> <maml:para>- Line</maml:para> <maml:para>- Command</maml:para> <maml:para>- Variable</maml:para> <maml:para></maml:para> <maml:para>You can also pipe breakpoint types to Get-PSBreakPoint .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.BreakpointType[]</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.BreakpointType[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Variable</maml:name> <maml:Description> <maml:para>Specifies an array of variable breakpoints that are set on the specified variable names. Enter the variable names without dollar signs.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Int32, Microsoft.PowerShell.Commands.BreakpointType</maml:name> </dev:type> <maml:description> <maml:para>You can pipe breakpoint IDs and breakpoint types to Get-PSBreakPoint .</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.Breakpoint</maml:name> </dev:type> <maml:description> <maml:para>Get-PSBreakPoint returns objects that represent the breakpoints in the session.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>You can use Get-PSBreakpoint * or its alias, "gbp".</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>- Example 1: Get all breakpoints for all scripts and functions -</maml:title> <dev:code>PS C:\> Get-PSBreakpoint</dev:code> <dev:remarks> <maml:para>This command gets all breakpoints set on all scripts and functions in the current session.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------------- Example 2: Get breakpoints by ID ---------------</maml:title> <dev:code>PS C:\> Get-PSBreakpoint -Id 2 Function : IncrementAction : Enabled : TrueHitCount : 0 Id : 2 Script : C:\ps-test\sample.ps1 ScriptName : C:\ps-test\sample.ps1</dev:code> <dev:remarks> <maml:para>This command gets the breakpoint with breakpoint ID 2.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 3: Pipe an ID to Get-PSBreakpoint ----------</maml:title> <dev:code>PS C:\> $B = Set-PSBreakpoint -Script "sample.ps1" -Command "Increment" PS C:\> $B.Id | Get-PSBreakpoint</dev:code> <dev:remarks> <maml:para>These commands show how to get a breakpoint by piping a breakpoint ID to Get-PSBreakpoint .</maml:para> <maml:para>The first command uses the Set-PSBreakpoint cmdlet to create a breakpoint on the Increment function in the Sample.ps1 script. It saves the breakpoint object in the $B variable.</maml:para> <maml:para>The second command uses the dot operator (.) to get the Id property of the breakpoint object in the $B variable. It uses a pipeline operator (|) to send the ID to the Get-PSBreakpoint cmdlet.</maml:para> <maml:para>As a result, Get-PSBreakpoint gets the breakpoint with the specified ID.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 4: Get breakpoints in specified script files -----</maml:title> <dev:code>PS C:\> Get-PSBreakpoint -Script "Sample.ps1, SupportScript.ps1"</dev:code> <dev:remarks> <maml:para>This command gets all of the breakpoints in the Sample.ps1 and SupportScript.ps1 files.</maml:para> <maml:para>This command does not get other breakpoints that might be set in other scripts or on functions in the session.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 5: Get breakpoints in specified cmdlets -------</maml:title> <dev:code>PS C:\> Get-PSBreakpoint -Command "Read-Host, Write-Host" -Script "Sample.ps1"</dev:code> <dev:remarks> <maml:para>This command gets all Command breakpoints that are set on Read-Host or Write-Host commands in the Sample.ps1 file.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 6: Get Command breakpoints in a specified file ----</maml:title> <dev:code>PS C:\> Get-PSBreakpoint -Type Command -Script "Sample.ps1"</dev:code> <dev:remarks> <maml:para>This command gets all Command breakpoints in the Sample.ps1 file.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------ Example 7: Get breakpoints by variable ------------</maml:title> <dev:code>PS C:\> Get-PSBreakpoint -Variable "Index, Swap"</dev:code> <dev:remarks> <maml:para>This command gets breakpoints that are set on the $Index and $Swap variables in the current session.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 8: Get all Line and Variable breakpoints in a file --</maml:title> <dev:code>PS C:\> Get-PSBreakpoint -Type Line, Variable -Script "Sample.ps1"</dev:code> <dev:remarks> <maml:para>This command gets all line and variable breakpoints in the Sample.ps1 script.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-psbreakpoint?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Disable-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Enable-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-PSCallStack</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-PSCallStack</command:name> <command:verb>Get</command:verb> <command:noun>PSCallStack</command:noun> <maml:description> <maml:para>Displays the current call stack.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Get-PSCallStack cmdlet displays the current call stack.</maml:para> <maml:para>Although it is designed to be used with the Windows PowerShell debugger, you can use this cmdlet to display the call stack in a script or function outside of the debugger.</maml:para> <maml:para>To run a Get-PSCallStack command while in the debugger, type `k` or `Get-PSCallStack`.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-PSCallStack</maml:name> </command:syntaxItem> </command:syntax> <command:parameters /> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe objects to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.CallStackFrame</maml:name> </dev:type> <maml:description> <maml:para>Get-PSCallStack returns an object that represents the items in the call stack.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1: Get the call stack for a function ---------</maml:title> <dev:code>PS C:\> function my-alias { $p = $args[0] Get-Alias | where {$_.definition -like "*$p"} | format-table definition, name -auto } PS C:\ps-test> Set-PSBreakpoint -Command my-alias Command : my-alias Action : Enabled : True HitCount : 0 Id : 0 Script : prompt PS C:\> my-alias Get-Content Entering debug mode. Use h or ? for help. Hit Command breakpoint on 'prompt:my-alias' my-alias get-content [DBG]: PS C:\ps-test> s $p = $args[0] DEBUG: Stepped to ': $p = $args[0] ' [DBG]: PS C:\ps-test> s get-alias | Where {$_.Definition -like "*$p*"} | format-table Definition, [DBG]: PS C:\ps-test>get-pscallstack Name CommandLineParameters UnboundArguments Location ---- --------------------- ---------------- -------- prompt {} {} prompt my-alias {} {get-content} prompt prompt {} {} prompt PS C:\> [DBG]: PS C:\ps-test> o Definition Name ---------- ---- Get-Content gc Get-Content cat Get-Content type</dev:code> <dev:remarks> <maml:para>This command uses the Get-PSCallStack cmdlet to display the call stack for My-Alias, a simple function that gets the aliases for a cmdlet name.</maml:para> <maml:para>The first command enters the function at the Windows PowerShell prompt. The second command uses the Set-PSBreakpoint cmdlet to set a breakpoint on the My-Alias function. The third command uses the My-Alias function to get all of the aliases in the current session for the Get-Content cmdlet.</maml:para> <maml:para>The debugger breaks in at the function call. Two consecutive step-into (s) commands begin executing the function line by line. Then, a Get-PSCallStack command is used to retrieve the call stack.</maml:para> <maml:para>The final command is a Step-Out command (o) that exits the debugger and continues executing the script to completion.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-pscallstack?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Disable-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Enable-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-Table</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-Random</command:name> <command:verb>Get</command:verb> <command:noun>Random</command:noun> <maml:description> <maml:para>Gets a random number, or selects objects randomly from a collection.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Get-Random` cmdlet gets a randomly selected number. If you submit a collection of objects to `Get-Random`, it gets one or more randomly selected objects from the collection.</maml:para> <maml:para>Without parameters or input, a `Get-Random` command returns a randomly selected 32-bit unsigned integer between 0 (zero) and Int32.MaxValue (`0x7FFFFFFF`, `2,147,483,647`).</maml:para> <maml:para>You can use the parameters of `Get-Random` to specify a seed number, minimum and maximum values, and the number of objects returned from a submitted collection.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-Random</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies a collection of objects. `Get-Random` gets randomly selected objects in random order from the collection up to the number specified by Count . Enter the objects, a variable that contains the objects, or a command or expression that gets the objects. You can also pipe a collection of objects to `Get-Random`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Count</maml:name> <maml:Description> <maml:para>Specifies the number of random objects or numbers to return. The default is 1.</maml:para> <maml:para>When used with `InputObject`, if the value of Count exceeds the number of objects in the collection, `Get-Random` returns all of the objects in random order.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SetSeed</maml:name> <maml:Description> <maml:para>Specifies a seed value for the random number generator. This seed value is used for the current command and for all subsequent `Get-Random` commands in the current session until you use SetSeed again or close the session. You can't reset the seed to its default value.</maml:para> <maml:para>The SetSeed parameter is not required. By default, `Get-Random` uses the RandomNumberGenerator() (/dotnet/api/system.security.cryptography.randomnumbergenerator)method to generate a seed value. Because SetSeed results in non-random behavior, it's typically used only when trying to reproduce behavior, such as when debugging or analyzing a script that includes `Get-Random` commands.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Nullable`1[System.Int32]</command:parameterValue> <dev:type> <maml:name>System.Nullable`1[System.Int32]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-Random</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Maximum</maml:name> <maml:Description> <maml:para>Specifies a maximum value for the random number. `Get-Random` returns a value that is less than the maximum (not equal). Enter an integer, a double-precision floating-point number, or an object that can be converted to an integer or double, such as a numeric string ("100").</maml:para> <maml:para>The value of Maximum must be greater than (not equal to) the value of Minimum . If the value of Maximum or Minimum is a floating-point number, `Get-Random` returns a randomly selected floating-point number.</maml:para> <maml:para>On a 64-bit computer, if the value of Minimum is a 32-bit integer, the default value of Maximum is Int32.MaxValue .</maml:para> <maml:para>If the value of Minimum is a double (a floating-point number), the default value of Maximum is Double.MaxValue . Otherwise, the default value is Int32.MaxValue .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Minimum</maml:name> <maml:Description> <maml:para>Specifies a minimum value for the random number. Enter an integer, a double-precision floating-point number, or an object that can be converted to an integer or double, such as a numeric string ("100"). The default value is 0 (zero).</maml:para> <maml:para>The value of Minimum must be less than (not equal to) the value of Maximum . If the value of Maximum or Minimum is a floating-point number, `Get-Random` returns a randomly selected floating-point number.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SetSeed</maml:name> <maml:Description> <maml:para>Specifies a seed value for the random number generator. This seed value is used for the current command and for all subsequent `Get-Random` commands in the current session until you use SetSeed again or close the session. You can't reset the seed to its default value.</maml:para> <maml:para>The SetSeed parameter is not required. By default, `Get-Random` uses the RandomNumberGenerator() (/dotnet/api/system.security.cryptography.randomnumbergenerator)method to generate a seed value. Because SetSeed results in non-random behavior, it's typically used only when trying to reproduce behavior, such as when debugging or analyzing a script that includes `Get-Random` commands.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Nullable`1[System.Int32]</command:parameterValue> <dev:type> <maml:name>System.Nullable`1[System.Int32]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Count</maml:name> <maml:Description> <maml:para>Specifies the number of random objects or numbers to return. The default is 1.</maml:para> <maml:para>When used with `InputObject`, if the value of Count exceeds the number of objects in the collection, `Get-Random` returns all of the objects in random order.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies a collection of objects. `Get-Random` gets randomly selected objects in random order from the collection up to the number specified by Count . Enter the objects, a variable that contains the objects, or a command or expression that gets the objects. You can also pipe a collection of objects to `Get-Random`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Maximum</maml:name> <maml:Description> <maml:para>Specifies a maximum value for the random number. `Get-Random` returns a value that is less than the maximum (not equal). Enter an integer, a double-precision floating-point number, or an object that can be converted to an integer or double, such as a numeric string ("100").</maml:para> <maml:para>The value of Maximum must be greater than (not equal to) the value of Minimum . If the value of Maximum or Minimum is a floating-point number, `Get-Random` returns a randomly selected floating-point number.</maml:para> <maml:para>On a 64-bit computer, if the value of Minimum is a 32-bit integer, the default value of Maximum is Int32.MaxValue .</maml:para> <maml:para>If the value of Minimum is a double (a floating-point number), the default value of Maximum is Double.MaxValue . Otherwise, the default value is Int32.MaxValue .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Minimum</maml:name> <maml:Description> <maml:para>Specifies a minimum value for the random number. Enter an integer, a double-precision floating-point number, or an object that can be converted to an integer or double, such as a numeric string ("100"). The default value is 0 (zero).</maml:para> <maml:para>The value of Minimum must be less than (not equal to) the value of Maximum . If the value of Maximum or Minimum is a floating-point number, `Get-Random` returns a randomly selected floating-point number.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SetSeed</maml:name> <maml:Description> <maml:para>Specifies a seed value for the random number generator. This seed value is used for the current command and for all subsequent `Get-Random` commands in the current session until you use SetSeed again or close the session. You can't reset the seed to its default value.</maml:para> <maml:para>The SetSeed parameter is not required. By default, `Get-Random` uses the RandomNumberGenerator() (/dotnet/api/system.security.cryptography.randomnumbergenerator)method to generate a seed value. Because SetSeed results in non-random behavior, it's typically used only when trying to reproduce behavior, such as when debugging or analyzing a script that includes `Get-Random` commands.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Nullable`1[System.Int32]</command:parameterValue> <dev:type> <maml:name>System.Nullable`1[System.Int32]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Object</maml:name> </dev:type> <maml:description> <maml:para>You can pipe one or more objects. `Get-Random` selects values randomly from the piped objects.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Int32, System.Int64, System.Double</maml:name> </dev:type> <maml:description> <maml:para>`Get-Random` returns an integer or floating-point number, or an object selected randomly from a submitted collection.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>`Get-Random` sets a default seed for each session based on the system time clock when the session starts.</maml:para> <maml:para>`Get-Random` does not alway return the same data type as the input value. The following table shows the output type for each of the numeric input types.</maml:para> <maml:para>| Input Type | Output Type | | :--------: | :---------: | | SByte | Double | | Byte | Double | | Int16 | Double | | UInt16 | Double | | Int32 | Int32 | | UInt32 | Double | | Int64 | Int64 | | UInt64 | Double | | Double | Double | | Single | Double |</maml:para> <maml:para>Beginning in Windows PowerShell 3.0, `Get-Random` supports 64-bit integers. In Windows PowerShell 2.0, all values are cast to System.Int32 .</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------------- Example 1: Get a random integer ---------------</maml:title> <dev:code>Get-Random 3951433</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 2: Get a random integer between 0 and 99 -------</maml:title> <dev:code>Get-Random -Maximum 100 47</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 3: Get a random integer between -100 and 99 -----</maml:title> <dev:code>Get-Random -Minimum -100 -Maximum 100 56</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 4: Get a random floating-point number --------</maml:title> <dev:code>Get-Random -Minimum 10.7 -Maximum 20.93 18.08467273887</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 5: Get a random integer from an array --------</maml:title> <dev:code>1, 2, 3, 5, 8, 13 | Get-Random 8</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 6: Get several random integers from an array -----</maml:title> <dev:code>1, 2, 3, 5, 8, 13 | Get-Random -Count 3 3 1 13</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 7: Randomize an entire collection ----------</maml:title> <dev:code>1, 2, 3, 5, 8, 13 | Get-Random -Count ([int]::MaxValue) 2 3 5 1 8 13</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 8: Get a random non-numeric value ----------</maml:title> <dev:code>"red", "yellow", "blue" | Get-Random yellow</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------- Example 9: Use the SetSeed parameter -------------</maml:title> <dev:code># Commands with the default seed are pseudorandom Get-Random -Maximum 100 -SetSeed 23 Get-Random -Maximum 100 Get-Random -Maximum 100 Get-Random -Maximum 100 74 56 84 46 # Commands with the same seed are not random Get-Random -Maximum 100 -SetSeed 23 Get-Random -Maximum 100 -SetSeed 23 Get-Random -Maximum 100 -SetSeed 23 74 74 74 # SetSeed results in a repeatable series Get-Random -Maximum 100 -SetSeed 23 Get-Random -Maximum 100 Get-Random -Maximum 100 Get-Random -Maximum 100 74 56 84 46</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------------- Example 10: Get random files -----------------</maml:title> <dev:code>$Files = Get-ChildItem -Path C:\* -Recurse $Sample = $Files | Get-Random -Count 50</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------------ Example 11: Roll fair dice ------------------</maml:title> <dev:code>1..1200 | ForEach-Object { 1..6 | Get-Random } | Group-Object | Select-Object Name,Count Name Count ---- ----- 1 206 2 199 3 196 4 226 5 185 6 188</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-random?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-Runspace</command:name> <command:verb>Get</command:verb> <command:noun>Runspace</command:noun> <maml:description> <maml:para>Gets active runspaces within a PowerShell host process.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Get-Runspace` cmdlet gets active runspaces in a PowerShell host process.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-Runspace</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Id</maml:name> <maml:Description> <maml:para>Specifies the Id of a runspace</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-Runspace</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>InstanceId</maml:name> <maml:Description> <maml:para>Specifies the instance ID GUID of a running job.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Guid[]</command:parameterValue> <dev:type> <maml:name>System.Guid[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-Runspace</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the Name of a runspace</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Id</maml:name> <maml:Description> <maml:para>Specifies the Id of a runspace</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>InstanceId</maml:name> <maml:Description> <maml:para>Specifies the instance ID GUID of a running job.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Guid[]</command:parameterValue> <dev:type> <maml:name>System.Guid[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the Name of a runspace</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes /> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.Runspace</maml:name> </dev:type> <maml:description> <maml:para>You can pipe the results of a `Get-Runspace` command to `Debug-Runspace`.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------------- Example 1: Get runspaces -------------------</maml:title> <dev:code>Get-Runspace Id Name ComputerName Type State Availability -- ---- ------------ ---- ----- ------------ 1 Runspace1 localhost Local Opened Busy 2 Runspace2 localhost Local Opened Available 3 Runspace3 localhost Local Opened Available</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------------- Example 2: Get runspace by Id ----------------</maml:title> <dev:code>Get-Runspace -Id 2 Id Name ComputerName Type State Availability -- ---- ------------ ---- ----- ------------ 2 Runspace2 localhost Local Opened Available</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------------- Example 3: Get runspace by Name ---------------</maml:title> <dev:code>Get-Runspace -Name Runspace1 Id Name ComputerName Type State Availability -- ---- ------------ ---- ----- ------------ 1 Runspace1 localhost Local Opened Busy</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------ Example 4: Get runspace by InstanceId ------------</maml:title> <dev:code>$activeRunspace = Get-Runspace -Name Runspace1 Get-Runspace -InstanceId $activeRunspace.InstanceId Id Name ComputerName Type State Availability -- ---- ------------ ---- ----- ------------ 1 Runspace1 localhost Local Opened Busy</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-runspace?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Debug-Runspace</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-RunspaceDebug</command:name> <command:verb>Get</command:verb> <command:noun>RunspaceDebug</command:noun> <maml:description> <maml:para>Shows runspace debugging options.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Get-RunspaceDebug` cmdlet shows runspace debugging options.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-RunspaceDebug</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>ProcessName</maml:name> <maml:Description> <maml:para>The name of the process that hosts the PowerShell runspace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>AppDomainName</maml:name> <maml:Description> <maml:para>The name of the application domain that hosts the PowerShell runspace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-RunspaceDebug</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Runspace</maml:name> <maml:Description> <maml:para>One or more Runspace objects to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Runspaces.Runspace[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.Runspace[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-RunspaceDebug</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceId</maml:name> <maml:Description> <maml:para>One or more Runspace Id numbers to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-RunspaceDebug</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceInstanceId</maml:name> <maml:Description> <maml:para>One or more Runspace GUIDs to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Guid[]</command:parameterValue> <dev:type> <maml:name>System.Guid[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-RunspaceDebug</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceName</maml:name> <maml:Description> <maml:para>One or more Runspace names to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>AppDomainName</maml:name> <maml:Description> <maml:para>The name of the application domain that hosts the PowerShell runspace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>ProcessName</maml:name> <maml:Description> <maml:para>The name of the process that hosts the PowerShell runspace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Runspace</maml:name> <maml:Description> <maml:para>One or more Runspace objects to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Runspaces.Runspace[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.Runspace[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceId</maml:name> <maml:Description> <maml:para>One or more Runspace Id numbers to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceInstanceId</maml:name> <maml:Description> <maml:para>One or more Runspace GUIDs to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Guid[]</command:parameterValue> <dev:type> <maml:name>System.Guid[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>RunspaceName</maml:name> <maml:Description> <maml:para>One or more Runspace names to be disabled.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes /> <command:returnValues /> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------ 1: Show the state of the default runspace debugger ------</maml:title> <dev:code>Get-RunspaceDebug Id Name Enabled BreakAll -- ---- ------- -------- 1 Runspace1 False False</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-runspacedebug?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Disable-RunspaceDebug</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Enable-RunspaceDebug</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-TraceSource</command:name> <command:verb>Get</command:verb> <command:noun>TraceSource</command:noun> <maml:description> <maml:para>Gets PowerShell components that are instrumented for tracing.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Get-TraceSource cmdlet gets the trace sources for PowerShell components that are currently in use. You can use the data to determine which PowerShell components you can trace. When tracing, the component generates detailed messages about each step in its internal processing. Developers use the trace data to monitor data flow, program execution, and errors.</maml:para> <maml:para>The tracing cmdlets were designed for PowerShell developers, but they are available to all users.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-TraceSource</maml:name> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the trace sources to get. Wildcards are permitted. The parameter name Name is optional.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the trace sources to get. Wildcards are permitted. The parameter name Name is optional.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a string that contains the name of a trace source to Get-TraceSource .</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.PSTraceSource</maml:name> </dev:type> <maml:description> <maml:para>Get-TraceSource returns objects that represent the trace sources.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------- Example 1: Get trace sources by name -------------</maml:title> <dev:code>PS C:\> Get-TraceSource -Name "*provider*"</dev:code> <dev:remarks> <maml:para>This command gets all of the trace sources that have names that include provider.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------------- Example 2: Get all trace sources ---------------</maml:title> <dev:code>PS C:\> Get-TraceSource</dev:code> <dev:remarks> <maml:para>This command gets all of the PowerShell components that can be traced.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-tracesource?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-TraceSource</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Trace-Command</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-TypeData</command:name> <command:verb>Get</command:verb> <command:noun>TypeData</command:noun> <maml:description> <maml:para>Gets the extended type data in the current session.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Get-TypeData` cmdlet gets the extended type data in the current session. This includes type data that was added to the session by `Types.ps1xml` file and dynamic type data that was added by using the parameter of the `Update-TypeData` cmdlet.</maml:para> <maml:para>You can use the extended type data that `Get-TypeData` returns to examine the type data in the session and send it to the `Update-TypeData` and `Remove-TypeData` cmdlets.</maml:para> <maml:para>Extended type data adds properties and methods to objects in PowerShell. You can use the added properties and methods in the same ways that you would use the properties and methods that are defined in the object type. However, when writing scripts, be aware that the added properties and methods might not be present in every PowerShell session.</maml:para> <maml:para>For more information about `Types.ps1xml` files, see about_Types.ps1xml (../Microsoft.PowerShell.Core/About/about_Types.ps1xml.md). For more information about dynamic type data that the `Update-TypeData` cmdlet adds, see `Update-TypeData`.</maml:para> <maml:para>This cmdlet was introduced in Windows PowerShell 3.0.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-TypeData</maml:name> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>TypeName</maml:name> <maml:Description> <maml:para>Specifies type data as an array only for the types with the specified names. By default, `Get-TypeData` gets all types in the session.</maml:para> <maml:para>Enter type names or a name patterns. Full names, or name patterns with wildcard characters are required, even for types in the System namespace. Wildcards are supported and the parameter name TypeName is optional. You can also pipe type names to `Get-TypeData`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>TypeName</maml:name> <maml:Description> <maml:para>Specifies type data as an array only for the types with the specified names. By default, `Get-TypeData` gets all types in the session.</maml:para> <maml:para>Enter type names or a name patterns. Full names, or name patterns with wildcard characters are required, even for types in the System namespace. Wildcards are supported and the parameter name TypeName is optional. You can also pipe type names to `Get-TypeData`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe type names to `Get-TypeData`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.TypeData</maml:name> </dev:type> <maml:description> <maml:para></maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>`Get-TypeData` gets only the extended type data in the current session. It does not get extended type data that is on the computer, but has not been added to the current session, such as extended types that are defined in modules that have not been imported into the current session.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------ Example 1: Get all extended type data ------------</maml:title> <dev:code>Get-TypeData</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------------- Example 2: Get types by name -----------------</maml:title> <dev:code>"*Eventing*" | Get-TypeData TypeName Members -------- ------- System.Diagnostics.Eventing.Reader.EventLogConfiguration {}System.Diagnostics.Eventing.Reader.EventLogRecord {}System.Diagnostics.Eventing.Reader.ProviderMetadata {[ProviderName, System.Management.Automation.Runspaces.AliasProper...</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title> Example 3: Get the script block that creates a property value </maml:title> <dev:code>(Get-TypeData *EventLogEntry*).Members.EventID GetScriptBlock SetScriptBlock IsHidden Name -------------- -------------- -------- ---- $this.get_EventID() -band 0xFFFF False EventID</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 4: Get the script block that defines a property for a specified object</maml:title> <dev:code>(Get-TypeData -TypeName System.DateTime).Members["DateTime"].GetScriptBlock if ((& { Set-StrictMode -Version 1; $this.DisplayHint }) -ieq "Date") { "{0}" -f $this.ToLongDateString() } elseif ((& { Set-StrictMode -Version 1; $this.DisplayHint }) -ieq "Time") { "{0}" -f $this.ToLongTimeString() } else { "{0} {1}" -f $this.ToLongDateString(), $this.ToLongTimeString() }</dev:code> <dev:remarks> <maml:para>The command uses the `Get-TypeData` cmdlet to get the extended type data for the System.DataTime type. The command gets the Members property of the TypeData object.</maml:para> <maml:para>The Members property contains a hash table of properties and methods that are defined by extended type data. Each key in the Members hash table is a property or method name and each value is the definition of the property or method value.</maml:para> <maml:para>The command gets the DateTime key in Members and its GetScriptBlock property value.</maml:para> <maml:para>The output shows the script block that creates the value of the DateTime property of every System.DateTime object in PowerShell.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-typedata?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Types.ps1xml</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-TypeData</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Update-TypeData</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-UICulture</command:name> <command:verb>Get</command:verb> <command:noun>UICulture</command:noun> <maml:description> <maml:para>Gets the current UI culture settings in the operating system.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Get-UICulture cmdlet gets information about the current user interface (UI) culture settings for Windows. The UI culture determines which text strings are used for user interface elements, such as menus and messages.</maml:para> <maml:para>You can also use the Get-Culture cmdlet, which gets the current culture on the system. The culture determines the display format of items such as numbers, currency, and dates.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-UICulture</maml:name> </command:syntaxItem> </command:syntax> <command:parameters /> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe input to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Globalization.CultureInfo, Microsoft.PowerShell.VistaCultureInfo</maml:name> </dev:type> <maml:description> <maml:para>Get-UICulture returns an object that represents the current UI culture. In Windows PowerShell 3.0, it returns a CultureInfo object. In Windows PowerShell 2.0, it returns a VistaCultureInfo object.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>* You can also use the $PsCulture and $PsUICulture variables. The $PsCulture variable stores the name of the current culture, and the $PsUICulture variable stores the name of the current UI culture.</maml:para> <maml:para>*</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>---------------- Example 1: Get the UI culture ----------------</maml:title> <dev:code>PS C:\> Get-UICulture</dev:code> <dev:remarks> <maml:para>This command gets the current UI culture information.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 2: Get the UI culture and format the results -----</maml:title> <dev:code>PS C:\> Get-UICulture | Format-List *</dev:code> <dev:remarks> <maml:para>This command displays the values of all of the properties of the current UI culture in a list.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 3: Get the value of the Calendar property ------</maml:title> <dev:code>PS C:\> (Get-UICulture).Calendar</dev:code> <dev:remarks> <maml:para>This command displays the current values for the Calendar property of the current UI culture. Calendar is just one property of UI culture. To see all of the properties, type `Get-UICulture | Get-Member`.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------ Example 4: Get the short date pattern ------------</maml:title> <dev:code>PS C:\> (Get-UICulture).DateTimeFormat.ShortDatePattern</dev:code> <dev:remarks> <maml:para>This command displays the short date pattern for the current UI culture. To see all of the subproperties of the DateTimeFormat property of the UI culture, type `(Get-UICulture).DateTimeFormat | gm`.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-uiculture?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-Unique</command:name> <command:verb>Get</command:verb> <command:noun>Unique</command:noun> <maml:description> <maml:para>Returns unique items from a sorted list.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Get-Unique` cmdlet compares each item in a sorted list to the next item, eliminates duplicates, and returns only one instance of each item. The list must be sorted for the cmdlet to work properly.</maml:para> <maml:para>`Get-Unique` is case-sensitive. As a result, strings that differ only in character casing are considered to be unique.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-Unique</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AsString</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet uses the data as a string. Without this parameter, data is treated as an object, so when you submit a collection of objects of the same type to `Get-Unique`, such as a collection of files, it returns just one (the first). You can use this parameter to find the unique values of object properties, such as the file names.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies input for `Get-Unique`. Enter a variable that contains the objects or type a command or expression that gets the objects.</maml:para> <maml:para>This cmdlet treats the input submitted by using InputObject as a collection. it does not enumerate individual items in the collection. Because the collection is a single item, input submitted by using InputObject is always returned unchanged.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-Unique</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies input for `Get-Unique`. Enter a variable that contains the objects or type a command or expression that gets the objects.</maml:para> <maml:para>This cmdlet treats the input submitted by using InputObject as a collection. it does not enumerate individual items in the collection. Because the collection is a single item, input submitted by using InputObject is always returned unchanged.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>OnType</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet returns only one object of each type.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AsString</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet uses the data as a string. Without this parameter, data is treated as an object, so when you submit a collection of objects of the same type to `Get-Unique`, such as a collection of files, it returns just one (the first). You can use this parameter to find the unique values of object properties, such as the file names.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies input for `Get-Unique`. Enter a variable that contains the objects or type a command or expression that gets the objects.</maml:para> <maml:para>This cmdlet treats the input submitted by using InputObject as a collection. it does not enumerate individual items in the collection. Because the collection is a single item, input submitted by using InputObject is always returned unchanged.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>OnType</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet returns only one object of each type.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe any type of object to `Get-Unique`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>The type of object that `Get-Unique` returns is determined by the input.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>You can also refer to `Get-Unique` by its built-in alias, `gu`. For more information, see about_Aliases (../Microsoft.PowerShell.Core/About/about_Aliases.md).</maml:para> <maml:para>To sort a list, use Sort-Object. You can also use the Unique parameter of `Sort-Object` to find the unique items in a list.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>---------- Example 1: Get unique words in a text file ----------</maml:title> <dev:code>$A = $( foreach ($line in Get-Content C:\Test1\File1.txt) { $line.tolower().split(" ") }) | Sort-Object | Get-Unique $A.count</dev:code> <dev:remarks> <maml:para>The first command gets the content of the File.txt file. It converts each line of text to lowercase letters and then splits each word onto a separate line at the space (" "). Then, it sorts the resulting list alphabetically (the default) and uses the `Get-Unique` cmdlet to eliminate any duplicate words. The results are stored in the `$A` variable.</maml:para> <maml:para>The second command uses the Count property of the collection of strings in `$A` to determine how many items are in `$A`.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 2: Get unique integers in an array ----------</maml:title> <dev:code>1,1,1,1,12,23,4,5,4643,5,3,3,3,3,3,3,3 | Sort-Object | Get-Unique 1 3 4 5 12 23 4643</dev:code> <dev:remarks> <maml:para>The first command takes an array of integers typed at the command line, pipes them to the `Sort-Object` cmdlet to be sorted, and then pipes them to `Get-Unique`, which eliminates duplicate entries.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 3: Get unique object types in a directory ------</maml:title> <dev:code>Get-ChildItem | Sort-Object {$_.GetType()} | Get-Unique -OnType</dev:code> <dev:remarks> <maml:para>The pipeline operator (|) sends the results to the `Sort-Object` cmdlet. The `$_.GetType()` statement applies the GetType method to each file or directory. Then, `Sort-Object` sorts the items by type. Another pipeline operator sends the results to `Get-Unique`. The OnType parameter directs `Get-Unique` to return only one object of each type.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------------- Example 4: Get unique processes ---------------</maml:title> <dev:code>Get-Process | Sort-Object | Select-Object processname | Get-Unique -AsString</dev:code> <dev:remarks> <maml:para>The `Get-Process` command gets all of the processes on the computer. The pipeline operator (|) passes the result to `Sort-Object`, which, by default, sorts the processes alphabetically by ProcessName. The results are piped to the `Select-Object` cmdlet, which selects only the values of the ProcessName property of each object. The results are then piped to `Get-Unique` to eliminate duplicates.</maml:para> <maml:para>The AsString parameter tells `Get-Unique` to treat the ProcessName values as strings. Without this parameter, `Get-Unique` treats the ProcessName values as objects and returns only one instance of the object, that is, the first process name in the list.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-unique?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Select-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Sort-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-Variable</command:name> <command:verb>Get</command:verb> <command:noun>Variable</command:noun> <maml:description> <maml:para>Gets the variables in the current console.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Get-Variable` cmdlet gets the PowerShell variables in the current console. You can retrieve just the values of the variables by specifying the ValueOnly parameter, and you can filter the variables returned by name.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-Variable</maml:name> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the name of the variable. Wildcards are permitted. You can also pipe a variable name to `Get-Variable`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Exclude</maml:name> <maml:Description> <maml:para>Specifies an array of items that this cmdlet excludes from the operation. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Include</maml:name> <maml:Description> <maml:para>Specifies an array of items upon which the cmdlet will act, excluding all others. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the variables in the scope.The acceptable values for this parameter are:</maml:para> <maml:para>- Global - Local - Script - A number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent) Local is the default. For more information, see about_Scopes (../Microsoft.PowerShell.Core/About/about_Scopes.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ValueOnly</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet gets only the value of the variable.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Exclude</maml:name> <maml:Description> <maml:para>Specifies an array of items that this cmdlet excludes from the operation. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Include</maml:name> <maml:Description> <maml:para>Specifies an array of items upon which the cmdlet will act, excluding all others. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the name of the variable. Wildcards are permitted. You can also pipe a variable name to `Get-Variable`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the variables in the scope.The acceptable values for this parameter are:</maml:para> <maml:para>- Global - Local - Script - A number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent) Local is the default. For more information, see about_Scopes (../Microsoft.PowerShell.Core/About/about_Scopes.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ValueOnly</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet gets only the value of the variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a string that contains the variable name to `Get-Variable`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.PSVariable</maml:name> </dev:type> <maml:description> <maml:para>This cmdlet returns a System.Management.AutomationPSVariable object for each variable that it gets. The object type depends on the variable.</maml:para> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <maml:name>System.Object[]</maml:name> </dev:type> <maml:description> <maml:para>When you specify the ValueOnly parameter, if the specified variable's value is a collection, `Get-Variable` returns a `[System.Object[]]`. This behavior prevents normal pipeline operation from processing the variable's values one at a time. A workaround to force collection enumeration is to enclose the `Get-Variable` command in parenthesis.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>- This cmdlet does not manage environment variables. To manage environment variables, you can use the environment variable provider.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------- Example 1: Get variables by letter --------------</maml:title> <dev:code>Get-Variable m*</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 2: Get variable values by letter -----------</maml:title> <dev:code>Get-Variable m* -ValueOnly</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 3: Get variables by two letters -----------</maml:title> <dev:code>Get-Variable -Include M*,P*</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------------- Example 4: Get variables by scope --------------</maml:title> <dev:code>Get-Variable -Scope 0 Compare-Object (Get-Variable -Scope 0) (Get-Variable -Scope 1)</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-variable?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Clear-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Group-Object</command:name> <command:verb>Group</command:verb> <command:noun>Object</command:noun> <maml:description> <maml:para>Groups objects that contain the same value for specified properties.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Group-Object` cmdlet displays objects in groups based on the value of a specified property. `Group-Object` returns a table with one row for each property value and a column that displays the number of items with that value.</maml:para> <maml:para>If you specify more than one property, `Group-Object` first groups them by the values of the first property, and then, within each property group, it groups by the value of the next property.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Group-Object</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the properties for grouping. The objects are arranged into groups based on the value of the specified property.</maml:para> <maml:para>The value of the Property parameter can be a new calculated property. To create a calculated, property, create a hash table with an Expression key that specifies a string or script block value.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="AHT"> <maml:name>AsHashTable</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet returns the group as a hash table. The keys of the hash table are the property values by which the objects are grouped. The values of the hash table are the objects that have that property value.</maml:para> <maml:para>By itself, the AsHashTable parameter returns each hash table in which each key is an instance of the grouped object. When used with the AsString parameter, the keys in the hash table are strings.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AsString</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet converts the hash table keys to strings. By default, the hash table keys are instances of the grouped object. This parameter is valid only when used with the AsHashTable parameter.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CaseSensitive</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet makes the grouping case-sensitive. Without this parameter, the property values of objects in a group might have different cases.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Culture</maml:name> <maml:Description> <maml:para>Specifies the culture to use when comparing strings.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to group. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> <maml:para>When you use the InputObject parameter to submit a collection of objects to `Group-Object`, `Group-Object` receives one object that represents the collection. As a result, it creates a single group with that object as its member.</maml:para> <maml:para>To group the objects in a collection, pipe the objects to `Group-Object`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NoElement</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet omits the members of a group from the results.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="AHT"> <maml:name>AsHashTable</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet returns the group as a hash table. The keys of the hash table are the property values by which the objects are grouped. The values of the hash table are the objects that have that property value.</maml:para> <maml:para>By itself, the AsHashTable parameter returns each hash table in which each key is an instance of the grouped object. When used with the AsString parameter, the keys in the hash table are strings.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AsString</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet converts the hash table keys to strings. By default, the hash table keys are instances of the grouped object. This parameter is valid only when used with the AsHashTable parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CaseSensitive</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet makes the grouping case-sensitive. Without this parameter, the property values of objects in a group might have different cases.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Culture</maml:name> <maml:Description> <maml:para>Specifies the culture to use when comparing strings.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to group. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> <maml:para>When you use the InputObject parameter to submit a collection of objects to `Group-Object`, `Group-Object` receives one object that represents the collection. As a result, it creates a single group with that object as its member.</maml:para> <maml:para>To group the objects in a collection, pipe the objects to `Group-Object`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NoElement</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet omits the members of a group from the results.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the properties for grouping. The objects are arranged into groups based on the value of the specified property.</maml:para> <maml:para>The value of the Property parameter can be a new calculated property. To create a calculated, property, create a hash table with an Expression key that specifies a string or script block value.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe any object to `Group-Object`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.GroupInfo or System.Collections.Hashtable</maml:name> </dev:type> <maml:description> <maml:para>When you use the AsHashTable parameter, `Group-Object` returns a Hashtable object. Otherwise, it returns a GroupInfo object.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>You can use the GroupBy parameter of the formatting cmdlets, such as `Format-Table` and `Format-List`, to group objects. Unlike `Group-Object`, which creates a single table with a row for each property value, the GroupBy parameters create a table for each property value with a row for each item that has the property value.</maml:para> <maml:para>`Group-Object` doesn't require that the objects being grouped are of the same Microsoft .NET Framework type. When grouping objects of different .NET Framework types, `Group-Object` uses the following rules:</maml:para> <maml:para>- Same Property Names and Types.</maml:para> <maml:para> If the objects have a property with the specified name, and the property values have the same .NET Framework type, the property values are grouped by using the same rules that would be used for objects of the same type.</maml:para> <maml:para>- Same Property Names, Different Types.</maml:para> <maml:para> If the objects have a property with the specified name, but the property values have a different .NET Framework type in different objects, `Group-Object` uses the .NET Framework type of the first occurrence of the property as the .NET Framework type for that property group. When an object has a property with a different type, the property value is converted to the type for that group. If the type conversion fails, the object is not included in the group.</maml:para> <maml:para>- Missing Properties.</maml:para> <maml:para> Objects that don't have a specified property can't be grouped. Objects that aren't grouped appear in the final GroupInfo object output in a group named `AutomationNull.Value`.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------- Example 1: Group files by extension -------------</maml:title> <dev:code>$files = Get-ChildItem -Path $PSHOME -Recurse $files | Group-Object -Property extension -NoElement | Sort-Object -Property Count -Descending Count Name ----- ---- 365 .xml 231 .cdxml 197 169 .ps1xml 142 .txt 114 .psd1 63 .psm1 49 .xsd 36 .dll 15 .mfl 15 .mof ...</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 2: Group integers by odds and evens ---------</maml:title> <dev:code>1..20 | Group-Object -Property {$_ % 2} Count Name Group ----- ---- ----- 10 1 {1, 3, 5, 7...} 10 0 {2, 4, 6, 8...}</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 3: Group event log events by EntryType --------</maml:title> <dev:code>Get-WinEvent -LogName System -MaxEvents 1000 | Group-Object -Property LevelDisplayName Count Name Group ----- ---- ----- 153 Error {System.Diagnostics.Eventing.Reader.EventLogRecord, System.Diagnostics...} 722 Information {System.Diagnostics.Eventing.Reader.EventLogRecord, System.Diagnostics...} 125 Warning {System.Diagnostics.Eventing.Reader.EventLogRecord, System.Diagnostics...}</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 4: Group processes by priority class ---------</maml:title> <dev:code>Get-Process | Group-Object -Property PriorityClass Count Name Group ----- ---- ----- 55 Normal {System.Diagnostics.Process (AdtAgent), System.Diagnosti... 1 {System.Diagnostics.Process (Idle)} 3 High {System.Diagnostics.Process (Newproc), System.Diagnostic... 2 BelowNormal {System.Diagnostics.Process (winperf), Get-Process | Group-Object -Property PriorityClass -NoElement Count Name ----- ---- 55 Normal 1 3 High 2 BelowNormal</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------------- Example 5: Group processes by name --------------</maml:title> <dev:code>Get-Process | Group-Object -Property Name -NoElement | Where-Object {$_.Count -gt 1} Count Name ----- ---- 2 csrss 5 svchost 2 winlogon 2 wmiprvse</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 6: Group objects in a hash table -----------</maml:title> <dev:code>$A = Get-Command Get-*, Set-* -CommandType cmdlet | Group-Object -Property Verb -AsHashTable -AsString $A Name Value ---- ----- Get {Get-Acl, Get-Alias, Get-AppLockerFileInformation, Get-AppLockerPolicy...} Set {Set-Acl, Set-Alias, Set-AppBackgroundTaskResourcePolicy, Set-AppLockerPolicy...} $A.Get CommandType Name Version Source ----------- ---- ------- ------ Cmdlet Get-Acl 3.0.0.0 Microsoft.PowerShell.Security Cmdlet Get-Alias 3.1.0.0 Microsoft.PowerShell.Utility Cmdlet Get-AppLockerFileInformation 2.0.0.0 AppLocker Cmdlet Get-AppLockerPolicy 2.0.0.0 AppLocker ...</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/group-object?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Hash_Tables</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Compare-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ForEach-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Measure-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Select-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Sort-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Tee-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Where-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Import-Alias</command:name> <command:verb>Import</command:verb> <command:noun>Alias</command:noun> <maml:description> <maml:para>Imports an alias list from a file.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Import-Alias` cmdlet imports an alias list from a file.</maml:para> <maml:para>Beginning in Windows PowerShell 3.0, as a security feature, `Import-Alias` does not overwrite existing aliases by default. To overwrite an existing alias, after assuring that the contents of the alias file is safe, use the Force parameter.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Import-Alias</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Allows the cmdlet to import an alias that is already defined or is read only. You can use the following command to display information about the currently-defined aliases:</maml:para> <maml:para>`Get-Alias | Select-Object Name, Options`</maml:para> <maml:para>If the corresponding alias is read-only, it will be displayed in the value of the Options property.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to a file that includes exported alias information. Unlike the Path parameter, the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope into which the aliases are imported. The acceptable values for this parameter are:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Script</maml:para> <maml:para>- A number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent)</maml:para> <maml:para></maml:para> <maml:para>The default is Local. For more information, see about_Scopes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Import-Alias</maml:name> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the path to a file that includes exported alias information. Wildcards are allowed but they must resolve to a single name.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Allows the cmdlet to import an alias that is already defined or is read only. You can use the following command to display information about the currently-defined aliases:</maml:para> <maml:para>`Get-Alias | Select-Object Name, Options`</maml:para> <maml:para>If the corresponding alias is read-only, it will be displayed in the value of the Options property.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope into which the aliases are imported. The acceptable values for this parameter are:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Script</maml:para> <maml:para>- A number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent)</maml:para> <maml:para></maml:para> <maml:para>The default is Local. For more information, see about_Scopes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Allows the cmdlet to import an alias that is already defined or is read only. You can use the following command to display information about the currently-defined aliases:</maml:para> <maml:para>`Get-Alias | Select-Object Name, Options`</maml:para> <maml:para>If the corresponding alias is read-only, it will be displayed in the value of the Options property.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to a file that includes exported alias information. Unlike the Path parameter, the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the path to a file that includes exported alias information. Wildcards are allowed but they must resolve to a single name.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope into which the aliases are imported. The acceptable values for this parameter are:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Script</maml:para> <maml:para>- A number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent)</maml:para> <maml:para></maml:para> <maml:para>The default is Local. For more information, see about_Scopes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a string that contains a path to `Import-Alias`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None or System.Management.Automation.AliasInfo</maml:name> </dev:type> <maml:description> <maml:para>When you use the Passthru parameter, `Import-Alias` returns a System.Management.Automation.AliasInfo object that represents the alias. Otherwise, this cmdlet does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------ Example 1: Import aliases from a file ------------</maml:title> <dev:code>Import-Alias test.txt</dev:code> <dev:remarks> <maml:para>This command imports alias information from a file named test.txt.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/import-alias?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Export-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Import-Clixml</command:name> <command:verb>Import</command:verb> <command:noun>Clixml</command:noun> <maml:description> <maml:para>Imports a CLIXML file and creates corresponding objects in PowerShell.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Import-Clixml` cmdlet imports a Common Language Infrastructure (CLI) XML file with data that represents Microsoft .NET Framework objects and creates the PowerShell objects. For more information about CLI, see Language independence (/dotnet/standard/language-independence).</maml:para> <maml:para>A valuable use of `Import-Clixml` on Windows computers is to import credentials and secure strings that were exported as secure XML using `Export-Clixml`. For an example, see Example 2.</maml:para> <maml:para>`Import-Clixml` uses the byte-order-mark (BOM) to detect the encoding format of the file. If the file has no BOM, it assumes the encoding is UTF8.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Import-Clixml</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>First</maml:name> <maml:Description> <maml:para>Gets only the specified number of objects. Enter the number of objects to get.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.UInt64</command:parameterValue> <dev:type> <maml:name>System.UInt64</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>IncludeTotalCount</maml:name> <maml:Description> <maml:para>Reports the total number of objects in the data set followed by the selected objects. If the cmdlet can't determine the total count, it displays Unknown total count . The integer has an Accuracy property that indicates the reliability of the total count value. The value of Accuracy ranges from `0.0` to `1.0` where `0.0` means that the cmdlet couldn't count the objects, `1.0` means that the count is exact, and a value between `0.0` and `1.0` indicates an increasingly reliable estimate.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to the XML files. Unlike Path , the value of the LiteralPath parameter is used exactly as it's typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Skip</maml:name> <maml:Description> <maml:para>Ignores the specified number of objects and then gets the remaining objects. Enter the number of objects to skip.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.UInt64</command:parameterValue> <dev:type> <maml:name>System.UInt64</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Import-Clixml</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the path to the XML files.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>First</maml:name> <maml:Description> <maml:para>Gets only the specified number of objects. Enter the number of objects to get.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.UInt64</command:parameterValue> <dev:type> <maml:name>System.UInt64</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>IncludeTotalCount</maml:name> <maml:Description> <maml:para>Reports the total number of objects in the data set followed by the selected objects. If the cmdlet can't determine the total count, it displays Unknown total count . The integer has an Accuracy property that indicates the reliability of the total count value. The value of Accuracy ranges from `0.0` to `1.0` where `0.0` means that the cmdlet couldn't count the objects, `1.0` means that the count is exact, and a value between `0.0` and `1.0` indicates an increasingly reliable estimate.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Skip</maml:name> <maml:Description> <maml:para>Ignores the specified number of objects and then gets the remaining objects. Enter the number of objects to skip.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.UInt64</command:parameterValue> <dev:type> <maml:name>System.UInt64</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>First</maml:name> <maml:Description> <maml:para>Gets only the specified number of objects. Enter the number of objects to get.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.UInt64</command:parameterValue> <dev:type> <maml:name>System.UInt64</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>IncludeTotalCount</maml:name> <maml:Description> <maml:para>Reports the total number of objects in the data set followed by the selected objects. If the cmdlet can't determine the total count, it displays Unknown total count . The integer has an Accuracy property that indicates the reliability of the total count value. The value of Accuracy ranges from `0.0` to `1.0` where `0.0` means that the cmdlet couldn't count the objects, `1.0` means that the count is exact, and a value between `0.0` and `1.0` indicates an increasingly reliable estimate.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to the XML files. Unlike Path , the value of the LiteralPath parameter is used exactly as it's typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the path to the XML files.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Skip</maml:name> <maml:Description> <maml:para>Ignores the specified number of objects and then gets the remaining objects. Enter the number of objects to skip.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.UInt64</command:parameterValue> <dev:type> <maml:name>System.UInt64</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipeline a string that contains a path to `Import-Clixml`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>PSObject</maml:name> </dev:type> <maml:description> <maml:para>`Import-Clixml` returns objects that were deserialized from the stored XML files.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>When specifying multiple values for a parameter, use commas to separate the values. For example, `<parameter-name> <value1>, <value2>`.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-- Example 1: Import a serialized file and recreate an object --</maml:title> <dev:code>Get-Process | Export-Clixml -Path .\pi.xml $Processes = Import-Clixml -Path .\pi.xml</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 2: Import a secure credential object ---------</maml:title> <dev:code>$Credxmlpath = Join-Path (Split-Path $Profile) TestScript.ps1.credential $Credential | Export-Clixml $Credxmlpath $Credxmlpath = Join-Path (Split-Path $Profile) TestScript.ps1.credential $Credential = Import-Clixml $Credxmlpath</dev:code> <dev:remarks> <maml:para>The `Export-Clixml` cmdlet encrypts credential objects by using the Windows Data Protection API (/previous-versions/windows/apps/hh464970(v=win.10)). The encryption ensures that only your user account can decrypt the contents of the credential object. The exported `CLIXML` file can't be used on a different computer or by a different user.</maml:para> <maml:para>In the example, the file in which the credential is stored is represented by `TestScript.ps1.credential`. Replace TestScript with the name of the script with which you're loading the credential.</maml:para> <maml:para>You send the credential object down the pipeline to `Export-Clixml`, and save it to the path, `$Credxmlpath`, that you specified in the first command.</maml:para> <maml:para>To import the credential automatically into your script, run the final two commands. Run `Import-Clixml` to import the secured credential object into your script. This import eliminates the risk of exposing plain-text passwords in your script.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/import-clixml?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Export-Clixml</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Introducing XML Serialization</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Join-Path</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Securely Store Credentials on Disk</maml:linkText> <maml:uri>https://powershellcookbook.com/recipe/PukO/securely-store-credentials-on-disk</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Use PowerShell to Pass Credentials to Legacy Systems</maml:linkText> <maml:uri>https://devblogs.microsoft.com/scripting/use-powershell-to-pass-credentials-to-legacy-systems/</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Import-Csv</command:name> <command:verb>Import</command:verb> <command:noun>Csv</command:noun> <maml:description> <maml:para>Creates table-like custom objects from the items in a comma-separated value (CSV) file.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Import-Csv` cmdlet creates table-like custom objects from the items in CSV files. Each column in the CSV file becomes a property of the custom object and the items in rows become the property values. `Import-Csv` works on any CSV file, including files that are generated by the `Export-Csv` cmdlet.</maml:para> <maml:para>You can use the parameters of the `Import-Csv` cmdlet to specify the column header row and the item delimiter, or direct `Import-Csv` to use the list separator for the current culture as the item delimiter.</maml:para> <maml:para>You can also use the `ConvertTo-Csv` and `ConvertFrom-Csv` cmdlets to convert objects to CSV strings (and back). These cmdlets are the same as the `Export-CSV` and `Import-Csv` cmdlets, except that they do not deal with files.</maml:para> <maml:para>If a header row entry in a CSV file contains an empty or null value, PowerShell inserts a default header row name and displays a warning message.</maml:para> <maml:para>`Import-Csv` uses the byte-order-mark (BOM) to detect the encoding format of the file. If the file has no BOM, it assumes the encoding is UTF8.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Import-Csv</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the path to the CSV file to import. You can also pipe a path to `Import-Csv`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Delimiter</maml:name> <maml:Description> <maml:para>Specifies the delimiter that separates the property values in the CSV file. The default is a comma (,).</maml:para> <maml:para>Enter a character, such as a colon (:). To specify a semicolon (;) enclose it in single quotation marks.</maml:para> <maml:para>If you specify a character other than the actual string delimiter in the file, `Import-Csv` cannot create the objects from the CSV strings and will return the CSV strings.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Char</command:parameterValue> <dev:type> <maml:name>System.Char</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>comma (,)</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is `Default`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ASCII` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `BigEndianUnicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `Default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `OEM` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `Unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `UTF7` Uses UTF-7.</maml:para> <maml:para>- `UTF8` Uses UTF-8.</maml:para> <maml:para>- `UTF32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">ASCII</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">BigEndianUnicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Default</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OEM</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF7</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF8</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF32</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Default</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Header</maml:name> <maml:Description> <maml:para>Specifies an alternate column header row for the imported file. The column header determines the property names of the objects created by `Import-Csv`.</maml:para> <maml:para>Enter column headers as a comma-separated list. Do not enclose the header string in quotation marks. Enclose each column header in single quotation marks.</maml:para> <maml:para>If you enter fewer column headers than there are data columns, the remaining data columns are discarded. If you enter more column headers than there are data columns, the additional column headers are created with empty data columns.</maml:para> <maml:para>When using the Header parameter, delete the original header row from the CSV file. Otherwise, `Import-Csv` creates an extra object from the items in the header row.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to the CSV file to import. Unlike Path , the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Import-Csv</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the path to the CSV file to import. You can also pipe a path to `Import-Csv`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is `Default`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ASCII` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `BigEndianUnicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `Default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `OEM` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `Unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `UTF7` Uses UTF-7.</maml:para> <maml:para>- `UTF8` Uses UTF-8.</maml:para> <maml:para>- `UTF32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">ASCII</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">BigEndianUnicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Default</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OEM</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF7</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF8</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF32</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Default</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Header</maml:name> <maml:Description> <maml:para>Specifies an alternate column header row for the imported file. The column header determines the property names of the objects created by `Import-Csv`.</maml:para> <maml:para>Enter column headers as a comma-separated list. Do not enclose the header string in quotation marks. Enclose each column header in single quotation marks.</maml:para> <maml:para>If you enter fewer column headers than there are data columns, the remaining data columns are discarded. If you enter more column headers than there are data columns, the additional column headers are created with empty data columns.</maml:para> <maml:para>When using the Header parameter, delete the original header row from the CSV file. Otherwise, `Import-Csv` creates an extra object from the items in the header row.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to the CSV file to import. Unlike Path , the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseCulture</maml:name> <maml:Description> <maml:para>Uses the list separator for the current culture as the item delimiter. To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Delimiter</maml:name> <maml:Description> <maml:para>Specifies the delimiter that separates the property values in the CSV file. The default is a comma (,).</maml:para> <maml:para>Enter a character, such as a colon (:). To specify a semicolon (;) enclose it in single quotation marks.</maml:para> <maml:para>If you specify a character other than the actual string delimiter in the file, `Import-Csv` cannot create the objects from the CSV strings and will return the CSV strings.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Char</command:parameterValue> <dev:type> <maml:name>System.Char</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>comma (,)</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is `Default`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ASCII` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `BigEndianUnicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `Default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `OEM` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `Unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `UTF7` Uses UTF-7.</maml:para> <maml:para>- `UTF8` Uses UTF-8.</maml:para> <maml:para>- `UTF32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Default</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Header</maml:name> <maml:Description> <maml:para>Specifies an alternate column header row for the imported file. The column header determines the property names of the objects created by `Import-Csv`.</maml:para> <maml:para>Enter column headers as a comma-separated list. Do not enclose the header string in quotation marks. Enclose each column header in single quotation marks.</maml:para> <maml:para>If you enter fewer column headers than there are data columns, the remaining data columns are discarded. If you enter more column headers than there are data columns, the additional column headers are created with empty data columns.</maml:para> <maml:para>When using the Header parameter, delete the original header row from the CSV file. Otherwise, `Import-Csv` creates an extra object from the items in the header row.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to the CSV file to import. Unlike Path , the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the path to the CSV file to import. You can also pipe a path to `Import-Csv`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseCulture</maml:name> <maml:Description> <maml:para>Uses the list separator for the current culture as the item delimiter. To find the list separator for a culture, use the following command: `(Get-Culture).TextInfo.ListSeparator`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a string that contains a path to `Import-Csv`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Object</maml:name> </dev:type> <maml:description> <maml:para>This cmdlet returns the objects described by the content in the CSV file.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>Because the imported objects are CSV versions of the object type, they are not recognized and formatted by the PowerShell type formatting entries that format the non-CSV versions of the object type.</maml:para> <maml:para>The result of an `Import-Csv` command is a collection of strings that form a table-like custom object. Each row is a separate string, so you can use the Count property of the object to count the table rows. The columns are the properties of the object and items in the rows are the property values.</maml:para> <maml:para>The column header row determines the number of columns and the column names. The column names are also the names of the properties of the objects. The first row is interpreted to be the column headers, unless you use the Header parameter to specify column headers. If any row has more values than the header row, the additional values are ignored.</maml:para> <maml:para>If the column header row is missing a value or contains a null or empty value, `Import-Csv` uses H followed by a number for the missing column header and property name.</maml:para> <maml:para>In the CSV file, each object is represented by a comma-separated list of the property values of the object. The property values are converted to strings by using the ToString() method of the object, so they are represented by the name of the property value. `Export-Csv` does not export the methods of the object.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------- Example 1: Import process objects --------------</maml:title> <dev:code>Get-Process | Export-Csv -Path .\Processes.csv $P = Import-Csv -Path .\Processes.csv $P | Get-Member TypeName: System.Management.Automation.PSCustomObject Name MemberType Definition ---- ---------- ---------- Equals Method bool Equals(System.Object obj) GetHashCode Method int GetHashCode() GetType Method type GetType() ToString Method string ToString() BasePriority NoteProperty string BasePriority=8 Company NoteProperty string Company=Microsoft Corporation ... $P | Format-Table Name SI Handles VM WS PM NPM Path ---- -- ------- -- -- -- --- ---- ApplicationFrameHost 4 407 2199293489152 15884288 15151104 23792 C:\WINDOWS\system32\ApplicationFrameHost.exe ... wininit 0 157 2199112204288 4591616 1630208 10376 winlogon 4 233 2199125549056 7659520 2826240 10992 C:\WINDOWS\System32\WinLogon.exe WinStore.App 4 846 873435136 33652736 26607616 55432 C:\Program Files\WindowsApps\Microsoft.WindowsStore_11712.1001.13.0_x64__8weky... WmiPrvSE 0 201 2199100219392 8830976 3297280 10632 C:\WINDOWS\system32\wbem\wmiprvse.exe WmiPrvSE 0 407 2199157727232 18509824 12922880 16624 C:\WINDOWS\system32\wbem\wmiprvse.exe WUDFHost 0 834 2199310204928 51945472 87441408 24984 C:\Windows\System32\WUDFHost.exe</dev:code> <dev:remarks> <maml:para>The `Get-Process` cmdlet sends process objects down the pipeline to the `Export-Csv`. The `Export-Csv` cmdlet converts the process objects to CSV strings and saves the strings in the Processes.csv file. The `Import-Csv` cmdlet imports the CSV strings from the Processes.csv file. The strings are saved in the `$P` variable. The `$P` variable is sent down the pipeline to the `Get-Member` cmdlet that displays the properties of the imported CSV strings. The `$P` variable is sent down the pipeline to the `Format-Table` cmdlet and displays the objects.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------------- Example 2: Specify the delimiter ---------------</maml:title> <dev:code>Get-Process | Export-Csv -Path .\Processes.csv -Delimiter : $P = Import-Csv -Path .\Processes.csv -Delimiter : $P | Format-Table</dev:code> <dev:remarks> <maml:para>The `Get-Process` cmdlet sends process objects down the pipeline to `Export-Csv`. The `Export-Csv` cmdlet converts the process objects to CSV strings and saves the strings in the Processes.csv file. The Delimiter parameter is used to specify a colon delimiter. The `Import-Csv` cmdlet imports the CSV strings from the Processes.csv file. The strings are saved in the `$P` variable. To `$P` variable is sent down the pipeline to the `Format-Table` cmdlet.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--- Example 3: Specify the current culture for the delimiter ---</maml:title> <dev:code>(Get-Culture).TextInfo.ListSeparator Get-Process | Export-Csv -Path .\Processes.csv -UseCulture Import-Csv -Path .\Processes.csv -UseCulture</dev:code> <dev:remarks> <maml:para>The `Get-Culture` cmdlet uses the nested properties TextInfo and ListSeparator to get the current culture's default list separator. The `Get-Process` cmdlet sends process objects down the pipeline to `Export-Csv`. The `Export-Csv` cmdlet converts the process objects to CSV strings and saves the strings in the Processes.csv file. The UseCulture parameter uses the current culture's default list separator. The `Import-Csv` cmdlet imports the CSV strings from the Processes.csv file.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 4: Change property names in an imported object ----</maml:title> <dev:code>Start-Job -ScriptBlock { Get-Process } | Export-Csv -Path .\Jobs.csv -NoTypeInformation $Header = 'State', 'MoreData', 'StatusMessage', 'Location', 'Command', 'StateInfo', 'Finished', 'InstanceId', 'Id', 'Name', 'ChildJobs', 'BeginTime', 'EndTime', 'JobType', 'Output', 'Error', 'Progress', 'Verbose', 'Debug', 'Warning', 'Information' # Delete the default header from file $A = Get-Content -Path .\Jobs.csv $A = $A[1..($A.Count - 1)] $A | Out-File -FilePath .\Jobs.csv $J = Import-Csv -Path .\Jobs.csv -Header $Header $J State : Running MoreData : True StatusMessage : Location : localhost Command : Get-Process StateInfo : Running Finished : System.Threading.ManualResetEvent InstanceId : a259eb63-6824-4b97-a033-305108ae1c2e Id : 1 Name : Job1 ChildJobs : System.Collections.Generic.List`1[System.Management.Automation.Job] BeginTime : 12/20/2018 18:59:57 EndTime : JobType : BackgroundJob Output : System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject] Error : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord] Progress : System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord] Verbose : System.Management.Automation.PSDataCollection`1[System.Management.Automation.VerboseRecord] Debug : System.Management.Automation.PSDataCollection`1[System.Management.Automation.DebugRecord] Warning : System.Management.Automation.PSDataCollection`1[System.Management.Automation.WarningRecord] Information : System.Management.Automation.PSDataCollection`1[System.Management.Automation.InformationRecord]</dev:code> <dev:remarks> <maml:para>The `Start-Job` cmdlet starts a background job that runs `Get-Process`. A job object is sent down the pipeline to the `Export-Csv` cmdlet and converted to a CSV string. The NoTypeInformation parameter removes the type information header from CSV output and is optional in PowerShell Core. The `$Header` variable contains a custom header that replaces the following default values: HasMoreData , JobStateInfo , PSBeginTime , PSEndTime , and PSJobTypeName . The `$A` variable uses the `Get-Content` cmdlet to get the CSV string from the Jobs.csv file. The `$A` variable is used to remove the default header from the file. The `Out-File` cmdlet saves the new version of the Jobs.csv file in the `$A` variable. The `Import-Csv` cmdlet imports the Jobs.csv file and uses the Header parameter to apply the `$Header` variable. The `$J` variable contains the imported PSCustomObject and displays the object in the PowerShell console.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 5: Create a custom object using a CSV file ------</maml:title> <dev:code>Get-Content -Path .\Links.csv 113207,about_Aliases 113208,about_Arithmetic_Operators 113209,about_Arrays 113210,about_Assignment_Operators 113212,about_Automatic_Variables 113213,about_Break 113214,about_Command_Precedence 113215,about_Command_Syntax 144309,about_Comment_Based_Help 113216,about_CommonParameters 113217,about_Comparison_Operators 113218,about_Continue 113219,about_Core_Commands 113220,about_Data_Section $A = Import-Csv -Path .\Links.csv -Header 'LinkID', 'TopicTitle' $A | Get-Member TypeName: System.Management.Automation.PSCustomObject Name MemberType Definition ---- ---------- ---------- Equals Method bool Equals(System.Object obj) GetHashCode Method int GetHashCode() GetType Method type GetType() ToString Method string ToString() LinkID NoteProperty string LinkID=113207 TopicTitle NoteProperty string TopicTitle=about_Aliases $A | Where-Object -Property TopicTitle -Like '*alias*' LinkID TopicTitle ------ ---------- 113207 about_Aliases</dev:code> <dev:remarks> <maml:para>To create your Links.csv file, use the values shown in the `Get-Content` output.</maml:para> <maml:para>The `Get-Content` cmdlet displays the Links.csv file. The `Import-Csv` cmdlet imports the Links.csv file. The Header parameter specifies the property names LinkId and TopicTitle . The objects are stored in the `$A` variable. The `Get-Member` cmdlet shows the property names from the Header parameter. The `Where-Object` cmdlet selects objects with the TopicTitle property that includes alias .</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 6: Import a CSV that is missing a value -------</maml:title> <dev:code>Get-Content -Path .\Projects.csv ProjectID,ProjectName,,Completed 13,Inventory,Redmond,True 440,,FarEast,True 469,Marketing,Europe,False Import-Csv -Path .\Projects.csv WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. ProjectID ProjectName H1 Completed --------- ----------- -- --------- 13 Inventory Redmond True 440 FarEast True 469 Marketing Europe False (Import-Csv -Path .\Projects.csv).H1 WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers. Redmond FarEast Europe</dev:code> <dev:remarks> <maml:para>To create your Projects.csv file, use the values shown in the example's `Get-Content` output.</maml:para> <maml:para>The `Get-Content` cmdlet displays the Projects.csv file. The header row is missing a value between ProjectName and Completed . The `Import-Csv` cmdlet imports the Projects.csv file and displays a warning message because H1 is a default header name. The `(Import-Csv -Path .\Projects.csv).H1` command gets the H1 property values and displays a warning.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/import-csv?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertFrom-Csv</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-Csv</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Export-Csv</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Culture</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Import-LocalizedData</command:name> <command:verb>Import</command:verb> <command:noun>LocalizedData</command:noun> <maml:description> <maml:para>Imports language-specific data into scripts and functions based on the UI culture that is selected for the operating system.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Import-LocalizedData cmdlet dynamically retrieves strings from a subdirectory whose name matches the UI language set for the current user of the operating system. It is designed to enable scripts to display user messages in the UI language selected by the current user. Import-LocalizedData imports data from .psd1 files in language-specific subdirectories of the script directory and saves them in a local variable that is specified in the command. The cmdlet selects the subdirectory and file based on the value of the $PSUICulture automatic variable. When you use the local variable in the script to display a user message, the message appears in the user's UI language.</maml:para> <maml:para>You can use the parameters of Import-LocalizedData to specify an alternate UI culture, path, and file name, to add supported commands, and to suppress the error message that appears if the .psd1 files are not found.</maml:para> <maml:para>The Import-LocalizedData cmdlet supports the script internationalization initiative that was introduced in Windows PowerShell 2.0. This initiative aims to better serve users worldwide by making it easy for scripts to display user messages in the UI language of the current user. For more information about this and about the format of the .psd1 files, see about_Script_Internationalization.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Import-LocalizedData</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="Variable"> <maml:name>BindingVariable</maml:name> <maml:Description> <maml:para>Specifies the variable into which the text strings are imported. Enter a variable name without a dollar sign ($).</maml:para> <maml:para>In Windows PowerShell 2.0, this parameter is required. In Windows PowerShell 3.0, this parameter is optional. If you omit this parameter, Import-LocalizedData returns a hash table of the text strings. The hash table is passed down the pipeline or displayed at the command line.</maml:para> <maml:para>When using Import-LocalizedData to replace default text strings specified in the DATA section of a script, assign the DATA section to a variable and enter the name of the DATA section variable in the value of the BindingVariable parameter. Then, when Import-LocalizedData saves the imported content in the BindingVariable , the imported data will replace the default text strings. If you are not specifying default text strings, you can select any variable name.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>UICulture</maml:name> <maml:Description> <maml:para>Specifies an alternate UI culture. The default is the value of the $PsUICulture automatic variable. Enter a UI culture in <language>-<region> format, such as en-US, de-DE, or ar-SA.</maml:para> <maml:para>The value of the UICulture parameter determines the language-specific subdirectory (within the base directory) from which Import-LocalizedData gets the .psd1 file for the script.</maml:para> <maml:para>The cmdlet searches for a subdirectory with the same name as the value of the UICulture parameter or the $PsUICulture automatic variable, such as de-DE or ar-SA. If it cannot find the directory, or the directory does not contain a .psd1 file for the script, it searches for a subdirectory with the name of the language code, such as de or ar. If it cannot find the subdirectory or .psd1 file, the command fails and the data is displayed in the default language specified in the script.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>BaseDirectory</maml:name> <maml:Description> <maml:para>Specifies the base directory where the .psd1 files are located. The default is the directory where the script is located. Import-LocalizedData searches for the .psd1 file for the script in a language-specific subdirectory of the base directory.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>FileName</maml:name> <maml:Description> <maml:para>Specifies the name of the data file (.psd1) to be imported. Enter a file name. You can specify a file name that does not include its .psd1 file name extension, or you can specify the file name including the .psd1 file name extension. Data files should be saved as Unicode or UTF-8.</maml:para> <maml:para>The FileName parameter is required when Import-LocalizedData is not used in a script. Otherwise, the parameter is optional and the default value is the base name of the script. You can use this parameter to direct Import-LocalizedData to search for a different .psd1 file.</maml:para> <maml:para>For example, if the FileName is omitted and the script name is FindFiles.ps1, Import-LocalizedData searches for the FindFiles.psd1 data file.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SupportedCommand</maml:name> <maml:Description> <maml:para>Specifies cmdlets and functions that generate only data.</maml:para> <maml:para>Use this parameter to include cmdlets and functions that you have written or tested. For more information, see about_Script_Internationalization.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>BaseDirectory</maml:name> <maml:Description> <maml:para>Specifies the base directory where the .psd1 files are located. The default is the directory where the script is located. Import-LocalizedData searches for the .psd1 file for the script in a language-specific subdirectory of the base directory.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="Variable"> <maml:name>BindingVariable</maml:name> <maml:Description> <maml:para>Specifies the variable into which the text strings are imported. Enter a variable name without a dollar sign ($).</maml:para> <maml:para>In Windows PowerShell 2.0, this parameter is required. In Windows PowerShell 3.0, this parameter is optional. If you omit this parameter, Import-LocalizedData returns a hash table of the text strings. The hash table is passed down the pipeline or displayed at the command line.</maml:para> <maml:para>When using Import-LocalizedData to replace default text strings specified in the DATA section of a script, assign the DATA section to a variable and enter the name of the DATA section variable in the value of the BindingVariable parameter. Then, when Import-LocalizedData saves the imported content in the BindingVariable , the imported data will replace the default text strings. If you are not specifying default text strings, you can select any variable name.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>FileName</maml:name> <maml:Description> <maml:para>Specifies the name of the data file (.psd1) to be imported. Enter a file name. You can specify a file name that does not include its .psd1 file name extension, or you can specify the file name including the .psd1 file name extension. Data files should be saved as Unicode or UTF-8.</maml:para> <maml:para>The FileName parameter is required when Import-LocalizedData is not used in a script. Otherwise, the parameter is optional and the default value is the base name of the script. You can use this parameter to direct Import-LocalizedData to search for a different .psd1 file.</maml:para> <maml:para>For example, if the FileName is omitted and the script name is FindFiles.ps1, Import-LocalizedData searches for the FindFiles.psd1 data file.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SupportedCommand</maml:name> <maml:Description> <maml:para>Specifies cmdlets and functions that generate only data.</maml:para> <maml:para>Use this parameter to include cmdlets and functions that you have written or tested. For more information, see about_Script_Internationalization.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>UICulture</maml:name> <maml:Description> <maml:para>Specifies an alternate UI culture. The default is the value of the $PsUICulture automatic variable. Enter a UI culture in <language>-<region> format, such as en-US, de-DE, or ar-SA.</maml:para> <maml:para>The value of the UICulture parameter determines the language-specific subdirectory (within the base directory) from which Import-LocalizedData gets the .psd1 file for the script.</maml:para> <maml:para>The cmdlet searches for a subdirectory with the same name as the value of the UICulture parameter or the $PsUICulture automatic variable, such as de-DE or ar-SA. If it cannot find the directory, or the directory does not contain a .psd1 file for the script, it searches for a subdirectory with the name of the language code, such as de or ar. If it cannot find the subdirectory or .psd1 file, the command fails and the data is displayed in the default language specified in the script.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe input to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Collections.Hashtable</maml:name> </dev:type> <maml:description> <maml:para>Import-LocalizedData saves the hash table in the variable that is specified by the value of the BindingVariable parameter.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>Before using Import-LocalizedData *, localize your user messages. Format the messages for each locale (UI culture) in a hash table of key/value pairs, and save the hash table in a file with the same name as the script and a .psd1 file name extension. Create a directory under the script directory for each supported UI culture, and then save the .psd1 file for each UI culture in the directory with the UI culture name.</maml:para> <maml:para> For example, localize your user messages for the de-DE locale and format them in a hash table. Save the hash table in a <ScriptName>.psd1 file. Then create a de-DE subdirectory under the script directory, and save the de-DE <ScriptName>.psd1 file in the de-DE subdirectory. Repeat this method for each locale that you support. Import-LocalizedData * performs a structured search for the localized user messages for a script. Import-LocalizedData begins the search in the directory where the script file is located (or the value of the BaseDirectory parameter). It then searches within the base directory for a subdirectory with the same name as the value of the $PsUICulture variable (or the value of the UICulture parameter), such as de-DE or ar-SA. Then, it searches in that subdirectory for a .psd1 file with the same name as the script (or the value of the FileName parameter).</maml:para> <maml:para> If Import-LocalizedData cannot find a subdirectory with the name of the UI culture, or the subdirectory does not contain a .psd1 file for the script, it searches for a .psd1 file for the script in a subdirectory with the name of the language code, such as de or ar. If it cannot find the subdirectory or .psd1 file, the command fails, the data is displayed in the default language in the script, and an error message is displayed explaining that the data could not be imported. To suppress the message and fail gracefully, use the ErrorAction common parameter with a value of SilentlyContinue.</maml:para> <maml:para> If Import-LocalizedData finds the subdirectory and the .psd1 file, it imports the hash table of user messages into the value of the BindingVariable parameter in the command. Then, when you display a message from the hash table in the variable, the localized message is displayed.</maml:para> <maml:para> For more information, see about_Script_Internationalization (https://go.microsoft.com/fwlink/?LinkID=113262).</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>---------------- Example 1: Import text strings ----------------</maml:title> <dev:code>PS C:\> Import-LocalizedData -BindingVariable "Messages"</dev:code> <dev:remarks> <maml:para>This command imports text strings into the $Messages variable. It uses the default values of all other cmdlet parameters.</maml:para> <maml:para>If the command is included in the Archives.ps1 script in the C:\Test directory, and the value of the $PsUICulture automatic variable is zh-CN, Import-LocalizedData imports the Archives.psd1 file in the C:\test\zh-CN directory into the $Messages variable.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 2: Import localized data strings -----------</maml:title> <dev:code>PS C:\> Import-LocalizedData -FileName "Test.psd1" -UICulture "en-US" Name Value ---- ----- Msg3 "Use $_ to represent the object that is being processed." Msg2 "This command requires the credentials of a member of the Administrators group on the... Msg1 "The Name parameter is missing from the command."</dev:code> <dev:remarks> <maml:para>This command is run at the command line; not in a script. It gets localized data strings from the Test.psd1 file and displays them at the command line. Because the command is not used in a script, the FileName parameter is required. The command uses the UICulture parameter to specify the en-US culture. Import-LocalizedData returns a hash table that contains the localized data strings.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------- Example 3: Import UI culture strings -------------</maml:title> <dev:code>PS C:\> Import-LocalizedData -BindingVariable "MsgTbl" -UICulture "ar-SA" -FileName "Simple" -BaseDirectory "C:\Data\Localized"</dev:code> <dev:remarks> <maml:para>This command imports text strings into the $MsgTbl variable of a script.</maml:para> <maml:para>It uses the UICulture parameter to direct the cmdlet to import data from the Simple.psd1 file in the ar-SA subdirectory of C:\Data\Localized.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 4: Import localized data into a script --------</maml:title> <dev:code>PS C:\> # In C:\Test\en-US\Test.psd1: ConvertFrom-StringData @' # English strings Msg1 = "The Name parameter is missing from the command." Msg2 = "This command requires the credentials of a member of the Administrators group on the computer." Msg3 = "Use $_ to represent the object that is being processed." '@ # In C:\Test\Test.ps1 Import-LocalizedData -BindingVariable "Messages" Write-Host $Messages.Msg2 # In Windows PowerShell PS C:\> .\Test.ps1 This command requires the credentials of a member of the Administrators group on the computer.</dev:code> <dev:remarks> <maml:para>This example shows how to use localized data in a simple script.</maml:para> <maml:para>The first part of the example shows the contents of the Test.psd1 file. It contains a ConvertFrom-StringData command that converts a series of named text strings into a hash table. The Test.psd1 file is located in the en-US subdirectory of the C:\Test directory that contains the script.</maml:para> <maml:para>The second part of the example shows the contents of the Test.ps1 script. It contains an Import-LocalizedData command that imports the data from the matching .psd1 file into the $Messages variable and a Write-Host command that writes one of the messages in the $Messages variable to the host program.</maml:para> <maml:para>The last part of the example runs the script. The output shows that it displays the correct user message in the UI language set for the current user of the operating system.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 5: Replace default text strings in a script -----</maml:title> <dev:code>PS C:\> # In TestScript.ps1 $UserMessages = DATA { ConvertFrom-StringData @' # English strings Msg1 = "Enter a name." Msg2 = "Enter your employee ID." Msg3 = "Enter your building number." '@ } Import-LocalizedData -BindingVariable "UserMessages" $UserMessages.Msg1...</dev:code> <dev:remarks> <maml:para>This example shows how to use Import-LocalizedData to replace default text strings defined in the DATA section of a script.</maml:para> <maml:para>In this example, the DATA section of the TestScript.ps1 script contains a ConvertFrom-StringData command that converts the contents of the DATA section to a hash table and stores in the value of the $UserMessages variable.</maml:para> <maml:para>The script also includes an Import-LocalizedData command, which imports a hash table of translated text strings from the TestScript.psd1 file in the subdirectory specified by the value of the $PsUICulture variable. If the command finds the .psd1 file, it saves the translated strings from the file in the value of the same $UserMessages variable, overwriting the hash table saved by the DATA section logic.</maml:para> <maml:para>The third command displays the first message in the $UserMessages variable.</maml:para> <maml:para>If the Import-LocalizedData command finds a .psd1 file for the $PsUICulture language, the value of the $UserMessages variable contains the translated text strings. If the command fails for any reason, the command displays the default text strings defined in the DATA section of the script.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 6: Suppress error messages if the UI culture is not found</maml:title> <dev:code>PS C:\> # In Day1.ps1 Import-LocalizedData -BindingVariable "Day" # In Day2.ps1 Import-LocalizedData -BindingVariable "Day" -ErrorAction:SilentlyContinue PS C:\> .\Day1.ps1 Import-LocalizedData : Cannot find PowerShell data file 'Day1.psd1' in directory 'C:\ps-test\fr-BE\' or any parent culture directories. At C:\ps-test\Day1.ps1:17 char:21+ Import-LocalizedData <<<< Day Today is Tuesday PS C:\> .\Day2.ps1 Today is Tuesday</dev:code> <dev:remarks> <maml:para>This example shows how to suppress the error messages that appear when Import-LocalizedData cannot find the directories that match the user's UI culture or cannot find a .psd1 file for the script in those directories.</maml:para> <maml:para>You can use the ErrorAction common parameter with a value of SilentlyContinue to suppress the error message. This is especially useful when you have provided user messages in a default or fallback language, and no error message is needed.</maml:para> <maml:para>This example compares two scripts, Day1.ps1 and Day2.ps1, that include an Import-LocalizedData command. The scripts are identical, except that Day2 uses the ErrorAction common parameter with a value of SilentlyContinue.</maml:para> <maml:para>The sample output shows the results of running both scripts when the UI culture is set to fr-BE and there are no matching files or directories for that UI culture. Day1.ps1 displays an error message and English output. Day2.ps1 just displays the English output.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/import-localizeddata?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Import-PowerShellDataFile</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Import-PSSession</command:name> <command:verb>Import</command:verb> <command:noun>PSSession</command:noun> <maml:description> <maml:para>Imports commands from another session into the current session.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Import-PSSession cmdlet imports commands , such as cmdlets, functions, and aliases, from a PSSession on a local or remote computer into the current session. You can import any command that the Get-Command cmdlet can find in the PSSession.</maml:para> <maml:para>Use an Import-PSSession command to import commands from a customized shell, such as a Microsoft Exchange Server shell, or from a session that includes Windows PowerShell modules and snap-ins or other elements that are not in the current session.</maml:para> <maml:para>To import commands, first use the New-PSSession cmdlet to create a PSSession. Then, use the Import-PSSession cmdlet to import the commands. By default, Import-PSSession imports all commands except for commands that have the same names as commands in the current session. To import all the commands, use the AllowClobber parameter.</maml:para> <maml:para>You can use imported commands just as you would use any command in the session. When you use an imported command, the imported part of the command runs implicitly in the session from which it was imported. However, the remote operations are handled entirely by Windows PowerShell. You need not even be aware of them, except that you must keep the connection to the other session (PSSession) open. If you close it, the imported commands are no longer available.</maml:para> <maml:para>Because imported commands might take longer to run than local commands, Import-PSSession adds an AsJob parameter to every imported command. This parameter allows you to run the command as a Windows PowerShell background job. For more information, see about_Jobs.</maml:para> <maml:para>When you use Import-PSSession , Windows PowerShell adds the imported commands to a temporary module that exists only in your session and returns an object that represents the module. To create a persistent module that you can use in future sessions, use the Export-PSSession cmdlet.</maml:para> <maml:para>The Import-PSSession cmdlet uses the implicit remoting feature of Windows PowerShell. When you import commands into the current session, they run implicitly in the original session or in a similar session on the originating computer.</maml:para> <maml:para>Beginning in Windows PowerShell 3.0, you can use the Import-Module cmdlet to import modules from a remote session into the current session. This feature uses implicit remoting. It is equivalent to using Import-PSSession to import selected modules from a remote session into the current session.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Import-PSSession</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Session</maml:name> <maml:Description> <maml:para>Specifies the PSSession from which the cmdlets are imported. Enter a variable that contains a session object or a command that gets a session object, such as a New-PSSession or Get-PSSession command. You can specify only one session. This parameter is required.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Runspaces.PSSession</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.PSSession</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="Name"> <maml:name>CommandName</maml:name> <maml:Description> <maml:para>Specifies commands with the specified names or name patterns. Wildcards are permitted. Use CommandName or its alias, Name .</maml:para> <maml:para>By default, Import-PSSession imports all commands from the session, except for commands that have the same names as commands in the current session. This prevents imported commands from hiding or replacing commands in the session. To import all commands, even those that hide or replace other commands, use the AllowClobber parameter.</maml:para> <maml:para>If you use the CommandName parameter, the formatting files for the commands are not imported unless you use the FormatTypeName parameter. Similarly, if you use the FormatTypeName parameter, no commands are imported unless you use the CommandName parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="3" aliases="none"> <maml:name>FormatTypeName</maml:name> <maml:Description> <maml:para>Specifies formatting instructions for the specified Microsoft .NET Framework types. Enter the type names. Wildcards are permitted.</maml:para> <maml:para>The value of this parameter must be the name of a type that is returned by a Get-FormatData command in the session from which the commands are being imported. To get all of the formatting data in the remote session, type *.</maml:para> <maml:para>If the command does not include either the CommandName or FormatTypeName parameter, Import-PSSession imports formatting instructions for all .NET Framework types returned by a Get-FormatData command in the remote session.</maml:para> <maml:para>If you use the FormatTypeName parameter, no commands are imported unless you use the CommandName parameter.</maml:para> <maml:para>Similarly, if you use the CommandName parameter, the formatting files for the commands are not imported unless you use the FormatTypeName parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AllowClobber</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet imports the specified commands, even if they have the same names as commands in the current session.</maml:para> <maml:para>If you import a command with the same name as a command in the current session, the imported command hides or replaces the original commands. For more information, see about_Command_Precedence.</maml:para> <maml:para>By default, Import-PSSession does not import commands that have the same name as commands in the current session.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Args"> <maml:name>ArgumentList</maml:name> <maml:Description> <maml:para>Specifies an array of commands that results from using the specified arguments (parameter values).</maml:para> <maml:para>For instance, to import the variant of the Get-Item command in the certificate (Cert:) drive in the PSSession in $S, type `Import-PSSession -Session $S -Command Get-Item -ArgumentList cert:`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Certificate</maml:name> <maml:Description> <maml:para>Specifies the client certificate that is used to sign the format files ( .Format.ps1xml) or script module files (.psm1) in the temporary module that Import-PSSession * creates.</maml:para> <maml:para>Enter a variable that contains a certificate or a command or expression that gets the certificate.</maml:para> <maml:para>To find a certificate, use the Get-PfxCertificate cmdlet or use the Get-ChildItem cmdlet in the Certificate (Cert:) drive. If the certificate is not valid or does not have sufficient authority, the command fails.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Security.Cryptography.X509Certificates.X509Certificate2</command:parameterValue> <dev:type> <maml:name>System.Security.Cryptography.X509Certificates.X509Certificate2</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Type"> <maml:name>CommandType</maml:name> <maml:Description> <maml:para>Specifies the type of command objects. The default value is Cmdlet. Use CommandType or its alias, Type . The acceptable values for this parameter are:</maml:para> <maml:para>- Alias. The Windows PowerShell aliases in the remote session. - All. The cmdlets and functions in the remote session. - Application. All the files other than Windows-PowerShell files in the paths that are listed in the Path environment variable ($env:path) in the remote session, including .txt, .exe, and .dll files. - Cmdlet. The cmdlets in the remote session. "Cmdlet" is the default. - ExternalScript. The .ps1 files in the paths listed in the Path environment variable ($env:path) in the remote session. - Filter and Function. The Windows PowerShell functions in the remote session. - Script. The script blocks in the remote session.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Alias</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Function</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Filter</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Cmdlet</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ExternalScript</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Application</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Script</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Workflow</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Configuration</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">All</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.CommandTypes</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.CommandTypes</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisableNameChecking</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet suppresses the message that warns you when you import a cmdlet or function whose name includes an unapproved verb or a prohibited character.</maml:para> <maml:para>By default, when a module that you import exports cmdlets or functions that have unapproved verbs in their names, the Windows PowerShell displays the following warning message:</maml:para> <maml:para>"WARNING: Some imported command names include unapproved verbs which might make them less discoverable. Use the Verbose parameter for more detail or type Get-Verb to see the list of approved verbs."</maml:para> <maml:para>This message is only a warning. The complete module is still imported, including the non-conforming commands. Although the message is displayed to module users, the naming problem should be fixed by the module author.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>FullyQualifiedModule</maml:name> <maml:Description> <maml:para>Specifies modules with names that are specified in the form of ModuleSpecification objects (described in the Remarks section of ModuleSpecification Constructor (Hashtable) (https://msdn.microsoft.com/library/jj136290) in the MSDN library). For example, the FullyQualifiedModule parameter accepts a module name that is specified in the format @{ModuleName = "modulename"; ModuleVersion = "version_number"} or @{ModuleName = "modulename"; ModuleVersion = "version_number"; Guid = "GUID"}. ModuleName and ModuleVersion are required, but Guid is optional.</maml:para> <maml:para>You cannot specify the FullyQualifiedModule parameter in the same command as a Module parameter; the two parameters are mutually exclusive.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.ModuleSpecification[]</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.ModuleSpecification[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSSnapin"> <maml:name>Module</maml:name> <maml:Description> <maml:para>Specifies and array of commands in the Windows PowerShell snap-ins and modules. Enter the snap-in and module names. Wildcards are not permitted. Import-PSSession cannot import providers from a snap-in.</maml:para> <maml:para>For more information, see about_PSSnapins and about_Modules (../Microsoft.PowerShell.Core/About/about_Modules.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Prefix</maml:name> <maml:Description> <maml:para>Specifies a prefix to the nouns in the names of imported commands.</maml:para> <maml:para>Use this parameter to avoid name conflicts that might occur when different commands in the session have the same name.</maml:para> <maml:para>For instance, if you specify the prefix Remote and then import a Get-Date cmdlet, the cmdlet is known in the session as Get-RemoteDate, and it is not confused with the original Get-Date cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AllowClobber</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet imports the specified commands, even if they have the same names as commands in the current session.</maml:para> <maml:para>If you import a command with the same name as a command in the current session, the imported command hides or replaces the original commands. For more information, see about_Command_Precedence.</maml:para> <maml:para>By default, Import-PSSession does not import commands that have the same name as commands in the current session.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Args"> <maml:name>ArgumentList</maml:name> <maml:Description> <maml:para>Specifies an array of commands that results from using the specified arguments (parameter values).</maml:para> <maml:para>For instance, to import the variant of the Get-Item command in the certificate (Cert:) drive in the PSSession in $S, type `Import-PSSession -Session $S -Command Get-Item -ArgumentList cert:`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Certificate</maml:name> <maml:Description> <maml:para>Specifies the client certificate that is used to sign the format files ( .Format.ps1xml) or script module files (.psm1) in the temporary module that Import-PSSession * creates.</maml:para> <maml:para>Enter a variable that contains a certificate or a command or expression that gets the certificate.</maml:para> <maml:para>To find a certificate, use the Get-PfxCertificate cmdlet or use the Get-ChildItem cmdlet in the Certificate (Cert:) drive. If the certificate is not valid or does not have sufficient authority, the command fails.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Security.Cryptography.X509Certificates.X509Certificate2</command:parameterValue> <dev:type> <maml:name>System.Security.Cryptography.X509Certificates.X509Certificate2</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="Name"> <maml:name>CommandName</maml:name> <maml:Description> <maml:para>Specifies commands with the specified names or name patterns. Wildcards are permitted. Use CommandName or its alias, Name .</maml:para> <maml:para>By default, Import-PSSession imports all commands from the session, except for commands that have the same names as commands in the current session. This prevents imported commands from hiding or replacing commands in the session. To import all commands, even those that hide or replace other commands, use the AllowClobber parameter.</maml:para> <maml:para>If you use the CommandName parameter, the formatting files for the commands are not imported unless you use the FormatTypeName parameter. Similarly, if you use the FormatTypeName parameter, no commands are imported unless you use the CommandName parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Type"> <maml:name>CommandType</maml:name> <maml:Description> <maml:para>Specifies the type of command objects. The default value is Cmdlet. Use CommandType or its alias, Type . The acceptable values for this parameter are:</maml:para> <maml:para>- Alias. The Windows PowerShell aliases in the remote session. - All. The cmdlets and functions in the remote session. - Application. All the files other than Windows-PowerShell files in the paths that are listed in the Path environment variable ($env:path) in the remote session, including .txt, .exe, and .dll files. - Cmdlet. The cmdlets in the remote session. "Cmdlet" is the default. - ExternalScript. The .ps1 files in the paths listed in the Path environment variable ($env:path) in the remote session. - Filter and Function. The Windows PowerShell functions in the remote session. - Script. The script blocks in the remote session.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.CommandTypes</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.CommandTypes</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisableNameChecking</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet suppresses the message that warns you when you import a cmdlet or function whose name includes an unapproved verb or a prohibited character.</maml:para> <maml:para>By default, when a module that you import exports cmdlets or functions that have unapproved verbs in their names, the Windows PowerShell displays the following warning message:</maml:para> <maml:para>"WARNING: Some imported command names include unapproved verbs which might make them less discoverable. Use the Verbose parameter for more detail or type Get-Verb to see the list of approved verbs."</maml:para> <maml:para>This message is only a warning. The complete module is still imported, including the non-conforming commands. Although the message is displayed to module users, the naming problem should be fixed by the module author.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="3" aliases="none"> <maml:name>FormatTypeName</maml:name> <maml:Description> <maml:para>Specifies formatting instructions for the specified Microsoft .NET Framework types. Enter the type names. Wildcards are permitted.</maml:para> <maml:para>The value of this parameter must be the name of a type that is returned by a Get-FormatData command in the session from which the commands are being imported. To get all of the formatting data in the remote session, type *.</maml:para> <maml:para>If the command does not include either the CommandName or FormatTypeName parameter, Import-PSSession imports formatting instructions for all .NET Framework types returned by a Get-FormatData command in the remote session.</maml:para> <maml:para>If you use the FormatTypeName parameter, no commands are imported unless you use the CommandName parameter.</maml:para> <maml:para>Similarly, if you use the CommandName parameter, the formatting files for the commands are not imported unless you use the FormatTypeName parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>FullyQualifiedModule</maml:name> <maml:Description> <maml:para>Specifies modules with names that are specified in the form of ModuleSpecification objects (described in the Remarks section of ModuleSpecification Constructor (Hashtable) (https://msdn.microsoft.com/library/jj136290) in the MSDN library). For example, the FullyQualifiedModule parameter accepts a module name that is specified in the format @{ModuleName = "modulename"; ModuleVersion = "version_number"} or @{ModuleName = "modulename"; ModuleVersion = "version_number"; Guid = "GUID"}. ModuleName and ModuleVersion are required, but Guid is optional.</maml:para> <maml:para>You cannot specify the FullyQualifiedModule parameter in the same command as a Module parameter; the two parameters are mutually exclusive.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.ModuleSpecification[]</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.ModuleSpecification[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSSnapin"> <maml:name>Module</maml:name> <maml:Description> <maml:para>Specifies and array of commands in the Windows PowerShell snap-ins and modules. Enter the snap-in and module names. Wildcards are not permitted. Import-PSSession cannot import providers from a snap-in.</maml:para> <maml:para>For more information, see about_PSSnapins and about_Modules (../Microsoft.PowerShell.Core/About/about_Modules.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Prefix</maml:name> <maml:Description> <maml:para>Specifies a prefix to the nouns in the names of imported commands.</maml:para> <maml:para>Use this parameter to avoid name conflicts that might occur when different commands in the session have the same name.</maml:para> <maml:para>For instance, if you specify the prefix Remote and then import a Get-Date cmdlet, the cmdlet is known in the session as Get-RemoteDate, and it is not confused with the original Get-Date cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Session</maml:name> <maml:Description> <maml:para>Specifies the PSSession from which the cmdlets are imported. Enter a variable that contains a session object or a command that gets a session object, such as a New-PSSession or Get-PSSession command. You can specify only one session. This parameter is required.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Runspaces.PSSession</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.PSSession</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe objects to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.PSModuleInfo</maml:name> </dev:type> <maml:description> <maml:para>Import-PSSession returns the same module object that New-Module and Get-Module cmdlets return. However, the imported module is temporary and exists only in the current session. To create a permanent module on disk, use the Export-PSSession cmdlet.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para> Import-PSSession * relies on the Windows PowerShell remoting infrastructure. To use this cmdlet, the computer must be configured for WS-Management remoting. For more information, see about_Remote and about_Remote_Requirements. Import-PSSession * does not import variables or Windows PowerShell providers. When you import commands that have the same names as commands in the current session, the imported commands can hide aliases, functions, and cmdlets in the session and they can replace functions and variables in the session. To prevent name conflicts, use the Prefix* parameter. For more information, see about_Command_Precedence. Import-PSSession * converts all commands into functions before it imports them. As a result, imported commands behave a bit differently than they would if they retained their original command type. For example, if you import a cmdlet from a PSSession and then import a cmdlet with the same name from a module or snap-in, the cmdlet that is imported from the PSSession always runs by default because functions take precedence over cmdlets. Conversely, if you import an alias into a session that has an alias with the same name, the original alias is always used, because aliases take precedence over functions. For more information, see about_Command_Precedence. Import-PSSession * uses the Write-Progress cmdlet to display the progress of the command. You might see the progress bar while the command is running. To find the commands to import, Import-PSSession uses the Invoke-Command cmdlet to run a Get-Command command in the PSSession. To get formatting data for the commands, it uses the Get-FormatData cmdlet. You might see error messages from these cmdlets when you run an Import-PSSession command. Also, Import-PSSession * cannot import commands from a PSSession that does not include the Get-Command, Get-FormatData, Select-Object, and Get-Help cmdlets.</maml:para> <maml:para>* Imported commands have the same limitations as other remote commands, including the inability to start a program with a user interface, such as Notepad. Because Windows PowerShell profiles are not run in PSSessions, the commands that a profile adds to a session are not available to Import-PSSession *. To import commands from a profile, use an Invoke-Command command to run the profile in the PSSession manually before importing commands. The temporary module that Import-PSSession * creates might include a formatting file, even if the command does not import formatting data. If the command does not import formatting data, any formatting files that are created will not contain formatting data. To use Import-PSSession , the execution policy in the current session cannot be Restricted or AllSigned, because the temporary module that Import-PSSession creates contains unsigned script files that are prohibited by these policies. To use Import-PSSession without changing the execution policy for the local computer, use the Scope* parameter of Set-ExecutionPolicy to set a less restrictive execution policy for a single process. In Windows PowerShell 2.0, help topics for commands that are imported from another session do not include the prefix that you assign by using the Prefix* parameter. To get help for an imported command in Windows PowerShell 2.0, use the original (non-prefixed) command name.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------- Example 1: Import all commands from a PSSession -------</maml:title> <dev:code>PS C:\> $S = New-PSSession -ComputerName Server01 PS C:\> Import-PSSession -Session $S</dev:code> <dev:remarks> <maml:para>This command imports all commands from a PSSession on the Server01 computer into the current session, except for commands that have the same names as commands in the current session.</maml:para> <maml:para>Because this command does not use the CommandName parameter, it also imports all of the formatting data required for the imported commands.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 2: Import commands that end with a specific string --</maml:title> <dev:code>PS C:\> $S = New-PSSession https://ps.testlabs.com/powershell PS C:\> Import-PSSession -Session $S -CommandName *-test -FormatTypeName * PS C:\> New-Test -Name Test1 PS C:\> Get-Test test1 | Run-Test</dev:code> <dev:remarks> <maml:para>These commands import the commands with names that end in "-test" from a PSSession into the local session, and then they show how to use an imported cmdlet.</maml:para> <maml:para>The first command uses the New-PSSession cmdlet to create a PSSession. It saves the PSSession in the $S variable.</maml:para> <maml:para>The second command uses the Import-PSSession cmdlet to import commands from the PSSession in $S into the current session. It uses the CommandName parameter to specify commands with the Test noun and the FormatTypeName parameter to import the formatting data for the Test commands.</maml:para> <maml:para>The third and fourth commands use the imported commands in the current session. Because imported commands are actually added to the current session, you use the local syntax to run them. You do not need to use the Invoke-Command cmdlet to run an imported command.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 3: Import cmdlets from a PSSession ----------</maml:title> <dev:code>PS C:\> $S1 = New-PSSession -ComputerName s1 PS C:\> $S2 = New-PSSession -ComputerName s2 PS C:\> Import-PSSession -Session s1 -Type cmdlet -Name New-Test, Get-Test -FormatTypeName * PS C:\> Import-PSSession -Session s2 -Type Cmdlet -Name Set-Test -FormatTypeName * PS C:\> New-Test Test1 | Set-Test -RunType Full</dev:code> <dev:remarks> <maml:para>This example shows that you can use imported cmdlets just as you would use local cmdlets.</maml:para> <maml:para>These commands import the New-Test and Get-Test cmdlets from a PSSession on the Server01 computer and the Set-Test cmdlet from a PSSession on the Server02 computer.</maml:para> <maml:para>Even though the cmdlets were imported from different PSSessions, you can pipe an object from one cmdlet to another without error.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 4: Run an imported command as a background job ----</maml:title> <dev:code>PS C:\> $S = New-PSSession -ComputerName Server01 PS C:\> Import-PSSession -Session $S -CommandName *-test* -FormatTypeName * PS C:\> $batch = New-Test -Name Batch -AsJob PS C:\> Receive-Job $batch</dev:code> <dev:remarks> <maml:para>This example shows how to run an imported command as a background job.</maml:para> <maml:para>Because imported commands might take longer to run than local commands, Import-PSSession adds an AsJob parameter to every imported command. The AsJob parameter lets you run the command as a background job.</maml:para> <maml:para>The first command creates a PSSession on the Server01 computer and saves the PSSession object in the $S variable.</maml:para> <maml:para>The second command uses Import-PSSession to import the Test cmdlets from the PSSession in $S into the current session.</maml:para> <maml:para>The third command uses the AsJob parameter of the imported New-Test cmdlet to run a New-Test command as a background job. The command saves the job object that New-Test returns in the $batch variable.</maml:para> <maml:para>The fourth command uses the Receive-Job cmdlet to get the results of the job in the $batch variable.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 5: Import cmdlets and functions from a Windows PowerShell module</maml:title> <dev:code>PS C:\> $S = New-PSSession -ComputerName Server01 PS C:\> Invoke-Command -Session $S {Import-Module TestManagement} PS C:\> Import-PSSession -Session $S -Module TestManagement</dev:code> <dev:remarks> <maml:para>This example shows how to import the cmdlets and functions from a Windows PowerShell module on a remote computer into the current session.</maml:para> <maml:para>The first command creates a PSSession on the Server01 computer and saves it in the $S variable.</maml:para> <maml:para>The second command uses the Invoke-Command cmdlet to run an Import-Module command in the PSSession in $S.</maml:para> <maml:para>Typically, the module would be added to all sessions by an Import-Module command in a Windows PowerShell profile, but profiles are not run in PSSessions.</maml:para> <maml:para>The third command uses the Module parameter of Import-PSSession to import the cmdlets and functions in the module into the current session.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 6: Create a module in a temporary file --------</maml:title> <dev:code>PS C:\> Import-PSSession $S -CommandName Get-Date, SearchHelp -FormatTypeName * -AllowClobber Name : tmp_79468106-4e1d-4d90-af97-1154f9317239_tcw1zunz.ttf Path : C:\Users\User01\AppData\Local\Temp\tmp_79468106-4e1d-4d90-af97-1154f9317239_tcw1zunz.ttf\tmp_79468106-4e1d-4d90-af97-1154f9317239_ tcw1zunz.ttf.psm1 Description : Implicit remoting for http://server01.corp.fabrikam.com/wsman Guid : 79468106-4e1d-4d90-af97-1154f9317239 Version : 1.0 ModuleBase : C:\Users\User01\AppData\Local\Temp\tmp_79468106-4e1d-4d90-af97-1154f9317239_tcw1zunz.ttf ModuleType : Script PrivateData : {ImplicitRemoting} AccessMode : ReadWrite ExportedAliases : {} ExportedCmdlets : {} ExportedFunctions : {[Get-Date, Get-Date], [SearchHelp, SearchHelp]} ExportedVariables : {} NestedModules : {}</dev:code> <dev:remarks> <maml:para>This example shows that Import-PSSession creates a module in a temporary file on disk. It also shows that all commands are converted into functions before they are imported into the current session.</maml:para> <maml:para>The command uses the Import-PSSession cmdlet to import a Get-Date cmdlet and a SearchHelp function into the current session.</maml:para> <maml:para>The Import-PSSession cmdlet returns a PSModuleInfo object that represents the temporary module. The value of the Path property shows that Import-PSSession created a script module (.psm1) file in a temporary location. The ExportedFunctions property shows that the Get-Date cmdlet and the SearchHelp function were both imported as functions.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 7: Run a command that is hidden by an imported command</maml:title> <dev:code>PS C:\> Import-PSSession $S -CommandName Get-Date -FormatTypeName * -AllowClobber PS C:\> Get-Command Get-Date -All CommandType Name Definition ----------- ---- ---------- Function Get-Date ... Cmdlet Get-Date Get-Date [[-Date] <DateTime>] [-Year <Int32>] [-Month <Int32>] PS C:\> Get-Date 09074 PS C:\> (Get-Command -Type Cmdlet -Name Get-Date).PSSnapin.Name Microsoft.PowerShell.Utility PS C:\> Microsoft.PowerShell.Utility\Get-Date Sunday, March 15, 2009 2:08:26 PM</dev:code> <dev:remarks> <maml:para>This example shows how to run a command that is hidden by an imported command.</maml:para> <maml:para>The first command imports a Get-Date cmdlet from the PSSession in the $S variable. Because the current session includes a Get-Date cmdlet, the AllowClobber parameter is required in the command.</maml:para> <maml:para>The second command uses the All parameter of the Get-Command cmdlet to get all Get-Date commands in the current session. The output shows that the session includes the original Get-Date cmdlet and a Get-Date function. The Get-Date function runs the imported Get-Date cmdlet in the PSSession in $S.</maml:para> <maml:para>The third command runs a Get-Date command. Because functions take precedence over cmdlets, Windows PowerShell runs the imported Get-Date function, which returns a Julian date.</maml:para> <maml:para>The fourth and fifth commands show how to use a qualified name to run a command that is hidden by an imported command.</maml:para> <maml:para>The fourth command gets the name of the Windows PowerShell snap-in that added the original Get-Date cmdlet to the current session.</maml:para> <maml:para>The fifth command uses the snap-in-qualified name of the Get-Date cmdlet to run a Get-Date command.</maml:para> <maml:para>For more information about command precedence and hidden commands, see about_Command_Precedence.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 8: Import commands that have a specific string in their names</maml:title> <dev:code>PS C:\> Import-PSSession -Session $S -CommandName *Item* -AllowClobber</dev:code> <dev:remarks> <maml:para>This command imports commands whose names include Item from the PSSession in $S. Because the command includes the CommandName parameter but not the FormatTypeData parameter, only the command is imported.</maml:para> <maml:para>Use this command when you are using Import-PSSession to run a command on a remote computer and you already have the formatting data for the command in the current session.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 9: Use the Module parameter to discover which commands were imported into the session</maml:title> <dev:code>PS C:\> $M = Import-PSSession -Session $S -CommandName *bits* -FormatTypeName *bits* PS C:\> Get-Command -Module $M CommandType Name ----------- ---- Function Add-BitsFile Function Complete-BitsTransfer Function Get-BitsTransfer Function Remove-BitsTransfer Function Resume-BitsTransfer Function Set-BitsTransfer Function Start-BitsTransfer Function Suspend-BitsTransfer</dev:code> <dev:remarks> <maml:para>This command shows how to use the Module parameter of Get-Command to find out which commands were imported into the session by an Import-PSSession command.</maml:para> <maml:para>The first command uses the Import-PSSession cmdlet to import commands whose names include "bits" from the PSSession in the $S variable. The Import-PSSession command returns a temporary module, and the command saves the module in the $m variable.</maml:para> <maml:para>The second command uses the Get-Command cmdlet to get the commands that are exported by the module in the $M variable.</maml:para> <maml:para>The Module parameter takes a string value, which is designed for the module name. However, when you submit a module object, Windows PowerShell uses the ToString method on the module object, which returns the module name.</maml:para> <maml:para>The Get-Command command is the equivalent of `Get-Command $M.Name`".</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/import-pssession?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Export-PSSession</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Invoke-Expression</command:name> <command:verb>Invoke</command:verb> <command:noun>Expression</command:noun> <maml:description> <maml:para>Runs commands or expressions on the local computer.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Invoke-Expression` cmdlet evaluates or runs a specified string as a command and returns the results of the expression or command. Without `Invoke-Expression`, a string submitted at the command line is returned (echoed) unchanged.</maml:para> <maml:para>Expressions are evaluated and run in the current scope. For more information, see about_Scopes (../Microsoft.PowerShell.Core/About/about_Scopes.md).</maml:para> <maml:para>> [!CAUTION] > Take reasonable precautions when using the `Invoke-Expression` cmdlet in scripts. When using > `Invoke-Expression` to run a command that the user enters, verify that the command is safe to run > before running it. In general, it is best to design your script with predefined input options, > rather than allowing freeform input.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Invoke-Expression</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Command</maml:name> <maml:Description> <maml:para>Specifies the command or expression to run. Type the command or expression or enter a variable that contains the command or expression. The Command parameter is required.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Command</maml:name> <maml:Description> <maml:para>Specifies the command or expression to run. Type the command or expression or enter a variable that contains the command or expression. The Command parameter is required.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String or PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe an object that represents the command to `Invoke-Expression`. Use the `$Input` automatic variable to represent the input objects in the command.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>PSObject</maml:name> </dev:type> <maml:description> <maml:para>Returns the output that is generated by the invoked command (the value of the Command parameter).</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>In most cases, you invoke expressions using PowerShell's call operator and achieve the same results. The call operator is a safer method. For more information, see about_Operators (../microsoft.powershell.core/about/about_operators.md#call-operator-).</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------- Example 1: Evaluate an expression --------------</maml:title> <dev:code>$Command = "Get-Process" $Command Get-Process Invoke-Expression $Command Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- 296 4 1572 1956 20 0.53 1348 AdtAgent 270 6 1328 800 34 0.06 2396 alg 67 2 620 484 20 0.22 716 ati2evxx 1060 15 12904 11840 74 11.48 892 CcmExec 1400 33 25280 37544 223 38.44 2564 communicator ...</dev:code> <dev:remarks> <maml:para>This example demonstrates the use of `Invoke-Expression` to evaluate an expression. Without `Invoke-Expression`, the expression is printed, but not evaluated.</maml:para> <maml:para>The first command assigns a value of `Get-Process` (a string) to the `$Command` variable.</maml:para> <maml:para>The second command shows the effect of typing the variable name at the command line. PowerShell echoes the string.</maml:para> <maml:para>The third command uses `Invoke-Expression` to evaluate the string.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 2: Run a script on the local computer --------</maml:title> <dev:code>Invoke-Expression -Command "C:\ps-test\testscript.ps1" "C:\ps-test\testscript.ps1" | Invoke-Expression</dev:code> <dev:remarks> <maml:para>These commands use `Invoke-Expression` to run a script, TestScript.ps1, on the local computer. The two commands are equivalent. The first uses the Command parameter to specify the command to run. The second uses a pipeline operator (`|`) to send the command string to `Invoke-Expression`.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------ Example 3: Run a command in a variable ------------</maml:title> <dev:code>$Command = 'Get-Process | where {$_.cpu -gt 1000}' Invoke-Expression $Command</dev:code> <dev:remarks> <maml:para>This example runs a command string that is saved in the `$Command` variable.</maml:para> <maml:para>The command string is enclosed in single quotation marks because it includes a variable, `$_`, which represents the current object. If it were enclosed in double quotation marks, the `$_` variable would be replaced by its value before it was saved in the `$Command` variable.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 4: Get and run a cmdlet Help example ---------</maml:title> <dev:code>$Cmdlet_name = "Get-EventLog" $Example_number = 1 $Example_code = (Get-Help $Cmdlet_name).examples.example[($Example_number-1)].code Invoke-Expression $Example_code</dev:code> <dev:remarks> <maml:para>This command retrieves and runs the first example in the `Get-EventLog` cmdlet Help topic.</maml:para> <maml:para>To run an example of a different cmdlet, change the value of the `$Cmdlet_name` variable to the name of the cmdlet. And, change the `$Example_number` variable to the example number you want to run. The command fails if the example number is not valid.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-expression?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Invoke-Command</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Scopes</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Invoke-RestMethod</command:name> <command:verb>Invoke</command:verb> <command:noun>RestMethod</command:noun> <maml:description> <maml:para>Sends an HTTP or HTTPS request to a RESTful web service.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Invoke-RestMethod` cmdlet sends HTTP and HTTPS requests to Representational State Transfer (REST) web services that returns richly structured data.</maml:para> <maml:para>Windows PowerShell formats the response based to the data type. For an RSS or ATOM feed, Windows PowerShell returns the Item or Entry XML nodes. For JavaScript Object Notation (JSON) or XML, Windows PowerShell converts (or deserializes) the content into objects.</maml:para> <maml:para>This cmdlet is introduced in Windows PowerShell 3.0.</maml:para> <maml:para>> [!NOTE] > By default, script code in the web page may be run when the page is being parsed to populate the > `ParsedHtml` property. Use the UseBasicParsing switch to suppress this.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Invoke-RestMethod</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Uri</maml:name> <maml:Description> <maml:para>Specifies the Uniform Resource Identifier (URI) of the Internet resource to which the web request is sent. This parameter supports HTTP, HTTPS, FTP, and FILE values.</maml:para> <maml:para>This parameter is required. The parameter name ( Uri ) is optional.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Uri</command:parameterValue> <dev:type> <maml:name>System.Uri</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>Body</maml:name> <maml:Description> <maml:para>Specifies the body of the request. The body is the content of the request that follows the headers. You can also pipe a body value to `Invoke-RestMethod`.</maml:para> <maml:para>The Body parameter can be used to specify a list of query parameters or specify the content of the response.</maml:para> <maml:para>When the input is a GET request, and the body is an IDictionary (typically, a hash table), the body is added to the URI as query parameters. For other request types (such as POST), the body is set as the value of the request body in the standard name=value format.</maml:para> <maml:para>> [!WARNING] > The verbose output of a POST body will end with `with -1-byte payload`, even though > the size of the body is both known and sent in the `Content-Length` HTTP header.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Certificate</maml:name> <maml:Description> <maml:para>Specifies the client certificate that is used for a secure web request. Enter a variable that contains a certificate or a command or expression that gets the certificate.</maml:para> <maml:para>To find a certificate, use `Get-PfxCertificate` or use the `Get-ChildItem` cmdlet in the Certificate (`Cert:`) drive. If the certificate is not valid or does not have sufficient authority, the command fails.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Security.Cryptography.X509Certificates.X509Certificate</command:parameterValue> <dev:type> <maml:name>System.Security.Cryptography.X509Certificates.X509Certificate</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CertificateThumbprint</maml:name> <maml:Description> <maml:para>Specifies the digital public key certificate (X509) of a user account that has permission to send the request. Enter the certificate thumbprint of the certificate.</maml:para> <maml:para>Certificates are used in client certificate-based authentication. They can be mapped only to local user accounts; they do not work with domain accounts.</maml:para> <maml:para>To get a certificate thumbprint, use the `Get-Item` or `Get-ChildItem` command in the Windows PowerShell (`Cert:`) drive.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ContentType</maml:name> <maml:Description> <maml:para>Specifies the content type of the web request.</maml:para> <maml:para>If this parameter is omitted and the request method is POST, `Invoke-RestMethod` sets the content type to "application/x-www-form-urlencoded". Otherwise, the content type is not specified in the call.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Credential</maml:name> <maml:Description> <maml:para>Specifies a user account that has permission to send the request. The default is the current user.</maml:para> <maml:para>Type a user name, such as User01 or Domain01\User01 , or enter a PSCredential object generated by the `Get-Credential` cmdlet.</maml:para> <maml:para>Credentials are stored in a PSCredential (/dotnet/api/system.management.automation.pscredential)object and the password is stored as a SecureString (/dotnet/api/system.security.securestring).</maml:para> <maml:para>> [!NOTE] > For more information about SecureString data protection, see > How secure is SecureString? (/dotnet/api/system.security.securestring#how-secure-is-securestring).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSCredential</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSCredential</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Current user</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisableKeepAlive</maml:name> <maml:Description> <maml:para>Sets the KeepAlive value in the HTTP header to False. By default, KeepAlive is True. KeepAlive establishes a persistent connection to the server to facilitate subsequent requests.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>KeepAlive</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Headers</maml:name> <maml:Description> <maml:para>Specifies the headers of the web request. Enter a hash table or dictionary.</maml:para> <maml:para>To set UserAgent headers, use the UserAgent parameter. You cannot use this parameter to specify UserAgent or cookie headers.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Collections.IDictionary</command:parameterValue> <dev:type> <maml:name>System.Collections.IDictionary</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>InFile</maml:name> <maml:Description> <maml:para>Gets the content of the web request from a file.</maml:para> <maml:para>Enter a path and file name. If you omit the path, the default is the current location.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>MaximumRedirection</maml:name> <maml:Description> <maml:para>Determines how many times Windows PowerShell redirects a connection to an alternate Uniform Resource Identifier (URI) before the connection fails. The default value is 5. A value of 0 (zero) prevents all redirection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>5</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Method</maml:name> <maml:Description> <maml:para>Specifies the method used for the web request. The acceptable values for this parameter are:</maml:para> <maml:para>- Default</maml:para> <maml:para>- Delete</maml:para> <maml:para>- Get</maml:para> <maml:para>- Head</maml:para> <maml:para>- Merge</maml:para> <maml:para>- Options</maml:para> <maml:para>- Patch</maml:para> <maml:para>- Post</maml:para> <maml:para>- Put</maml:para> <maml:para>- Trace</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Default</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Get</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Head</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Post</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Put</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Delete</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Trace</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Options</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Merge</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Patch</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.WebRequestMethod</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.WebRequestMethod</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Default</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>OutFile</maml:name> <maml:Description> <maml:para>Saves the response body in the specified output file. Enter a path and file name. If you omit the path, the default is the current location.</maml:para> <maml:para>By default, `Invoke-RestMethod` returns the results to the pipeline. To send the results to a file and to the pipeline, use the Passthru parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns the results, in addition to writing them to a file. This parameter is valid only when the OutFile parameter is also used in the command.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>No output</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Proxy</maml:name> <maml:Description> <maml:para>Uses a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Uri</command:parameterValue> <dev:type> <maml:name>System.Uri</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ProxyCredential</maml:name> <maml:Description> <maml:para>Specifies a user account that has permission to use the proxy server that is specified by the Proxy parameter. The default is the current user.</maml:para> <maml:para>Type a user name, such as "User01" or "Domain01\User01", or enter a PSCredential object, such as one generated by the `Get-Credential` cmdlet.</maml:para> <maml:para>This parameter is valid only when the Proxy parameter is also used in the command. You cannot use the ProxyCredential and ProxyUseDefaultCredentials parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSCredential</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSCredential</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Current user</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ProxyUseDefaultCredentials</maml:name> <maml:Description> <maml:para>Uses the credentials of the current user to access the proxy server that is specified by the Proxy parameter.</maml:para> <maml:para>This parameter is valid only when the Proxy parameter is also used in the command. You cannot use the ProxyCredential and ProxyUseDefaultCredentials parameters in the same command.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="SV"> <maml:name>SessionVariable</maml:name> <maml:Description> <maml:para>Creates a web request session and saves it in the value of the specified variable. Enter a variable name without the dollar sign (`$`) symbol.</maml:para> <maml:para>When you specify a session variable, `Invoke-RestMethod` creates a web request session object and assigns it to a variable with the specified name in your PowerShell session. You can use the variable in your session as soon as the command completes.</maml:para> <maml:para>Unlike a remote session, the web request session is not a persistent connection. It is an object that contains information about the connection and the request, including cookies, credentials, the maximum redirection value, and the user agent string. You can use it to share state and data among web requests.</maml:para> <maml:para>To use the web request session in subsequent web requests, specify the session variable in the value of the WebSession parameter. Windows PowerShell uses the data in the web request session object when establishing the new connection. To override a value in the web request session, use a cmdlet parameter, such as UserAgent or Credential . Parameter values take precedence over values in the web request session.</maml:para> <maml:para>You cannot use the SessionVariable and WebSession parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TimeoutSec</maml:name> <maml:Description> <maml:para>Specifies how long the request can be pending before it times out. Enter a value in seconds. The default value, 0, specifies an indefinite time-out.</maml:para> <maml:para>A Domain Name System (DNS) query can take up to 15 seconds to return or time out. If your request contains a host name that requires resolution, and you set TimeoutSec to a value greater than zero, but less than 15 seconds, it can take 15 seconds or more before a WebException is thrown, and your request times out.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>0</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TransferEncoding</maml:name> <maml:Description> <maml:para>Specifies a value for the transfer-encoding HTTP response header. The acceptable values for this parameter are:</maml:para> <maml:para>- Chunked</maml:para> <maml:para>- Compress</maml:para> <maml:para>- Deflate</maml:para> <maml:para>- GZip</maml:para> <maml:para>- Identity</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">chunked</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">compress</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">deflate</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">gzip</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">identity</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseBasicParsing</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet uses basic parsing. The cmdlet returns the raw HTML in a String object.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseDefaultCredentials</maml:name> <maml:Description> <maml:para>Uses the credentials of the current user to send the web request.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UserAgent</maml:name> <maml:Description> <maml:para>Specifies a user agent string for the web request.</maml:para> <maml:para>The default user agent is similar to "Mozilla/5.0 (Windows NT; Windows NT 6.1; en-US) WindowsPowerShell/3.0" with slight variations for each operating system and platform.</maml:para> <maml:para>To test a website with the standard user agent string that is used by most Internet browsers, use the properties of the PSUserAgent (/dotnet/api/microsoft.powershell.commands)class, such as Chrome, FireFox, Internet Explorer, Opera, and Safari.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>WebSession</maml:name> <maml:Description> <maml:para>Specifies a web request session. Enter the variable name, including the dollar sign (`$`).</maml:para> <maml:para>To override a value in the web request session, use a cmdlet parameter, such as UserAgent or Credential . Parameter values take precedence over values in the web request session.</maml:para> <maml:para>Unlike a remote session, the web request session is not a persistent connection. It is an object that contains information about the connection and the request, including cookies, credentials, the maximum redirection value, and the user agent string. You can use it to share state and data among web requests.</maml:para> <maml:para>To create a web request session, enter a variable name (without a dollar sign) in the value of the SessionVariable parameter of an `Invoke-RestMethod` command. `Invoke-RestMethod` creates the session and saves it in the variable. In subsequent commands, use the variable as the value of the WebSession parameter.</maml:para> <maml:para>You cannot use the SessionVariable and WebSession parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.WebRequestSession</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.WebRequestSession</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>Body</maml:name> <maml:Description> <maml:para>Specifies the body of the request. The body is the content of the request that follows the headers. You can also pipe a body value to `Invoke-RestMethod`.</maml:para> <maml:para>The Body parameter can be used to specify a list of query parameters or specify the content of the response.</maml:para> <maml:para>When the input is a GET request, and the body is an IDictionary (typically, a hash table), the body is added to the URI as query parameters. For other request types (such as POST), the body is set as the value of the request body in the standard name=value format.</maml:para> <maml:para>> [!WARNING] > The verbose output of a POST body will end with `with -1-byte payload`, even though > the size of the body is both known and sent in the `Content-Length` HTTP header.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Certificate</maml:name> <maml:Description> <maml:para>Specifies the client certificate that is used for a secure web request. Enter a variable that contains a certificate or a command or expression that gets the certificate.</maml:para> <maml:para>To find a certificate, use `Get-PfxCertificate` or use the `Get-ChildItem` cmdlet in the Certificate (`Cert:`) drive. If the certificate is not valid or does not have sufficient authority, the command fails.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Security.Cryptography.X509Certificates.X509Certificate</command:parameterValue> <dev:type> <maml:name>System.Security.Cryptography.X509Certificates.X509Certificate</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CertificateThumbprint</maml:name> <maml:Description> <maml:para>Specifies the digital public key certificate (X509) of a user account that has permission to send the request. Enter the certificate thumbprint of the certificate.</maml:para> <maml:para>Certificates are used in client certificate-based authentication. They can be mapped only to local user accounts; they do not work with domain accounts.</maml:para> <maml:para>To get a certificate thumbprint, use the `Get-Item` or `Get-ChildItem` command in the Windows PowerShell (`Cert:`) drive.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ContentType</maml:name> <maml:Description> <maml:para>Specifies the content type of the web request.</maml:para> <maml:para>If this parameter is omitted and the request method is POST, `Invoke-RestMethod` sets the content type to "application/x-www-form-urlencoded". Otherwise, the content type is not specified in the call.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Credential</maml:name> <maml:Description> <maml:para>Specifies a user account that has permission to send the request. The default is the current user.</maml:para> <maml:para>Type a user name, such as User01 or Domain01\User01 , or enter a PSCredential object generated by the `Get-Credential` cmdlet.</maml:para> <maml:para>Credentials are stored in a PSCredential (/dotnet/api/system.management.automation.pscredential)object and the password is stored as a SecureString (/dotnet/api/system.security.securestring).</maml:para> <maml:para>> [!NOTE] > For more information about SecureString data protection, see > How secure is SecureString? (/dotnet/api/system.security.securestring#how-secure-is-securestring).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSCredential</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSCredential</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Current user</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisableKeepAlive</maml:name> <maml:Description> <maml:para>Sets the KeepAlive value in the HTTP header to False. By default, KeepAlive is True. KeepAlive establishes a persistent connection to the server to facilitate subsequent requests.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>KeepAlive</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Headers</maml:name> <maml:Description> <maml:para>Specifies the headers of the web request. Enter a hash table or dictionary.</maml:para> <maml:para>To set UserAgent headers, use the UserAgent parameter. You cannot use this parameter to specify UserAgent or cookie headers.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Collections.IDictionary</command:parameterValue> <dev:type> <maml:name>System.Collections.IDictionary</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>InFile</maml:name> <maml:Description> <maml:para>Gets the content of the web request from a file.</maml:para> <maml:para>Enter a path and file name. If you omit the path, the default is the current location.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>MaximumRedirection</maml:name> <maml:Description> <maml:para>Determines how many times Windows PowerShell redirects a connection to an alternate Uniform Resource Identifier (URI) before the connection fails. The default value is 5. A value of 0 (zero) prevents all redirection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>5</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Method</maml:name> <maml:Description> <maml:para>Specifies the method used for the web request. The acceptable values for this parameter are:</maml:para> <maml:para>- Default</maml:para> <maml:para>- Delete</maml:para> <maml:para>- Get</maml:para> <maml:para>- Head</maml:para> <maml:para>- Merge</maml:para> <maml:para>- Options</maml:para> <maml:para>- Patch</maml:para> <maml:para>- Post</maml:para> <maml:para>- Put</maml:para> <maml:para>- Trace</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.WebRequestMethod</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.WebRequestMethod</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Default</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>OutFile</maml:name> <maml:Description> <maml:para>Saves the response body in the specified output file. Enter a path and file name. If you omit the path, the default is the current location.</maml:para> <maml:para>By default, `Invoke-RestMethod` returns the results to the pipeline. To send the results to a file and to the pipeline, use the Passthru parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns the results, in addition to writing them to a file. This parameter is valid only when the OutFile parameter is also used in the command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>No output</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Proxy</maml:name> <maml:Description> <maml:para>Uses a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Uri</command:parameterValue> <dev:type> <maml:name>System.Uri</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ProxyCredential</maml:name> <maml:Description> <maml:para>Specifies a user account that has permission to use the proxy server that is specified by the Proxy parameter. The default is the current user.</maml:para> <maml:para>Type a user name, such as "User01" or "Domain01\User01", or enter a PSCredential object, such as one generated by the `Get-Credential` cmdlet.</maml:para> <maml:para>This parameter is valid only when the Proxy parameter is also used in the command. You cannot use the ProxyCredential and ProxyUseDefaultCredentials parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSCredential</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSCredential</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Current user</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ProxyUseDefaultCredentials</maml:name> <maml:Description> <maml:para>Uses the credentials of the current user to access the proxy server that is specified by the Proxy parameter.</maml:para> <maml:para>This parameter is valid only when the Proxy parameter is also used in the command. You cannot use the ProxyCredential and ProxyUseDefaultCredentials parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="SV"> <maml:name>SessionVariable</maml:name> <maml:Description> <maml:para>Creates a web request session and saves it in the value of the specified variable. Enter a variable name without the dollar sign (`$`) symbol.</maml:para> <maml:para>When you specify a session variable, `Invoke-RestMethod` creates a web request session object and assigns it to a variable with the specified name in your PowerShell session. You can use the variable in your session as soon as the command completes.</maml:para> <maml:para>Unlike a remote session, the web request session is not a persistent connection. It is an object that contains information about the connection and the request, including cookies, credentials, the maximum redirection value, and the user agent string. You can use it to share state and data among web requests.</maml:para> <maml:para>To use the web request session in subsequent web requests, specify the session variable in the value of the WebSession parameter. Windows PowerShell uses the data in the web request session object when establishing the new connection. To override a value in the web request session, use a cmdlet parameter, such as UserAgent or Credential . Parameter values take precedence over values in the web request session.</maml:para> <maml:para>You cannot use the SessionVariable and WebSession parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TimeoutSec</maml:name> <maml:Description> <maml:para>Specifies how long the request can be pending before it times out. Enter a value in seconds. The default value, 0, specifies an indefinite time-out.</maml:para> <maml:para>A Domain Name System (DNS) query can take up to 15 seconds to return or time out. If your request contains a host name that requires resolution, and you set TimeoutSec to a value greater than zero, but less than 15 seconds, it can take 15 seconds or more before a WebException is thrown, and your request times out.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>0</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TransferEncoding</maml:name> <maml:Description> <maml:para>Specifies a value for the transfer-encoding HTTP response header. The acceptable values for this parameter are:</maml:para> <maml:para>- Chunked</maml:para> <maml:para>- Compress</maml:para> <maml:para>- Deflate</maml:para> <maml:para>- GZip</maml:para> <maml:para>- Identity</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Uri</maml:name> <maml:Description> <maml:para>Specifies the Uniform Resource Identifier (URI) of the Internet resource to which the web request is sent. This parameter supports HTTP, HTTPS, FTP, and FILE values.</maml:para> <maml:para>This parameter is required. The parameter name ( Uri ) is optional.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Uri</command:parameterValue> <dev:type> <maml:name>System.Uri</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseBasicParsing</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet uses basic parsing. The cmdlet returns the raw HTML in a String object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseDefaultCredentials</maml:name> <maml:Description> <maml:para>Uses the credentials of the current user to send the web request.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UserAgent</maml:name> <maml:Description> <maml:para>Specifies a user agent string for the web request.</maml:para> <maml:para>The default user agent is similar to "Mozilla/5.0 (Windows NT; Windows NT 6.1; en-US) WindowsPowerShell/3.0" with slight variations for each operating system and platform.</maml:para> <maml:para>To test a website with the standard user agent string that is used by most Internet browsers, use the properties of the PSUserAgent (/dotnet/api/microsoft.powershell.commands)class, such as Chrome, FireFox, Internet Explorer, Opera, and Safari.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>WebSession</maml:name> <maml:Description> <maml:para>Specifies a web request session. Enter the variable name, including the dollar sign (`$`).</maml:para> <maml:para>To override a value in the web request session, use a cmdlet parameter, such as UserAgent or Credential . Parameter values take precedence over values in the web request session.</maml:para> <maml:para>Unlike a remote session, the web request session is not a persistent connection. It is an object that contains information about the connection and the request, including cookies, credentials, the maximum redirection value, and the user agent string. You can use it to share state and data among web requests.</maml:para> <maml:para>To create a web request session, enter a variable name (without a dollar sign) in the value of the SessionVariable parameter of an `Invoke-RestMethod` command. `Invoke-RestMethod` creates the session and saves it in the variable. In subsequent commands, use the variable as the value of the WebSession parameter.</maml:para> <maml:para>You cannot use the SessionVariable and WebSession parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.WebRequestSession</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.WebRequestSession</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Object</maml:name> </dev:type> <maml:description> <maml:para>You can pipe the body of a web request to `Invoke-RestMethod`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Xml.XmlDocument, Microsoft.PowerShell.Commands.HtmlWebResponseObject, System.String</maml:name> </dev:type> <maml:description> <maml:para>The output of the cmdlet depends upon the format of the content that is retrieved.</maml:para> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <maml:name>PSObject</maml:name> </dev:type> <maml:description> <maml:para>If the request returns JSON strings, `Invoke-RestMethod` returns a PSObject that represents the strings.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------ Example 1: Get the PowerShell RSS feed ------------</maml:title> <dev:code>Invoke-RestMethod -Uri https://devblogs.microsoft.com/powershell/feed/ | Format-Table -Property Title, pubDate Title pubDate ----- ------- Join the PowerShell 10th Anniversary Celebration! Tue, 08 Nov 2016 23:00:04 +0000 DSC Resource Kit November 2016 Release Thu, 03 Nov 2016 00:19:07 +0000 PSScriptAnalyzer Community Call - Oct 18, 2016 Thu, 13 Oct 2016 17:52:35 +0000 New Home for In-Box DSC Resources Sat, 08 Oct 2016 07:13:10 +0000 New Social Features on Gallery Fri, 30 Sep 2016 23:04:34 +0000 PowerShellGet and PackageManagement in PowerShell Gallery and GitHub Thu, 29 Sep 2016 22:21:42 +0000 PowerShell Security at DerbyCon Wed, 28 Sep 2016 01:13:19 +0000 DSC Resource Kit September Release Thu, 22 Sep 2016 00:25:37 +0000 PowerShell DSC and implicit remoting broken in KB3176934 Tue, 23 Aug 2016 15:07:50 +0000 PowerShell on Linux and Open Source! Thu, 18 Aug 2016 15:32:02 +0000</dev:code> <dev:remarks> <maml:para>This command uses the `Invoke-RestMethod` cmdlet to get information from the PowerShell Blog RSS feed. The command uses the `Format-Table` cmdlet to display the values of the Title and pubDate properties of each blog in a table.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------------------------- Example 2 --------------------------</maml:title> <dev:code>$Cred = Get-Credential # Next, allow the use of self-signed SSL certificates. [System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $True } # Create variables to store the values consumed by the Invoke-RestMethod command. # The search variable contents are later embedded in the body variable. $Server = 'server.contoso.com' $Url = "https://${server}:8089/services/search/jobs/export" $Search = "search index=_internal | reverse | table index,host,source,sourcetype,_raw" # The cmdlet handles URL encoding. The body variable describes the search criteria, specifies CSV as # the output mode, and specifies a time period for returned data that starts two days ago and ends # one day ago. The body variable specifies values for parameters that apply to the particular REST # API with which Invoke-RestMethod is communicating. $Body = @{ search = $Search output_mode = "csv" earliest_time = "-2d@d" latest_time = "-1d@d" } # Now, run the Invoke-RestMethod command with all variables in place, specifying a path and file # name for the resulting CSV output file. Invoke-RestMethod -Method Post -Uri $url -Credential $Cred -Body $body -OutFile output.csv {"preview":true,"offset":0,"result":{"sourcetype":"contoso1","count":"9624"}} {"preview":true,"offset":1,"result":{"sourcetype":"contoso2","count":"152"}} {"preview":true,"offset":2,"result":{"sourcetype":"contoso3","count":"88494"}} {"preview":true,"offset":3,"result":{"sourcetype":"contoso4","count":"15277"}}</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------------- Example 3: Pass multiple headers ---------------</maml:title> <dev:code>$headers = @{ 'userId' = 'UserIDValue' 'token' = 'TokenValue' } Invoke-RestMethod -Uri $uri -Method Post -Headers $headers -Body $body</dev:code> <dev:remarks> <maml:para>APIs often require passed headers for authentication, validation etc.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------------- Example 3: Submitting form data ---------------</maml:title> <dev:code>$R = Invoke-WebRequest https://website.com/login.aspx $R.Forms[0].Name = "MyName" $R.Forms[0].Password = "MyPassword" Invoke-RestMethod https://website.com/service.aspx -Body $R.Forms[0]</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-Json</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertFrom-Json</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Invoke-WebRequest</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Invoke-WebRequest</command:name> <command:verb>Invoke</command:verb> <command:noun>WebRequest</command:noun> <maml:description> <maml:para>Gets content from a web page on the Internet.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Invoke-WebRequest` cmdlet sends HTTP, HTTPS, FTP, and FILE requests to a web page or web service. It parses the response and returns collections of forms, links, images, and other significant HTML elements.</maml:para> <maml:para>This cmdlet was introduced in Windows PowerShell 3.0.</maml:para> <maml:para>> [!NOTE] > By default, > script code in the web page may be run when the page is being parsed to populate the `ParsedHtml` property. > Use the `-UseBasicParsing` switch to suppress this.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Invoke-WebRequest</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Uri</maml:name> <maml:Description> <maml:para>Specifies the Uniform Resource Identifier (URI) of the Internet resource to which the web request is sent. Enter a URI. This parameter supports HTTP, HTTPS, FTP, and FILE values.</maml:para> <maml:para>This parameter is required.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Uri</command:parameterValue> <dev:type> <maml:name>System.Uri</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>Body</maml:name> <maml:Description> <maml:para>Specifies the body of the request. The body is the content of the request that follows the headers. You can also pipe a body value to `Invoke-WebRequest`.</maml:para> <maml:para>The Body parameter can be used to specify a list of query parameters or specify the content of the response.</maml:para> <maml:para>When the input is a GET request and the body is an IDictionary (typically, a hash table), the body is added to the URI as query parameters. For other GET requests, the body is set as the value of the request body in the standard `name=value` format.</maml:para> <maml:para>When the body is a form, or it is the output of an `Invoke-WebRequest` call, PowerShell sets the request content to the form fields. For example:</maml:para> <maml:para>`$r = Invoke-WebRequest https://website.com/login.aspx` `$r.Forms[0].Name = "MyName"` `$r.Forms[0].Password = "MyPassword"` `Invoke-RestMethod https://website.com/service.aspx -Body $r`</maml:para> <maml:para>- or -</maml:para> <maml:para>`Invoke-RestMethod https://website.com/service.aspx -Body $r.Forms[0]`</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Certificate</maml:name> <maml:Description> <maml:para>Specifies the client certificate that is used for a secure web request. Enter a variable that contains a certificate or a command or expression that gets the certificate.</maml:para> <maml:para>To find a certificate, use `Get-PfxCertificate` or use the `Get-ChildItem` cmdlet in the Certificate (`Cert:`) drive. If the certificate is not valid or does not have sufficient authority, the command fails.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Security.Cryptography.X509Certificates.X509Certificate</command:parameterValue> <dev:type> <maml:name>System.Security.Cryptography.X509Certificates.X509Certificate</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CertificateThumbprint</maml:name> <maml:Description> <maml:para>Specifies the digital public key certificate (X509) of a user account that has permission to send the request. Enter the certificate thumbprint of the certificate. Certificates are used in client certificate-based authentication. They can be mapped only to local user accounts; they do not work with domain accounts.</maml:para> <maml:para>To get a certificate thumbprint, use the `Get-Item` or `Get-ChildItem` command in the PowerShell `Cert:` drive.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ContentType</maml:name> <maml:Description> <maml:para>Specifies the content type of the web request.</maml:para> <maml:para>If this parameter is omitted and the request method is POST, `Invoke-WebRequest` sets the content type to application/x-www-form-urlencoded. Otherwise, the content type is not specified in the call.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Credential</maml:name> <maml:Description> <maml:para>Specifies a user account that has permission to send the request. The default is the current user.</maml:para> <maml:para>Type a user name, such as User01 or Domain01\User01 , or enter a PSCredential object generated by the `Get-Credential` cmdlet.</maml:para> <maml:para>Credentials are stored in a PSCredential (/dotnet/api/system.management.automation.pscredential)object and the password is stored as a SecureString (/dotnet/api/system.security.securestring).</maml:para> <maml:para>> [!NOTE] > For more information about SecureString data protection, see > How secure is SecureString? (/dotnet/api/system.security.securestring#how-secure-is-securestring).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSCredential</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSCredential</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisableKeepAlive</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sets the KeepAlive value in the HTTP header to False . By default, KeepAlive is True . KeepAlive establishes a persistent connection to the server to facilitate subsequent requests.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Headers</maml:name> <maml:Description> <maml:para>Specifies the headers of the web request. Enter a hash table or dictionary.</maml:para> <maml:para>To set UserAgent headers, use the UserAgent parameter. You cannot use this parameter to specify UserAgent or cookie headers.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Collections.IDictionary</command:parameterValue> <dev:type> <maml:name>System.Collections.IDictionary</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>InFile</maml:name> <maml:Description> <maml:para>Gets the content of the web request from a file.</maml:para> <maml:para>Enter a path and file name. If you omit the path, the default is the current location.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>MaximumRedirection</maml:name> <maml:Description> <maml:para>Specifies how many times PowerShell redirects a connection to an alternate Uniform Resource Identifier (URI) before the connection fails. The default value is 5. A value of 0 (zero) prevents all redirection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Method</maml:name> <maml:Description> <maml:para>Specifies the method used for the web request. The acceptable values for this parameter are:</maml:para> <maml:para>- Default</maml:para> <maml:para>- Delete</maml:para> <maml:para>- Get</maml:para> <maml:para>- Head</maml:para> <maml:para>- Merge</maml:para> <maml:para>- Options</maml:para> <maml:para>- Patch</maml:para> <maml:para>- Post</maml:para> <maml:para>- Put</maml:para> <maml:para>- Trace</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Default</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Get</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Head</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Post</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Put</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Delete</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Trace</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Options</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Merge</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Patch</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.WebRequestMethod</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.WebRequestMethod</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>OutFile</maml:name> <maml:Description> <maml:para>Specifies the output file for which this cmdlet saves the response body. Enter a path and file name. If you omit the path, the default is the current location.</maml:para> <maml:para>By default, `Invoke-WebRequest` returns the results to the pipeline. To send the results to a file and to the pipeline, use the Passthru parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet returns the results, in addition to writing them to a file. This parameter is valid only when the OutFile parameter is also used in the command.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Proxy</maml:name> <maml:Description> <maml:para>Specifies a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Uri</command:parameterValue> <dev:type> <maml:name>System.Uri</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ProxyCredential</maml:name> <maml:Description> <maml:para>Specifies a user account that has permission to use the proxy server that is specified by the Proxy parameter. The default is the current user.</maml:para> <maml:para>Type a user name, such as `User01` or `Domain01\User01`, or enter a PSCredential object, such as one generated by the `Get-Credential` cmdlet.</maml:para> <maml:para>This parameter is valid only when the Proxy parameter is also used in the command. You cannot use the ProxyCredential and ProxyUseDefaultCredentials parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSCredential</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSCredential</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ProxyUseDefaultCredentials</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet uses the credentials of the current user to access the proxy server that is specified by the Proxy parameter.</maml:para> <maml:para>This parameter is valid only when the Proxy parameter is also used in the command. You cannot use the ProxyCredential and ProxyUseDefaultCredentials parameters in the same command.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="SV"> <maml:name>SessionVariable</maml:name> <maml:Description> <maml:para>Specifies a variable for which this cmdlet creates a web request session and saves it in the value. Enter a variable name without the dollar sign (`$`) symbol.</maml:para> <maml:para>When you specify a session variable, `Invoke-WebRequest` creates a web request session object and assigns it to a variable with the specified name in your PowerShell session. You can use the variable in your session as soon as the command completes.</maml:para> <maml:para>Unlike a remote session, the web request session is not a persistent connection. It is an object that contains information about the connection and the request, including cookies, credentials, the maximum redirection value, and the user agent string. You can use it to share state and data among web requests.</maml:para> <maml:para>To use the web request session in subsequent web requests, specify the session variable in the value of the WebSession parameter. PowerShell uses the data in the web request session object when establishing the new connection. To override a value in the web request session, use a cmdlet parameter, such as UserAgent or Credential . Parameter values take precedence over values in the web request session.</maml:para> <maml:para>You cannot use the SessionVariable and WebSession parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TimeoutSec</maml:name> <maml:Description> <maml:para>Specifies how long the request can be pending before it times out. Enter a value in seconds. The default value, 0, specifies an indefinite time-out.</maml:para> <maml:para>A Domain Name System (DNS) query can take up to 15 seconds to return or time out. If your request contains a host name that requires resolution, and you set TimeoutSec to a value greater than zero, but less than 15 seconds, it can take 15 seconds or more before a WebException is thrown, and your request times out.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TransferEncoding</maml:name> <maml:Description> <maml:para>Specifies a value for the transfer-encoding HTTP response header. The acceptable values for this parameter are:</maml:para> <maml:para>- Chunked</maml:para> <maml:para>- Compress</maml:para> <maml:para>- Deflate</maml:para> <maml:para>- GZip</maml:para> <maml:para>- Identity</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">chunked</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">compress</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">deflate</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">gzip</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">identity</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseBasicParsing</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet uses the response object for HTML content without Document Object Model (DOM) parsing. This parameter is required when Internet Explorer is not installed on the computers, such as on a Server Core installation of a Windows Server operating system.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseDefaultCredentials</maml:name> <maml:Description> <maml:para>Indicates that the cmdet uses the credentials of the current user to send the web request.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UserAgent</maml:name> <maml:Description> <maml:para>Specifies a user agent string for the web request. The default user agent is similar to `Mozilla/5.0 (Windows NT; Windows NT 6.1; en-US) WindowsPowerShell/3.0` with slight variations for each operating system and platform.</maml:para> <maml:para>To test a website with the standard user agent string that is used by most Internet browsers, use the properties of the PSUserAgent (/dotnet/api/microsoft.powershell.commands.psuseragent)class, such as Chrome, FireFox, InternetExplorer, Opera, and Safari. For example, the following command uses the user agent string for Internet Explorer</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>WebSession</maml:name> <maml:Description> <maml:para>Specifies a web request session. Enter the variable name, including the dollar sign (`$`).</maml:para> <maml:para>To override a value in the web request session, use a cmdlet parameter, such as UserAgent or Credential . Parameter values take precedence over values in the web request session.</maml:para> <maml:para>Unlike a remote session, the web request session is not a persistent connection. It is an object that contains information about the connection and the request, including cookies, credentials, the maximum redirection value, and the user agent string. You can use it to share state and data among web requests.</maml:para> <maml:para>To create a web request session, enter a variable name (without a dollar sign) in the value of the SessionVariable parameter of an `Invoke-WebRequest` command. `Invoke-WebRequest` creates the session and saves it in the variable. In subsequent commands, use the variable as the value of the WebSession parameter.</maml:para> <maml:para>You cannot use the SessionVariable and WebSession parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.WebRequestSession</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.WebRequestSession</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>Body</maml:name> <maml:Description> <maml:para>Specifies the body of the request. The body is the content of the request that follows the headers. You can also pipe a body value to `Invoke-WebRequest`.</maml:para> <maml:para>The Body parameter can be used to specify a list of query parameters or specify the content of the response.</maml:para> <maml:para>When the input is a GET request and the body is an IDictionary (typically, a hash table), the body is added to the URI as query parameters. For other GET requests, the body is set as the value of the request body in the standard `name=value` format.</maml:para> <maml:para>When the body is a form, or it is the output of an `Invoke-WebRequest` call, PowerShell sets the request content to the form fields. For example:</maml:para> <maml:para>`$r = Invoke-WebRequest https://website.com/login.aspx` `$r.Forms[0].Name = "MyName"` `$r.Forms[0].Password = "MyPassword"` `Invoke-RestMethod https://website.com/service.aspx -Body $r`</maml:para> <maml:para>- or -</maml:para> <maml:para>`Invoke-RestMethod https://website.com/service.aspx -Body $r.Forms[0]`</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Certificate</maml:name> <maml:Description> <maml:para>Specifies the client certificate that is used for a secure web request. Enter a variable that contains a certificate or a command or expression that gets the certificate.</maml:para> <maml:para>To find a certificate, use `Get-PfxCertificate` or use the `Get-ChildItem` cmdlet in the Certificate (`Cert:`) drive. If the certificate is not valid or does not have sufficient authority, the command fails.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Security.Cryptography.X509Certificates.X509Certificate</command:parameterValue> <dev:type> <maml:name>System.Security.Cryptography.X509Certificates.X509Certificate</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CertificateThumbprint</maml:name> <maml:Description> <maml:para>Specifies the digital public key certificate (X509) of a user account that has permission to send the request. Enter the certificate thumbprint of the certificate. Certificates are used in client certificate-based authentication. They can be mapped only to local user accounts; they do not work with domain accounts.</maml:para> <maml:para>To get a certificate thumbprint, use the `Get-Item` or `Get-ChildItem` command in the PowerShell `Cert:` drive.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ContentType</maml:name> <maml:Description> <maml:para>Specifies the content type of the web request.</maml:para> <maml:para>If this parameter is omitted and the request method is POST, `Invoke-WebRequest` sets the content type to application/x-www-form-urlencoded. Otherwise, the content type is not specified in the call.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Credential</maml:name> <maml:Description> <maml:para>Specifies a user account that has permission to send the request. The default is the current user.</maml:para> <maml:para>Type a user name, such as User01 or Domain01\User01 , or enter a PSCredential object generated by the `Get-Credential` cmdlet.</maml:para> <maml:para>Credentials are stored in a PSCredential (/dotnet/api/system.management.automation.pscredential)object and the password is stored as a SecureString (/dotnet/api/system.security.securestring).</maml:para> <maml:para>> [!NOTE] > For more information about SecureString data protection, see > How secure is SecureString? (/dotnet/api/system.security.securestring#how-secure-is-securestring).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSCredential</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSCredential</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisableKeepAlive</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sets the KeepAlive value in the HTTP header to False . By default, KeepAlive is True . KeepAlive establishes a persistent connection to the server to facilitate subsequent requests.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Headers</maml:name> <maml:Description> <maml:para>Specifies the headers of the web request. Enter a hash table or dictionary.</maml:para> <maml:para>To set UserAgent headers, use the UserAgent parameter. You cannot use this parameter to specify UserAgent or cookie headers.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Collections.IDictionary</command:parameterValue> <dev:type> <maml:name>System.Collections.IDictionary</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>InFile</maml:name> <maml:Description> <maml:para>Gets the content of the web request from a file.</maml:para> <maml:para>Enter a path and file name. If you omit the path, the default is the current location.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>MaximumRedirection</maml:name> <maml:Description> <maml:para>Specifies how many times PowerShell redirects a connection to an alternate Uniform Resource Identifier (URI) before the connection fails. The default value is 5. A value of 0 (zero) prevents all redirection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Method</maml:name> <maml:Description> <maml:para>Specifies the method used for the web request. The acceptable values for this parameter are:</maml:para> <maml:para>- Default</maml:para> <maml:para>- Delete</maml:para> <maml:para>- Get</maml:para> <maml:para>- Head</maml:para> <maml:para>- Merge</maml:para> <maml:para>- Options</maml:para> <maml:para>- Patch</maml:para> <maml:para>- Post</maml:para> <maml:para>- Put</maml:para> <maml:para>- Trace</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.WebRequestMethod</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.WebRequestMethod</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>OutFile</maml:name> <maml:Description> <maml:para>Specifies the output file for which this cmdlet saves the response body. Enter a path and file name. If you omit the path, the default is the current location.</maml:para> <maml:para>By default, `Invoke-WebRequest` returns the results to the pipeline. To send the results to a file and to the pipeline, use the Passthru parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet returns the results, in addition to writing them to a file. This parameter is valid only when the OutFile parameter is also used in the command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Proxy</maml:name> <maml:Description> <maml:para>Specifies a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Uri</command:parameterValue> <dev:type> <maml:name>System.Uri</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ProxyCredential</maml:name> <maml:Description> <maml:para>Specifies a user account that has permission to use the proxy server that is specified by the Proxy parameter. The default is the current user.</maml:para> <maml:para>Type a user name, such as `User01` or `Domain01\User01`, or enter a PSCredential object, such as one generated by the `Get-Credential` cmdlet.</maml:para> <maml:para>This parameter is valid only when the Proxy parameter is also used in the command. You cannot use the ProxyCredential and ProxyUseDefaultCredentials parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSCredential</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSCredential</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ProxyUseDefaultCredentials</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet uses the credentials of the current user to access the proxy server that is specified by the Proxy parameter.</maml:para> <maml:para>This parameter is valid only when the Proxy parameter is also used in the command. You cannot use the ProxyCredential and ProxyUseDefaultCredentials parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="SV"> <maml:name>SessionVariable</maml:name> <maml:Description> <maml:para>Specifies a variable for which this cmdlet creates a web request session and saves it in the value. Enter a variable name without the dollar sign (`$`) symbol.</maml:para> <maml:para>When you specify a session variable, `Invoke-WebRequest` creates a web request session object and assigns it to a variable with the specified name in your PowerShell session. You can use the variable in your session as soon as the command completes.</maml:para> <maml:para>Unlike a remote session, the web request session is not a persistent connection. It is an object that contains information about the connection and the request, including cookies, credentials, the maximum redirection value, and the user agent string. You can use it to share state and data among web requests.</maml:para> <maml:para>To use the web request session in subsequent web requests, specify the session variable in the value of the WebSession parameter. PowerShell uses the data in the web request session object when establishing the new connection. To override a value in the web request session, use a cmdlet parameter, such as UserAgent or Credential . Parameter values take precedence over values in the web request session.</maml:para> <maml:para>You cannot use the SessionVariable and WebSession parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TimeoutSec</maml:name> <maml:Description> <maml:para>Specifies how long the request can be pending before it times out. Enter a value in seconds. The default value, 0, specifies an indefinite time-out.</maml:para> <maml:para>A Domain Name System (DNS) query can take up to 15 seconds to return or time out. If your request contains a host name that requires resolution, and you set TimeoutSec to a value greater than zero, but less than 15 seconds, it can take 15 seconds or more before a WebException is thrown, and your request times out.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TransferEncoding</maml:name> <maml:Description> <maml:para>Specifies a value for the transfer-encoding HTTP response header. The acceptable values for this parameter are:</maml:para> <maml:para>- Chunked</maml:para> <maml:para>- Compress</maml:para> <maml:para>- Deflate</maml:para> <maml:para>- GZip</maml:para> <maml:para>- Identity</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Uri</maml:name> <maml:Description> <maml:para>Specifies the Uniform Resource Identifier (URI) of the Internet resource to which the web request is sent. Enter a URI. This parameter supports HTTP, HTTPS, FTP, and FILE values.</maml:para> <maml:para>This parameter is required.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Uri</command:parameterValue> <dev:type> <maml:name>System.Uri</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseBasicParsing</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet uses the response object for HTML content without Document Object Model (DOM) parsing. This parameter is required when Internet Explorer is not installed on the computers, such as on a Server Core installation of a Windows Server operating system.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseDefaultCredentials</maml:name> <maml:Description> <maml:para>Indicates that the cmdet uses the credentials of the current user to send the web request.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UserAgent</maml:name> <maml:Description> <maml:para>Specifies a user agent string for the web request. The default user agent is similar to `Mozilla/5.0 (Windows NT; Windows NT 6.1; en-US) WindowsPowerShell/3.0` with slight variations for each operating system and platform.</maml:para> <maml:para>To test a website with the standard user agent string that is used by most Internet browsers, use the properties of the PSUserAgent (/dotnet/api/microsoft.powershell.commands.psuseragent)class, such as Chrome, FireFox, InternetExplorer, Opera, and Safari. For example, the following command uses the user agent string for Internet Explorer</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>WebSession</maml:name> <maml:Description> <maml:para>Specifies a web request session. Enter the variable name, including the dollar sign (`$`).</maml:para> <maml:para>To override a value in the web request session, use a cmdlet parameter, such as UserAgent or Credential . Parameter values take precedence over values in the web request session.</maml:para> <maml:para>Unlike a remote session, the web request session is not a persistent connection. It is an object that contains information about the connection and the request, including cookies, credentials, the maximum redirection value, and the user agent string. You can use it to share state and data among web requests.</maml:para> <maml:para>To create a web request session, enter a variable name (without a dollar sign) in the value of the SessionVariable parameter of an `Invoke-WebRequest` command. `Invoke-WebRequest` creates the session and saves it in the variable. In subsequent commands, use the variable as the value of the WebSession parameter.</maml:para> <maml:para>You cannot use the SessionVariable and WebSession parameters in the same command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.WebRequestSession</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.WebRequestSession</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Object</maml:name> </dev:type> <maml:description> <maml:para>You can pipe the body of a web request to `Invoke-WebRequest`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.HtmlWebResponseObject</maml:name> </dev:type> <maml:description> <maml:para></maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>---------------- Example 1: Send a web request ----------------</maml:title> <dev:code>$R = Invoke-WebRequest -URI https://www.bing.com?q=how+many+feet+in+a+mile $R.AllElements | Where-Object { $_.name -like "* Value" -and $_.tagName -eq "INPUT" } | Select-Object Name, Value name value ---- ----- From Value 1 To Value 5280</dev:code> <dev:remarks> <maml:para>The first command issues the request and saves the response in the `$R` variable.</maml:para> <maml:para>The second command filters the objects in the AllElements property where the name property is like " Value" and the tagName * is "INPUT". The filtered results are piped to `Select-Object` to select the name and value properties.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------ Example 2: Use a stateful web service ------------</maml:title> <dev:code>$R = Invoke-WebRequest https://www.facebook.com/login.php -SessionVariable fb # This command stores the first form in the Forms property of the $R variable in the $Form variable. $Form = $R.Forms[0] # This command shows the fields available in the Form. $Form.fields Key Value --- ----- ... email pass ... # These commands populate the username and password of the respective Form fields. $Form.Fields["email"]="User01@Fabrikam.com" $Form.Fields["pass"]="P@ssw0rd" # This command creates the Uri that will be used to log in to facebook. # The value of the Uri parameter is the value of the Action property of the form. $Uri = "https://www.facebook.com" + $Form.Action # Now the Invoke-WebRequest cmdlet is used to sign into the Facebook web service. # The WebRequestSession object in the $FB variable is passed as the value of the WebSession parameter. # The value of the Body parameter is the hash table in the Fields property of the form. # The value of the *Method* parameter is POST. The command saves the output in the $R variable. $R = Invoke-WebRequest -Uri $Uri -WebSession $FB -Method POST -Body $Form.Fields $R.StatusDescription</dev:code> <dev:remarks> <maml:para>The first command uses the `Invoke-WebRequest` cmdlet to send a sign-in request. The command specifies a value of "FB" for the value of the SessionVariable parameter, and saves the result in the `$R` variable. When the command completes, the `$R` variable contains an HtmlWebResponseObject and the `$FB` variable contains a WebRequestSession object.</maml:para> <maml:para>After the `Invoke-WebRequest` cmdlet signs in to facebook, the StatusDescription property of the web response object in the `$R` variable indicates that the user is signed in successfully.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------- Example 3: Get links from a web page -------------</maml:title> <dev:code>(Invoke-WebRequest -Uri "https://devblogs.microsoft.com/powershell/").Links.Href</dev:code> <dev:remarks> <maml:para>The `Invoke-WebRequest` cmdlet gets the web page content. Then the Links property of the returned HtmlWebResponseObject is used to display the Href property of each link.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>- Example 4: Catch non success messages from Invoke-WebRequest -</maml:title> <dev:code>try { $response = Invoke-WebRequest -Uri "www.microsoft.com/unkownhost" -ErrorAction Stop # This will only execute if the Invoke-WebRequest is successful. $StatusCode = $Response.StatusCode } catch { $StatusCode = $_.Exception.Response.StatusCode.value__ } $StatusCode 404</dev:code> <dev:remarks> <maml:para>The first command calls `Invoke-WebRequest` with an ErrorAction of Stop , which forces `Invoke-WebRequest` to throw a terminating error on any failed requests. The terminating error is caught by the `catch` block which retrieves the StatusCode from the Exception object.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Invoke-RestMethod</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertFrom-Json</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-Json</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Measure-Command</command:name> <command:verb>Measure</command:verb> <command:noun>Command</command:noun> <maml:description> <maml:para>Measures the time it takes to run script blocks and cmdlets.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Measure-Command` cmdlet runs a script block or cmdlet internally, times the execution of the operation, and returns the execution time.</maml:para> <maml:para>> [!NOTE] > Script blocks run by `Measure-Command` run in the current scope, not a child scope.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Measure-Command</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Expression</maml:name> <maml:Description> <maml:para>Specifies the expression that is being timed. Enclose the expression in braces (`{}`).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScriptBlock</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Objects bound to the InputObject parameter are optional input for the script block passed to the Expression parameter. Inside the script block, `$_` can be used to reference the current object in the pipeline.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Expression</maml:name> <maml:Description> <maml:para>Specifies the expression that is being timed. Enclose the expression in braces (`{}`).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScriptBlock</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Objects bound to the InputObject parameter are optional input for the script block passed to the Expression parameter. Inside the script block, `$_` can be used to reference the current object in the pipeline.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe an object to `Measure-Command`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.TimeSpan</maml:name> </dev:type> <maml:description> <maml:para>`Measure-Command` returns a time span object that represents the result.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>----------------- Example 1: Measure a command -----------------</maml:title> <dev:code>Measure-Command { Get-EventLog "windows powershell" }</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 2: Compare two outputs from Measure-Command -----</maml:title> <dev:code>Measure-Command { Get-ChildItem -Path C:\Windows\*.txt -Recurse } Days : 0 Hours : 0 Minutes : 0 Seconds : 8 Milliseconds : 618 Ticks : 86182763 TotalDays : 9.9748568287037E-05 TotalHours : 0.00239396563888889 TotalMinutes : 0.143637938333333 TotalSeconds : 8.6182763 TotalMilliseconds : 8618.2763 Measure-Command {Get-ChildItem C:\Windows -Filter "*.txt" -Recurse} Days : 0 Hours : 0 Minutes : 0 Seconds : 1 Milliseconds : 140 Ticks : 11409189 TotalDays : 1.32050798611111E-05 TotalHours : 0.000316921916666667 TotalMinutes : 0.019015315 TotalSeconds : 1.1409189 TotalMilliseconds : 1140.9189</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 3: Piping input to Measure-Command ----------</maml:title> <dev:code># Perform a simple operation to demonstrate the InputObject parameter # Note that no output is displayed. 10, 20, 50 | Measure-Command -Expression { for ($i=0; $i -lt $_ i++) {$i} } Days : 0 Hours : 0 Minutes : 0 Seconds : 0 Milliseconds : 12 Ticks : 122672 TotalDays : 1.41981481481481E-07 TotalHours : 3.40755555555556E-06 TotalMinutes : 0.000204453333333333 TotalSeconds : 0.0122672 TotalMilliseconds : 12.2672</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 4: Displaying output of measured command -------</maml:title> <dev:code># Perform the same operation as above adding Out-Default to every execution. # This will show that the ScriptBlock is in fact executing for every item. 10, 20, 50 | Measure-Command -Expression {for ($i=0; $i -lt $_; $i++) {$i}; "$($_)" | Out-Default } 10 20 50 Days : 0 Hours : 0 Minutes : 0 Seconds : 0 Milliseconds : 11 Ticks : 113745 TotalDays : 1.31649305555556E-07 TotalHours : 3.15958333333333E-06 TotalMinutes : 0.000189575 TotalSeconds : 0.0113745 TotalMilliseconds : 11.3745</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 5: Measuring execution in a child scope -------</maml:title> <dev:code>$foo = 'Value 1' $null = Measure-Command { $foo = 'Value 2' } $foo $null = Measure-Command { & { $foo = 'Value 3' } } $foo Value 2 Value 2</dev:code> <dev:remarks> <maml:para>For more information about the invocation operator, see about_Operators (../Microsoft.PowerShell.Core/About/about_Operators.md#call-operator-).</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/measure-command?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Invoke-Command</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Trace-Command</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Measure-Object</command:name> <command:verb>Measure</command:verb> <command:noun>Object</command:noun> <maml:description> <maml:para>Calculates the numeric properties of objects, and the characters, words, and lines in string objects, such as files of text.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Measure-Object` cmdlet calculates the property values of certain types of object. `Measure-Object` performs three types of measurements, depending on the parameters in the command.</maml:para> <maml:para>The `Measure-Object` cmdlet performs calculations on the property values of objects. You can use `Measure-Object` to count objects or count objects with a specified Property . You can also use `Measure-Object` to calculate the Minimum , Maximum , Sum , StandardDeviation and Average of numeric values. For String objects, you can also use `Measure-Object` to count the number of lines, words, and characters.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Measure-Object</maml:name> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies one or more properties to measure. If you do not specify any other measures, `Measure-Object` counts the objects that have the properties you specify.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Average</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet displays the average value of the specified properties.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be measured. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> <maml:para>When you use the InputObject parameter with `Measure-Object`, instead of piping command results to `Measure-Object`, the InputObject value is treated as a single object.</maml:para> <maml:para>It is recommended that you use `Measure-Object` in the pipeline if you want to measure a collection of objects based on whether the objects have specific values in defined properties.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Maximum</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet displays the maximum value of the specified properties.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Minimum</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet displays the minimum value of the specified properties.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Sum</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet displays the sum of the values of the specified properties.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Measure-Object</maml:name> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies one or more properties to measure. If you do not specify any other measures, `Measure-Object` counts the objects that have the properties you specify.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Character</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet counts the number of characters in the input objects.</maml:para> <maml:para>> [!NOTE] > The Word , Char and Line switches count inside each input object, as well as across > input objects. See Example 7.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>IgnoreWhiteSpace</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet ignores white space in character counts. By default, white space is not ignored.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be measured. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> <maml:para>When you use the InputObject parameter with `Measure-Object`, instead of piping command results to `Measure-Object`, the InputObject value is treated as a single object.</maml:para> <maml:para>It is recommended that you use `Measure-Object` in the pipeline if you want to measure a collection of objects based on whether the objects have specific values in defined properties.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Line</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet counts the number of lines in the input objects.</maml:para> <maml:para>> [!NOTE] > The Word , Char and Line switches count inside each input object, as well as across > input objects. See Example 7.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Word</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet counts the number of words in the input objects.</maml:para> <maml:para>> [!NOTE] > The Word , Char and Line switches count inside each input object, as well as across > input objects. See Example 7.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Average</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet displays the average value of the specified properties.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Character</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet counts the number of characters in the input objects.</maml:para> <maml:para>> [!NOTE] > The Word , Char and Line switches count inside each input object, as well as across > input objects. See Example 7.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>IgnoreWhiteSpace</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet ignores white space in character counts. By default, white space is not ignored.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be measured. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> <maml:para>When you use the InputObject parameter with `Measure-Object`, instead of piping command results to `Measure-Object`, the InputObject value is treated as a single object.</maml:para> <maml:para>It is recommended that you use `Measure-Object` in the pipeline if you want to measure a collection of objects based on whether the objects have specific values in defined properties.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Line</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet counts the number of lines in the input objects.</maml:para> <maml:para>> [!NOTE] > The Word , Char and Line switches count inside each input object, as well as across > input objects. See Example 7.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Maximum</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet displays the maximum value of the specified properties.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Minimum</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet displays the minimum value of the specified properties.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies one or more properties to measure. If you do not specify any other measures, `Measure-Object` counts the objects that have the properties you specify.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Sum</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet displays the sum of the values of the specified properties.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Word</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet counts the number of words in the input objects.</maml:para> <maml:para>> [!NOTE] > The Word , Char and Line switches count inside each input object, as well as across > input objects. See Example 7.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe objects to `Measure-Object`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.GenericMeasureInfo, Microsoft.PowerShell.Commands.TextMeasureInfo, Microsoft.PowerShell.Commands.GenericObjectMeasureInfo</maml:name> </dev:type> <maml:description> <maml:para>If you use the Word parameter, `Measure-Object` returns a TextMeasureInfo object. Otherwise, it returns a GenericMeasureInfo object.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>---- Example 1: Count the files and folders in a directory ----</maml:title> <dev:code>Get-ChildItem | Measure-Object</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 2: Measure the files in a directory ---------</maml:title> <dev:code>Get-ChildItem | Measure-Object -Property length -Minimum -Maximum -Average</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------ Example 3: Measure text in a text file ------------</maml:title> <dev:code>"One", "Two", "Three", "Four" | Set-Content -Path C:\Temp\tmp.txt Get-Content C:\Temp\tmp.txt | Measure-Object -Character -Line -Word Lines Words Characters Property ----- ----- ---------- -------- 4 4 15</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 4: Measure objects containing a specified Property --</maml:title> <dev:code>$services = Get-Service $processes = Get-Process $services + $processes | Measure-Object $services + $processes | Measure-Object -Property DisplayName Count : 682 Average : Sum : Maximum : Minimum : Property : Count : 290 Average : Sum : Maximum : Minimum : Property : DisplayName</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 5: Measure the contents of a CSV file --------</maml:title> <dev:code>Import-Csv d:\test\serviceyrs.csv | Measure-Object -Property years -Minimum -Maximum -Average</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------------- Example 6: Measure Boolean values --------------</maml:title> <dev:code>Get-ChildItem | Measure-Object -Property psiscontainer -Maximum -Sum -Minimum -Average Count : 126 Average : 0.0634920634920635 Sum : 8 Maximum : 1 Minimum : 0 StandardDeviation : Property : PSIsContainer</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------------ Example 7: Measure strings ------------------</maml:title> <dev:code># The newline character `n separates the string into separate lines, as shown in the output. "One`nTwo`nThree" "One`nTwo`nThree" | Measure-Object -Line One Two Three Lines Words Characters Property ----- ----- ---------- -------- 3 # The first string counts as a single line. # The second string is separated into two lines by the newline character. "One", "Two`nThree" | Measure-Object -Line Lines Words Characters Property ----- ----- ---------- -------- 3 # The Word switch counts the number of words in each InputObject # Each InputObject is treated as a single line. "One, Two", "Three", "Four Five" | Measure-Object -Word -Line Lines Words Characters Property ----- ----- ---------- -------- 3 5</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/measure-object?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Compare-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ForEach-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Group-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Select-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Sort-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Tee-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Where-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>New-Alias</command:name> <command:verb>New</command:verb> <command:noun>Alias</command:noun> <maml:description> <maml:para>Creates a new alias.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The New-Alias cmdlet creates a new alias in the current Windows PowerShell session. Aliases created by using New-Alias are not saved after you exit the session or close Windows PowerShell. You can use the Export-Alias cmdlet to save your alias information to a file. You can later use Import-Alias to retrieve that saved alias information.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>New-Alias</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the new alias. You can use any alphanumeric characters in an alias, but the first character cannot be a number.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> <maml:name>Value</maml:name> <maml:Description> <maml:para>Specifies the name of the cmdlet or command element that is being aliased.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Description</maml:name> <maml:Description> <maml:para>Specifies a description of the alias. You can type any string. If the description includes spaces, enclose it in quotation marks.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet acts like Set-Alias if the alias named already exists.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Option</maml:name> <maml:Description> <maml:para>Specifies the value of the Options property of the alias. Valid values are:</maml:para> <maml:para>- None: The alias has no constraints (default value)</maml:para> <maml:para>- ReadOnly: The alias can be deleted but cannot be changed except by using the Force parameter - Constant: The alias cannot be deleted or changed</maml:para> <maml:para>- Private: The alias is available only in the current scope</maml:para> <maml:para>- AllScope: The alias is copied to any new scopes that are created</maml:para> <maml:para>- Unspecified: The option is not specified</maml:para> <maml:para></maml:para> <maml:para>To see the Options property of all aliases in the session, type `Get-Alias | Format-Table -Property Name, Options -AutoSize`.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">None</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ReadOnly</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Constant</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Private</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">AllScope</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unspecified</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScopedItemOptions</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScopedItemOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>[System.Management.Automation.ScopedItemOptions]::None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope of the new alias. The acceptable values for this parameter are:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Script</maml:para> <maml:para>- A number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent).</maml:para> <maml:para></maml:para> <maml:para>Local is the default. For more information, see about_Scopes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Description</maml:name> <maml:Description> <maml:para>Specifies a description of the alias. You can type any string. If the description includes spaces, enclose it in quotation marks.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet acts like Set-Alias if the alias named already exists.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the new alias. You can use any alphanumeric characters in an alias, but the first character cannot be a number.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Option</maml:name> <maml:Description> <maml:para>Specifies the value of the Options property of the alias. Valid values are:</maml:para> <maml:para>- None: The alias has no constraints (default value)</maml:para> <maml:para>- ReadOnly: The alias can be deleted but cannot be changed except by using the Force parameter - Constant: The alias cannot be deleted or changed</maml:para> <maml:para>- Private: The alias is available only in the current scope</maml:para> <maml:para>- AllScope: The alias is copied to any new scopes that are created</maml:para> <maml:para>- Unspecified: The option is not specified</maml:para> <maml:para></maml:para> <maml:para>To see the Options property of all aliases in the session, type `Get-Alias | Format-Table -Property Name, Options -AutoSize`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScopedItemOptions</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScopedItemOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>[System.Management.Automation.ScopedItemOptions]::None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope of the new alias. The acceptable values for this parameter are:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Script</maml:para> <maml:para>- A number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent).</maml:para> <maml:para></maml:para> <maml:para>Local is the default. For more information, see about_Scopes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> <maml:name>Value</maml:name> <maml:Description> <maml:para>Specifies the name of the cmdlet or command element that is being aliased.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe input to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None or System.Management.Automation.AliasInfo</maml:name> </dev:type> <maml:description> <maml:para>When you use the Passthru parameter, New-Alias generates a System.Management.Automation.AliasInfo object representing the new alias. Otherwise, this cmdlet does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>To create a new alias, use Set-Alias or New-Alias. To change an alias, use Set-Alias *. To delete an alias, use Remove-Item.</maml:para> <maml:para>*</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>----------- Example 1: Create an alias for a cmdlet -----------</maml:title> <dev:code>PS C:\> New-Alias -Name "List" Get-ChildItem</dev:code> <dev:remarks> <maml:para>This command creates an alias named List to represent the Get-ChildItem cmdlet.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 2: Create a read-only alias for a cmdlet -------</maml:title> <dev:code>PS C:\> New-Alias -Name "W" -Value Get-WmiObject -Description "quick wmi alias" -Option ReadOnly PS C:\> Get-Alias -Name "W" | Format-List *</dev:code> <dev:remarks> <maml:para>This command creates an alias named W to represent the Get-WmiObject cmdlet. It creates a description, quick wmi alias, for the alias and makes it read-only. The last line of the command uses Get-Alias to get the new alias and pipes it to Format-List to display all of the information about it.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/new-alias?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Export-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Import-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>New-Event</command:name> <command:verb>New</command:verb> <command:noun>Event</command:noun> <maml:description> <maml:para>Creates a new event.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The New-Event cmdlet creates a new custom event.</maml:para> <maml:para>You can use custom events to notify users about state changes in your program and any change that your program can detect, including hardware or system conditions, application status, disk status, network status, or the completion of a background job.</maml:para> <maml:para>Custom events are automatically added to the event queue in your session whenever they are raised; you do not need to subscribe to them. However, if you want to forward an event to the local session or specify an action to respond to the event, use the Register-EngineEvent cmdlet to subscribe to the custom event.</maml:para> <maml:para>When you subscribe to a custom event, the event subscriber is added to your session. If you cancel the event subscription by using the Unregister-Event cmdlet, the event subscriber and custom event are deleted from the session. If you do not subscribe to the custom event, to delete the event, you must change the program conditions or close the Windows PowerShell session.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>New-Event</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>SourceIdentifier</maml:name> <maml:Description> <maml:para>Specifies a name for the new event. This parameter is required, and it must be unique in the session.</maml:para> <maml:para>The value of this parameter appears in the SourceIdentifier property of the events.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Sender</maml:name> <maml:Description> <maml:para>Specifies the object that raises the event. The default is the Windows PowerShell engine.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none"> <maml:name>EventArguments</maml:name> <maml:Description> <maml:para>Specifies an object that contains options for the event.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="3" aliases="none"> <maml:name>MessageData</maml:name> <maml:Description> <maml:para>Specifies additional data associated with the event. The value of this parameter appears in the MessageData property of the event object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none"> <maml:name>EventArguments</maml:name> <maml:Description> <maml:para>Specifies an object that contains options for the event.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="3" aliases="none"> <maml:name>MessageData</maml:name> <maml:Description> <maml:para>Specifies additional data associated with the event. The value of this parameter appears in the MessageData property of the event object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Sender</maml:name> <maml:Description> <maml:para>Specifies the object that raises the event. The default is the Windows PowerShell engine.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>SourceIdentifier</maml:name> <maml:Description> <maml:para>Specifies a name for the new event. This parameter is required, and it must be unique in the session.</maml:para> <maml:para>The value of this parameter appears in the SourceIdentifier property of the events.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe input to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.PSEventArgs</maml:name> </dev:type> <maml:description> <maml:para></maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>The new custom event, the event subscription, and the event queue exist only in the current session. If you close the current session, the event queue is discarded and the event subscription is canceled.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------- Example 1: Create a new event in the event queue -------</maml:title> <dev:code>PS C:\> New-Event -SourceIdentifier Timer -Sender windows.timer -MessageData "Test"</dev:code> <dev:remarks> <maml:para>This command creates a new event in the Windows PowerShell event queue. It uses a Windows.Timer object to send the event.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 2: Raise an event in response to another event ----</maml:title> <dev:code>PS C:\> function Enable-ProcessCreationEvent { $Query = New-Object System.Management.WqlEventQuery "__InstanceCreationEvent", (New-Object TimeSpan 0,0,1), "TargetInstance isa 'Win32_Process'" $ProcessWatcher = New-Object System.Management.ManagementEventWatcher $Query $Identifier = "WMI.ProcessCreated" Register-ObjectEvent $ProcessWatcher "EventArrived" -SupportEvent $Identifier -Action { [void] (New-Event -SourceID "PowerShell.ProcessCreated" -Sender $Args[0] -EventArguments $Args[1].SourceEventArgs.NewEvent.TargetInstance) } }</dev:code> <dev:remarks> <maml:para>This sample function uses the New-Event cmdlet to raise an event in response to another event. The command uses the Register-ObjectEvent cmdlet to subscribe to the Windows Management Instrumentation (WMI) event that is raised when a new process is created. The command uses the Action parameter of the cmdlet to call the New-Event cmdlet, which creates the new event.</maml:para> <maml:para>Because the events that New-Event raises are automatically added to the Windows PowerShellevent queue, you do not need to register for that event.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/new-event?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-EngineEvent</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-ObjectEvent</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Unregister-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Wait-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>New-Object</command:name> <command:verb>New</command:verb> <command:noun>Object</command:noun> <maml:description> <maml:para>Creates an instance of a Microsoft .NET Framework or COM object.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `New-Object` cmdlet creates an instance of a .NET Framework or COM object.</maml:para> <maml:para>You can specify either the type of a .NET Framework class or a ProgID of a COM object. By default, you type the fully qualified name of a .NET Framework class and the cmdlet returns a reference to an instance of that class. To create an instance of a COM object, use the ComObject parameter and specify the ProgID of the object as its value.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>New-Object</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>TypeName</maml:name> <maml:Description> <maml:para>Specifies the fully qualified name of the .NET Framework class. You cannot specify both the TypeName parameter and the ComObject parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="Args"> <maml:name>ArgumentList</maml:name> <maml:Description> <maml:para>Specifies an array of arguments to pass to the constructor of the .NET Framework class. If the constructor takes a single parameter that is an array, you must wrap that parameter inside another array. For example:</maml:para> <maml:para>`$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate -ArgumentList (,$bytes)`</maml:para> <maml:para>For more information about the behavior of ArgumentList , see about_Splatting (../Microsoft.PowerShell.Core/About/about_Splatting.md#splatting-with-arrays).</maml:para> <maml:para>The alias for ArgumentList is Args .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Sets property values and invokes methods of the new object.</maml:para> <maml:para>Enter a hash table in which the keys are the names of properties or methods and the values are property values or method arguments. `New-Object` creates the object and sets each property value and invokes each method in the order that they appear in the hash table.</maml:para> <maml:para>If the new object is derived from the PSObject class, and you specify a property that does not exist on the object, `New-Object` adds the specified property to the object as a NoteProperty. If the object is not a PSObject , the command generates a non-terminating error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Collections.IDictionary</command:parameterValue> <dev:type> <maml:name>System.Collections.IDictionary</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-Object</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>ComObject</maml:name> <maml:Description> <maml:para>Specifies the programmatic identifier (ProgID) of the COM object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Sets property values and invokes methods of the new object.</maml:para> <maml:para>Enter a hash table in which the keys are the names of properties or methods and the values are property values or method arguments. `New-Object` creates the object and sets each property value and invokes each method in the order that they appear in the hash table.</maml:para> <maml:para>If the new object is derived from the PSObject class, and you specify a property that does not exist on the object, `New-Object` adds the specified property to the object as a NoteProperty. If the object is not a PSObject , the command generates a non-terminating error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Collections.IDictionary</command:parameterValue> <dev:type> <maml:name>System.Collections.IDictionary</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Strict</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet generates a non-terminating error when a COM object that you attempt to create uses an interop assembly. This feature distinguishes actual COM objects from .NET Framework objects with COM-callable wrappers.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="Args"> <maml:name>ArgumentList</maml:name> <maml:Description> <maml:para>Specifies an array of arguments to pass to the constructor of the .NET Framework class. If the constructor takes a single parameter that is an array, you must wrap that parameter inside another array. For example:</maml:para> <maml:para>`$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate -ArgumentList (,$bytes)`</maml:para> <maml:para>For more information about the behavior of ArgumentList , see about_Splatting (../Microsoft.PowerShell.Core/About/about_Splatting.md#splatting-with-arrays).</maml:para> <maml:para>The alias for ArgumentList is Args .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>ComObject</maml:name> <maml:Description> <maml:para>Specifies the programmatic identifier (ProgID) of the COM object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Sets property values and invokes methods of the new object.</maml:para> <maml:para>Enter a hash table in which the keys are the names of properties or methods and the values are property values or method arguments. `New-Object` creates the object and sets each property value and invokes each method in the order that they appear in the hash table.</maml:para> <maml:para>If the new object is derived from the PSObject class, and you specify a property that does not exist on the object, `New-Object` adds the specified property to the object as a NoteProperty. If the object is not a PSObject , the command generates a non-terminating error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Collections.IDictionary</command:parameterValue> <dev:type> <maml:name>System.Collections.IDictionary</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Strict</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet generates a non-terminating error when a COM object that you attempt to create uses an interop assembly. This feature distinguishes actual COM objects from .NET Framework objects with COM-callable wrappers.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>TypeName</maml:name> <maml:Description> <maml:para>Specifies the fully qualified name of the .NET Framework class. You cannot specify both the TypeName parameter and the ComObject parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe input to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Object</maml:name> </dev:type> <maml:description> <maml:para>`New-Object` returns the object that is created.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>- `New-Object` provides the most commonly-used functionality of the VBScript CreateObject function. A statement like `Set objShell = CreateObject("Shell.Application")` in VBScript can be translated to `$objShell = New-Object -COMObject "Shell.Application"` in PowerShell. - `New-Object` expands upon the functionality available in the Windows Script Host environment by making it easy to work with .NET Framework objects from the command line and within scripts.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>---------- Example 1: Create a System.Version object ----------</maml:title> <dev:code>New-Object -TypeName System.Version -ArgumentList "1.2.3.4" Major Minor Build Revision ----- ----- ----- -------- 1 2 3 4</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 2: Create an Internet Explorer COM object ------</maml:title> <dev:code>$IE1 = New-Object -COMObject InternetExplorer.Application -Property @{Navigate2="www.microsoft.com"; Visible = $True} # The following command gets the same results as the example above. $IE2 = New-Object -COMObject InternetExplorer.Application` $IE2.Navigate2("www.microsoft.com")` $IE2.Visible = $True`</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 3: Use the Strict parameter to generate a non-terminating error</maml:title> <dev:code>$A = New-Object -COMObject Word.Application -Strict -Property @{Visible = $True} New-Object : The object written to the pipeline is an instance of the type "Microsoft.Office.Interop.Word.ApplicationClass" from the component's primary interop assembly. If this type exposes different members than the IDispatch members, scripts written to work with this object might not work if the primary interop assembly is not installed. At line:1 char:14 + $A = New-Object <<<< -COM Word.Application -Strict; $a.visible=$true</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--- Example 4: Create a COM object to manage Windows desktop ---</maml:title> <dev:code>$Objshell = New-Object -COMObject "Shell.Application" $objshell | Get-Member $objshell.ToggleDesktop() TypeName: System.__ComObject#{866738b9-6cf2-4de8-8767-f794ebe74f4e} Name MemberType Definition ---- ---------- ---------- AddToRecent Method void AddToRecent (Variant, string) BrowseForFolder Method Folder BrowseForFolder (int, string, int, Variant) CanStartStopService Method Variant CanStartStopService (string) CascadeWindows Method void CascadeWindows () ControlPanelItem Method void ControlPanelItem (string) EjectPC Method void EjectPC () Explore Method void Explore (Variant) ExplorerPolicy Method Variant ExplorerPolicy (string) FileRun Method void FileRun () FindComputer Method void FindComputer () FindFiles Method void FindFiles () FindPrinter Method void FindPrinter (string, string, string) GetSetting Method bool GetSetting (int) GetSystemInformation Method Variant GetSystemInformation (string) Help Method void Help () IsRestricted Method int IsRestricted (string, string) IsServiceRunning Method Variant IsServiceRunning (string) MinimizeAll Method void MinimizeAll () NameSpace Method Folder NameSpace (Variant) Open Method void Open (Variant) RefreshMenu Method void RefreshMenu () ServiceStart Method Variant ServiceStart (string, Variant) ServiceStop Method Variant ServiceStop (string, Variant) SetTime Method void SetTime () ShellExecute Method void ShellExecute (string, Variant, Variant, Variant, Variant) ShowBrowserBar Method Variant ShowBrowserBar (string, Variant) ShutdownWindows Method void ShutdownWindows () Suspend Method void Suspend () TileHorizontally Method void TileHorizontally () TileVertically Method void TileVertically () ToggleDesktop Method void ToggleDesktop () TrayProperties Method void TrayProperties () UndoMinimizeALL Method void UndoMinimizeALL () Windows Method IDispatch Windows () WindowsSecurity Method void WindowsSecurity () WindowSwitcher Method void WindowSwitcher () Application Property IDispatch Application () {get} Parent Property IDispatch Parent () {get}</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 5: Pass multiple arguments to a constructor -----</maml:title> <dev:code>$array = @('One', 'Two', 'Three') $parameters = @{ TypeName = 'System.Collections.Generic.HashSet[string]' ArgumentList = ([string[]]$array, [System.StringComparer]::OrdinalIgnoreCase) } $set = New-Object @parameters</dev:code> <dev:remarks> <maml:para>PowerShell binds each member of the array to a parameter of the constructor.</maml:para> <maml:para>> [!NOTE] > This example uses parameter splatting for readability. For more information, see > about_Splatting (../Microsoft.PowerShell.Core/About/about_Splatting.md).</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 6: Calling a constructor that takes an array as a single parameter</maml:title> <dev:code>$array = @('One', 'Two', 'Three') # This command throws an exception. $set = New-Object -TypeName 'System.Collections.Generic.HashSet[string]' -ArgumentList $array # This command succeeds. $set = New-Object -TypeName 'System.Collections.Generic.HashSet[string]' -ArgumentList (,[string[]]$array) $set New-Object : Cannot find an overload for "HashSet`1" and the argument count: "3". At line:1 char:8 + $set = New-Object -TypeName 'System.Collections.Generic.HashSet[strin ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [New-Object], MethodException + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand One Two Three</dev:code> <dev:remarks> <maml:para>The first attempt to create the object in this example fails. PowerShell attempted to bind the three members of `$array` to parameters of the constructor but the constructor does not take three parameter. Wrapping `$array` in another array prevents PowerShell from attempting to bind the three members of `$array` to parameters of the constructor.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/new-object?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Object_Creation</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Compare-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Group-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Measure-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Select-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Sort-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Tee-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>New-TimeSpan</command:name> <command:verb>New</command:verb> <command:noun>TimeSpan</command:noun> <maml:description> <maml:para>Creates a TimeSpan object.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `New-TimeSpan` cmdlet creates a TimeSpan object that represents a time interval. You can use a TimeSpan object to add or subtract time from DateTime objects.</maml:para> <maml:para>Without parameters, a `New-TimeSpan` command returns a TimeSpan object that represents a time interval of zero.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>New-TimeSpan</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Days</maml:name> <maml:Description> <maml:para>Specifies the days in the time span. The default value is 0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Hours</maml:name> <maml:Description> <maml:para>Specifies the hours in the time span. The default value is zero.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Minutes</maml:name> <maml:Description> <maml:para>Specifies the minutes in the time span. The default value is 0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Seconds</maml:name> <maml:Description> <maml:para>Specifies the length of the time span in seconds. The default value is 0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-TimeSpan</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="LastWriteTime"> <maml:name>Start</maml:name> <maml:Description> <maml:para>Specifies the start of a time span. Enter a string that represents the date and time, such as "3/15/09" or a DateTime object, such as one from a `Get-Date` command. The default value is the current date and time.</maml:para> <maml:para>You can use Start or its alias, LastWriteTime . The LastWriteTime alias lets you pipe objects that have a LastWriteTime property, such as files in the file system `[System.Io.FileIO]`, to the Start parameter of `New-TimeSpan`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.DateTime</command:parameterValue> <dev:type> <maml:name>System.DateTime</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Current date and time</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> <maml:name>End</maml:name> <maml:Description> <maml:para>Specifies the end of a time span. The default value is the current date and time.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.DateTime</command:parameterValue> <dev:type> <maml:name>System.DateTime</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Current date and time</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Days</maml:name> <maml:Description> <maml:para>Specifies the days in the time span. The default value is 0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> <maml:name>End</maml:name> <maml:Description> <maml:para>Specifies the end of a time span. The default value is the current date and time.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.DateTime</command:parameterValue> <dev:type> <maml:name>System.DateTime</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Current date and time</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Hours</maml:name> <maml:Description> <maml:para>Specifies the hours in the time span. The default value is zero.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Minutes</maml:name> <maml:Description> <maml:para>Specifies the minutes in the time span. The default value is 0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Seconds</maml:name> <maml:Description> <maml:para>Specifies the length of the time span in seconds. The default value is 0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="LastWriteTime"> <maml:name>Start</maml:name> <maml:Description> <maml:para>Specifies the start of a time span. Enter a string that represents the date and time, such as "3/15/09" or a DateTime object, such as one from a `Get-Date` command. The default value is the current date and time.</maml:para> <maml:para>You can use Start or its alias, LastWriteTime . The LastWriteTime alias lets you pipe objects that have a LastWriteTime property, such as files in the file system `[System.Io.FileIO]`, to the Start parameter of `New-TimeSpan`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.DateTime</command:parameterValue> <dev:type> <maml:name>System.DateTime</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Current date and time</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.DateTime</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a DateTime object that represents that start time to `New-TimeSpan`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.TimeSpan</maml:name> </dev:type> <maml:description> <maml:para>`New-TimeSpan` returns an object that represents the time span.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>- Example 1: Create a TimeSpan object for a specified duration -</maml:title> <dev:code>$TimeSpan = New-TimeSpan -Hours 1 -Minutes 25 $TimeSpan Days : 0 Hours : 1 Minutes : 25 Seconds : 0 Milliseconds : 0 Ticks : 51000000000 TotalDays : 0.0590277777777778 TotalHours : 1.41666666666667 TotalMinutes : 85 TotalSeconds : 5100 TotalMilliseconds : 5100000</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--- Example 2: Create a TimeSpan object for a time interval ---</maml:title> <dev:code>New-TimeSpan -End (Get-Date -Year 2010 -Month 1 -Day 1)</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 3: Get the date 90 days from the current date ----</maml:title> <dev:code>$90days = New-TimeSpan -Days 90 (Get-Date) + $90days</dev:code> <dev:remarks> <maml:para>These commands return the date that is 90 days after the current date.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 4: Discover the TimeSpan since a file was updated --</maml:title> <dev:code>Get-ChildItem $PSHOME\en-us\about_remote.help.txt | New-TimeSpan Days : 321 Hours : 21 Minutes : 59 Seconds : 22 Milliseconds : 312 Ticks : 278135623127728 TotalDays : 321.916230471907 TotalHours : 7725.98953132578 TotalMinutes : 463559.371879547 TotalSeconds : 27813562.3127728 TotalMilliseconds : 27813562312.7728</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/new-timespan?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Date</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-Date</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>New-Variable</command:name> <command:verb>New</command:verb> <command:noun>Variable</command:noun> <maml:description> <maml:para>Creates a new variable.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The New-Variable cmdlet creates a new variable in Windows PowerShell. You can assign a value to the variable while creating it or assign or change the value after it is created.</maml:para> <maml:para>You can use the parameters of New-Variable to set the properties of the variable, set the scope of a variable, and determine whether variables are public or private.</maml:para> <maml:para>Typically, you create a new variable by typing the variable name and its value, such as `$Var = 3`, but you can use the New-Variable cmdlet to use its parameters.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>New-Variable</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies a name for the new variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="1" aliases="none"> <maml:name>Value</maml:name> <maml:Description> <maml:para>Specifies the initial value of the variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Description</maml:name> <maml:Description> <maml:para>Specifies a description of the variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet creates a variable with the same name as an existing read-only variable.</maml:para> <maml:para>By default, you can overwrite a variable unless the variable has an option value of ReadOnly or Constant. For more information, see the Option parameter.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Option</maml:name> <maml:Description> <maml:para>Specifies the value of the Options property of the variable.The acceptable values for this parameter are:</maml:para> <maml:para>- None. Sets no options. (None is the default.) - ReadOnly. Can be deleted. Cannot be changed, except by using the Force parameter. - Private. The variable is available only in the current scope. - AllScope. The variable is copied to any new scopes that are created. - Constant. Cannot be deleted or changed. Constant is valid only when you are creating a variable. You cannot change the options of an existing variable to Constant.</maml:para> <maml:para>To see the Options property of all variables in the session, type `Get-Variable | Format-Table -Property name, options -autosize`.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">None</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ReadOnly</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Constant</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Private</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">AllScope</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unspecified</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScopedItemOptions</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScopedItemOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope of the new variable. The acceptable values for this parameter are:</maml:para> <maml:para>- Global. Variables created in the global scope are accessible everywhere in a PowerShell process. - Local. The local scope refers to the current scope, this can be any scope depending on the context. - Script. Variables created in the script scope are accessible only within the script file or module they are created in. - Private. Variables created in the private scope cannot be accessed outside the scope they exist in. You can use private scope to create a private version of an item with the same name in another scope. - A number relative to the current scope (0 through the number of scopes, where 0 is the current scope, 1 is its parent, 2 the parent of the parent scope, and so on). Negative numbers cannot be used.</maml:para> <maml:para>Local is the default scope when the scope parameter is not specified.</maml:para> <maml:para>For more information, see about_Scopes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Visibility</maml:name> <maml:Description> <maml:para>Determines whether the variable is visible outside of the session in which it was created. This parameter is designed for use in scripts and commands that will be delivered to other users. The acceptable values for this parameter are:</maml:para> <maml:para>- Public. The variable is visible. (Public is the default.) - Private. The variable is not visible.</maml:para> <maml:para>When a variable is private, it does not appear in lists of variables, such as those returned by Get-Variable, or in displays of the Variable: drive. Commands to read or change the value of a private variable return an error. However, the user can run commands that use a private variable if the commands were written in the session in which the variable was defined.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Public</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Private</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SessionStateEntryVisibility</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SessionStateEntryVisibility</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Description</maml:name> <maml:Description> <maml:para>Specifies a description of the variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet creates a variable with the same name as an existing read-only variable.</maml:para> <maml:para>By default, you can overwrite a variable unless the variable has an option value of ReadOnly or Constant. For more information, see the Option parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies a name for the new variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Option</maml:name> <maml:Description> <maml:para>Specifies the value of the Options property of the variable.The acceptable values for this parameter are:</maml:para> <maml:para>- None. Sets no options. (None is the default.) - ReadOnly. Can be deleted. Cannot be changed, except by using the Force parameter. - Private. The variable is available only in the current scope. - AllScope. The variable is copied to any new scopes that are created. - Constant. Cannot be deleted or changed. Constant is valid only when you are creating a variable. You cannot change the options of an existing variable to Constant.</maml:para> <maml:para>To see the Options property of all variables in the session, type `Get-Variable | Format-Table -Property name, options -autosize`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScopedItemOptions</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScopedItemOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope of the new variable. The acceptable values for this parameter are:</maml:para> <maml:para>- Global. Variables created in the global scope are accessible everywhere in a PowerShell process. - Local. The local scope refers to the current scope, this can be any scope depending on the context. - Script. Variables created in the script scope are accessible only within the script file or module they are created in. - Private. Variables created in the private scope cannot be accessed outside the scope they exist in. You can use private scope to create a private version of an item with the same name in another scope. - A number relative to the current scope (0 through the number of scopes, where 0 is the current scope, 1 is its parent, 2 the parent of the parent scope, and so on). Negative numbers cannot be used.</maml:para> <maml:para>Local is the default scope when the scope parameter is not specified.</maml:para> <maml:para>For more information, see about_Scopes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="1" aliases="none"> <maml:name>Value</maml:name> <maml:Description> <maml:para>Specifies the initial value of the variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Visibility</maml:name> <maml:Description> <maml:para>Determines whether the variable is visible outside of the session in which it was created. This parameter is designed for use in scripts and commands that will be delivered to other users. The acceptable values for this parameter are:</maml:para> <maml:para>- Public. The variable is visible. (Public is the default.) - Private. The variable is not visible.</maml:para> <maml:para>When a variable is private, it does not appear in lists of variables, such as those returned by Get-Variable, or in displays of the Variable: drive. Commands to read or change the value of a private variable return an error. However, the user can run commands that use a private variable if the commands were written in the session in which the variable was defined.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SessionStateEntryVisibility</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SessionStateEntryVisibility</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Object</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a value to New-Variable .</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None or System.Management.Automation.PSVariable</maml:name> </dev:type> <maml:description> <maml:para>When you use the PassThru parameter, New-Variable generates a System.Management.Automation.PSVariable object representing the new variable. Otherwise, this cmdlet does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>----------------- Example 1: Create a variable -----------------</maml:title> <dev:code>PS C:\> New-Variable days</dev:code> <dev:remarks> <maml:para>This command creates a new variable named days. You are not required to type the Name parameter.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 2: Create a variable and assign it a value ------</maml:title> <dev:code>PS C:\> New-Variable -Name "zipcode" -Value 98033</dev:code> <dev:remarks> <maml:para>This command creates a variable named zipcode and assigns it the value 98033.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 3: Create a variable with the ReadOnly option ----</maml:title> <dev:code>PS C:\> New-Variable -Name Max -Value 256 -Option ReadOnly PS C:\> New-Variable -Name max -Value 1024 New-Variable : A variable with name 'max' already exists. At line:1 char:1 + New-Variable -Name max -Value 1024 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ResourceExists: (max:String) [New-Variable], SessionStateException + FullyQualifiedErrorId : VariableAlreadyExists,Microsoft.PowerShell.Commands.NewVariableCommand PS C:\> New-Variable -Name max -Value 1024 -Force</dev:code> <dev:remarks> <maml:para>This example shows how to use the ReadOnly option of New-Variable to protect a variable from being overwritten.</maml:para> <maml:para>The first command creates a new variable named Max and sets its value to 256. It uses the Option parameter with a value of ReadOnly.</maml:para> <maml:para>The second command tries to create a second variable with the same name. This command returns an error, because the read-only option is set on the variable.</maml:para> <maml:para>The third command uses the Force parameter to override the read-only protection on the variable. In this case, the command to create a new variable with the same name succeeds.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------- Example 4: Create a private variable -------------</maml:title> <dev:code>PS C:\> New-Variable -Name counter -Visibility Private #Effect of private variable in a module. PS C:\> Get-Variable c* Name Value ---- ----- Culture en-US ConsoleFileName ConfirmPreference High CommandLineParameters {} PS C:\> $counter "Cannot access the variable '$counter' because it is a private variable" At line:1 char:1 + $counter + ~~~~~~~~ + CategoryInfo : PermissionDenied: (counter:String) [], SessionStateException + FullyQualifiedErrorId : VariableIsPrivate PS C:\> Get-Counter Name Value ---- ----- Counter1 3.1415 ...</dev:code> <dev:remarks> <maml:para>This command demonstrates the behavior of a private variable in a module. The module contains the Get-Counter cmdlet, which has a private variable named Counter. The command uses the Visibility parameter with a value of Private to create the variable.</maml:para> <maml:para>The sample output shows the behavior of a private variable. The user who has loaded the module cannot view or change the value of the Counter variable, but the Counter variable can be read and changed by the commands in the module.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 5: Create a variable with a space ----------</maml:title> <dev:code>PS C:\> New-Variable -Name 'with space' -Value 'abc123xyz' PS C:\> Get-Variable -Name 'with space' Name Value ---- ----- with space abc123xyz PS C:\> ${with space} abc123xyz</dev:code> <dev:remarks> <maml:para>This command demonstrates that variables with spaces can be created. The variables can be accessed using the Get-Variable cmdlet or directly by delimiting a variable with braces.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/new-variable?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Clear-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Out-File</command:name> <command:verb>Out</command:verb> <command:noun>File</command:noun> <maml:description> <maml:para>Sends output to a file.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Out-File` cmdlet sends output to a file. When you need to specify parameters for the output use `Out-File` rather than the redirection operator (`>`).</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Out-File</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>FilePath</maml:name> <maml:Description> <maml:para>Specifies the path to the output file.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is `unicode`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ascii` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `bigendianunicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `oem` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `string` Same as `unicode`.</maml:para> <maml:para>- `unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `unknown` Same as `unicode`.</maml:para> <maml:para>- `utf7` Uses UTF-7.</maml:para> <maml:para>- `utf8` Uses UTF-8.</maml:para> <maml:para>- `utf32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">ASCII</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">BigEndianUnicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Default</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OEM</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">String</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unknown</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF7</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF8</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF32</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Unicode</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Append</maml:name> <maml:Description> <maml:para>Adds the output to the end of an existing file. If no Encoding is specified, the cmdlet uses the default encoding. That encoding may not match the encoding of the target file. This is the same behavior as the redirection operator (`>>`).</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Overrides the read-only attribute and overwrites an existing read-only file. The Force parameter does not override security restrictions.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be written to the file. Enter a variable that contains the objects or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NoOverwrite"> <maml:name>NoClobber</maml:name> <maml:Description> <maml:para>NoClobber prevents an existing file from being overwritten and displays a message that the file already exists. By default, if a file exists in the specified path, `Out-File` overwrites the file without warning.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NoNewline</maml:name> <maml:Description> <maml:para>Specifies that the content written to the file does not end with a newline character. The string representations of the input objects are concatenated to form the output. No spaces or newlines are inserted between the output strings. No newline is added after the last output string.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Width</maml:name> <maml:Description> <maml:para>Specifies the number of characters in each line of output. Any additional characters are truncated, not wrapped. If this parameter is not used, the width is determined by the characteristics of the host. The default for the PowerShell console is 80 characters.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Out-File</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is `unicode`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ascii` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `bigendianunicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `oem` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `string` Same as `unicode`.</maml:para> <maml:para>- `unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `unknown` Same as `unicode`.</maml:para> <maml:para>- `utf7` Uses UTF-7.</maml:para> <maml:para>- `utf8` Uses UTF-8.</maml:para> <maml:para>- `utf32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">ASCII</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">BigEndianUnicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Default</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OEM</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">String</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unknown</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF7</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF8</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF32</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Unicode</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Append</maml:name> <maml:Description> <maml:para>Adds the output to the end of an existing file. If no Encoding is specified, the cmdlet uses the default encoding. That encoding may not match the encoding of the target file. This is the same behavior as the redirection operator (`>>`).</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Overrides the read-only attribute and overwrites an existing read-only file. The Force parameter does not override security restrictions.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be written to the file. Enter a variable that contains the objects or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to the output file. The LiteralPath parameter is used exactly as it is typed. Wildcard characters are not accepted. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences. For more information, see about_Quoting_Rules (../Microsoft.Powershell.Core/About/about_Quoting_Rules.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NoOverwrite"> <maml:name>NoClobber</maml:name> <maml:Description> <maml:para>NoClobber prevents an existing file from being overwritten and displays a message that the file already exists. By default, if a file exists in the specified path, `Out-File` overwrites the file without warning.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NoNewline</maml:name> <maml:Description> <maml:para>Specifies that the content written to the file does not end with a newline character. The string representations of the input objects are concatenated to form the output. No spaces or newlines are inserted between the output strings. No newline is added after the last output string.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Width</maml:name> <maml:Description> <maml:para>Specifies the number of characters in each line of output. Any additional characters are truncated, not wrapped. If this parameter is not used, the width is determined by the characteristics of the host. The default for the PowerShell console is 80 characters.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Append</maml:name> <maml:Description> <maml:para>Adds the output to the end of an existing file. If no Encoding is specified, the cmdlet uses the default encoding. That encoding may not match the encoding of the target file. This is the same behavior as the redirection operator (`>>`).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is `unicode`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ascii` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `bigendianunicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `oem` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `string` Same as `unicode`.</maml:para> <maml:para>- `unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `unknown` Same as `unicode`.</maml:para> <maml:para>- `utf7` Uses UTF-7.</maml:para> <maml:para>- `utf8` Uses UTF-8.</maml:para> <maml:para>- `utf32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Unicode</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>FilePath</maml:name> <maml:Description> <maml:para>Specifies the path to the output file.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Overrides the read-only attribute and overwrites an existing read-only file. The Force parameter does not override security restrictions.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be written to the file. Enter a variable that contains the objects or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to the output file. The LiteralPath parameter is used exactly as it is typed. Wildcard characters are not accepted. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences. For more information, see about_Quoting_Rules (../Microsoft.Powershell.Core/About/about_Quoting_Rules.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="NoOverwrite"> <maml:name>NoClobber</maml:name> <maml:Description> <maml:para>NoClobber prevents an existing file from being overwritten and displays a message that the file already exists. By default, if a file exists in the specified path, `Out-File` overwrites the file without warning.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NoNewline</maml:name> <maml:Description> <maml:para>Specifies that the content written to the file does not end with a newline character. The string representations of the input objects are concatenated to form the output. No spaces or newlines are inserted between the output strings. No newline is added after the last output string.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Width</maml:name> <maml:Description> <maml:para>Specifies the number of characters in each line of output. Any additional characters are truncated, not wrapped. If this parameter is not used, the width is determined by the characteristics of the host. The default for the PowerShell console is 80 characters.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe any object to `Out-File`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>`Out-File` does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>The `Out` cmdlets do not format objects; they just render them and send them to the specified display destination. If you send an unformatted object to an `Out` cmdlet, the cmdlet sends it to a formatting cmdlet before rendering it.</maml:para> <maml:para>To send a PowerShell command's output to the `Out-File` cmdlet, use the pipeline. You can store data in a variable and use the InputObject parameter to pass data to the `Out-File` cmdlet.</maml:para> <maml:para>`Out-File` sends data but it does not produce any output objects. If you pipe the output of `Out-File` to `Get-Member`, the `Get-Member` cmdlet reports that no objects were specified.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>----------- Example 1: Send output and create a file -----------</maml:title> <dev:code>Get-Process | Out-File -FilePath .\Process.txt Get-Content -Path .\Process.txt NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName ------ ----- ----- ------ -- -- ----------- 29 22.39 35.40 10.98 42764 9 Application 53 99.04 113.96 0.00 32664 0 CcmExec 27 96.62 112.43 113.00 17720 9 Code</dev:code> <dev:remarks> <maml:para>The `Get-Process` cmdlet gets the list of processes running on the local computer. The Process objects are sent down the pipeline to the `Out-File` cmdlet. `Out-File` uses the FilePath parameter and creates a file in the current directory named Process.txt . The `Get-Content` command gets content from the file and displays it in the PowerShell console.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 2: Prevent an existing file from being overwritten --</maml:title> <dev:code>Get-Process | Out-File -FilePath .\Process.txt -NoClobber Out-File : The file 'C:\Test\Process.txt' already exists. At line:1 char:15 + Get-Process | Out-File -FilePath .\Process.txt -NoClobber + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</dev:code> <dev:remarks> <maml:para>The `Get-Process` cmdlet gets the list of processes running on the local computer. The Process objects are sent down the pipeline to the `Out-File` cmdlet. `Out-File` uses the FilePath parameter and attempts to write to a file in the current directory named Process.txt . The NoClobber parameter prevents the file from being overwritten and displays a message that the file already exists.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 3: Send output to a file in ASCII format -------</maml:title> <dev:code>$Procs = Get-Process Out-File -FilePath .\Process.txt -InputObject $Procs -Encoding ASCII -Width 50</dev:code> <dev:remarks> <maml:para>The `Get-Process` cmdlet gets the list of processes running on the local computer. The Process objects are stored in the variable, `$Procs`. `Out-File` uses the FilePath parameter and creates a file in the current directory named Process.txt . The InputObject parameter passes the process objects in `$Procs` to the file Process.txt . The Encoding parameter converts the output to ASCII format. The Width parameter limits each line in the file to 50 characters so some data might be truncated.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 4: Use a provider and send output to a file -----</maml:title> <dev:code>PS> Set-Location -Path Alias: PS> Get-Location Path ---- Alias:\ PS> Get-ChildItem | Out-File -FilePath C:\TestDir\AliasNames.txt PS> Get-Content -Path C:\TestDir\AliasNames.txt CommandType Name ----------- ---- Alias % -> ForEach-Object Alias ? -> Where-Object Alias ac -> Add-Content Alias cat -> Get-Content</dev:code> <dev:remarks> <maml:para>The `Set-Location` command uses the Path parameter to set the current location to the registry provider `Alias:`. The `Get-Location` cmdlet displays the complete path for `Alias:`. `Get-ChildItem` sends objects down the pipeline to the `Out-File` cmdlet. `Out-File` uses the FilePath parameter to specify the complete path and filename for the output, C:\TestDir\AliasNames.txt . The `Get-Content` cmdlet uses the Path parameter and displays the file's content in the PowerShell console.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/out-file?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Providers</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Quoting_Rules</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-Default</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-GridView</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-Null</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-Printer</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-String</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Tee-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Out-GridView</command:name> <command:verb>Out</command:verb> <command:noun>GridView</command:noun> <maml:description> <maml:para>Sends output to an interactive table in a separate window.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Out-GridView` cmdlet sends the output from a command to a grid view window where the output is displayed in an interactive table.</maml:para> <maml:para>Because this cmdlet requires a user interface, it does not work on Windows Server Core or Windows Nano Server.</maml:para> <maml:para>You can use the following features of the table to examine your data:</maml:para> <maml:para>- Hide, Show, and Reorder Columns</maml:para> <maml:para>- Sort rows</maml:para> <maml:para>- Quick Filter</maml:para> <maml:para>- Add Criteria Filter</maml:para> <maml:para>- Copy and paste</maml:para> <maml:para></maml:para> <maml:para>For full instructions, see the Notes (#notes)section of this article.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Out-GridView</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies object that the cmdlet accepts as input for `Out-GridView`.</maml:para> <maml:para>When you use the InputObject parameter to send a collection of objects to `Out-GridView`, `Out-GridView` treats the collection as one collection object, and it displays one row that represents the collection. To display the each object in the collection, use a pipeline operator (|) to send objects to `Out-GridView`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>OutputMode</maml:name> <maml:Description> <maml:para>Specifies the items that the interactive window sends down the pipeline as input to other commands. By default, this cmdlet does not generate any output. To send items from the interactive window down the pipeline, click to select the items and then click OK.</maml:para> <maml:para>The values of this parameter determine how many items you can send down the pipeline.</maml:para> <maml:para>- None. No items. This is the default value.</maml:para> <maml:para>- Single. Zero items or one item. Use this value when the next command can take only one input</maml:para> <maml:para> object. - Multiple. Zero, one, or many items. Use this value when the next command can take multiple input objects. This value is equivalent to the Passthru parameter.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">None</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Single</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Multiple</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.OutputModeOption</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.OutputModeOption</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Title</maml:name> <maml:Description> <maml:para>Specifies the text that appears in the title bar of the `Out-GridView` window. By default, the title bar displays the command that invokes `Out-GridView`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Out-GridView</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies object that the cmdlet accepts as input for `Out-GridView`.</maml:para> <maml:para>When you use the InputObject parameter to send a collection of objects to `Out-GridView`, `Out-GridView` treats the collection as one collection object, and it displays one row that represents the collection. To display the each object in the collection, use a pipeline operator (|) to send objects to `Out-GridView`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends items from the interactive window down the pipeline as input to other commands. By default, this cmdlet does not generate any output. This parameter is equivalent to using the Multiple value of the OutputMode parameter.</maml:para> <maml:para>To send items from the interactive window down the pipeline, click to select the items and then click OK. Shift-click and Ctrl-click are supported.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Title</maml:name> <maml:Description> <maml:para>Specifies the text that appears in the title bar of the `Out-GridView` window. By default, the title bar displays the command that invokes `Out-GridView`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Out-GridView</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies object that the cmdlet accepts as input for `Out-GridView`.</maml:para> <maml:para>When you use the InputObject parameter to send a collection of objects to `Out-GridView`, `Out-GridView` treats the collection as one collection object, and it displays one row that represents the collection. To display the each object in the collection, use a pipeline operator (|) to send objects to `Out-GridView`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Title</maml:name> <maml:Description> <maml:para>Specifies the text that appears in the title bar of the `Out-GridView` window. By default, the title bar displays the command that invokes `Out-GridView`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Wait</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet suppresses the command prompt and prevents Windows PowerShell from closing until the `Out-GridView` window is closed. By default, the command prompt returns when the `Out-GridView` window opens.</maml:para> <maml:para>This feature lets you use the `Out-GridView` cmdlets in Windows shortcuts. When `Out-GridView` is used in a shortcut without the Wait parameter, the `Out-GridView` window appears only momentarily before PowerShell closes.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies object that the cmdlet accepts as input for `Out-GridView`.</maml:para> <maml:para>When you use the InputObject parameter to send a collection of objects to `Out-GridView`, `Out-GridView` treats the collection as one collection object, and it displays one row that represents the collection. To display the each object in the collection, use a pipeline operator (|) to send objects to `Out-GridView`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>OutputMode</maml:name> <maml:Description> <maml:para>Specifies the items that the interactive window sends down the pipeline as input to other commands. By default, this cmdlet does not generate any output. To send items from the interactive window down the pipeline, click to select the items and then click OK.</maml:para> <maml:para>The values of this parameter determine how many items you can send down the pipeline.</maml:para> <maml:para>- None. No items. This is the default value.</maml:para> <maml:para>- Single. Zero items or one item. Use this value when the next command can take only one input</maml:para> <maml:para> object. - Multiple. Zero, one, or many items. Use this value when the next command can take multiple input objects. This value is equivalent to the Passthru parameter.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.OutputModeOption</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.OutputModeOption</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends items from the interactive window down the pipeline as input to other commands. By default, this cmdlet does not generate any output. This parameter is equivalent to using the Multiple value of the OutputMode parameter.</maml:para> <maml:para>To send items from the interactive window down the pipeline, click to select the items and then click OK. Shift-click and Ctrl-click are supported.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Title</maml:name> <maml:Description> <maml:para>Specifies the text that appears in the title bar of the `Out-GridView` window. By default, the title bar displays the command that invokes `Out-GridView`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Wait</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet suppresses the command prompt and prevents Windows PowerShell from closing until the `Out-GridView` window is closed. By default, the command prompt returns when the `Out-GridView` window opens.</maml:para> <maml:para>This feature lets you use the `Out-GridView` cmdlets in Windows shortcuts. When `Out-GridView` is used in a shortcut without the Wait parameter, the `Out-GridView` window appears only momentarily before PowerShell closes.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can send any object to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>Normally, `Out-GridView` does not return any objects. When using the PassThru parameter, the objects representing the selected rows are returned to the pipeline.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>You cannot use a remote command to open a grid view window on another computer.</maml:para> <maml:para>The command output that you send to `Out-GridView` cannot be formatted using the `Format` cmdlets, such as `Format-Table` or `Format-Wide` cmdlets. To select properties, use the `Select-Object` cmdlet.</maml:para> <maml:para>Deserialized output from remote commands might not be formatted correctly in the grid view window. Keyboard Shortcuts for `Out-GridView`</maml:para> <maml:para>| Use this key: | To perform this action: | | --------------------------------------- | -------------------------------------------------------------------------------------------- | | <kbd>Tab</kbd> | Moves the cursor from the Filter box to the Add criteria menu to the table and back. | | <kbd>UpArrow</kbd> | Move up one row. Moves to column headers from first row of data. | | <kbd>DownArrow</kbd> | Move down one row. | | <kbd>LeftArrow</kbd> | In column header row, move left one column. | | <kbd>RightArrow</kbd> | In column header row, move right one column. | | <kbd>ContextMenuKey</kbd> | In column header row, displays the Select Columns option. | | <kbd>Enter</kbd> or <kbd>Spacebar</kbd> | In column header row, sort column data (toggle A-Z, Z-A). | How to Use the Grid View Window Features To hide or show a column: 1. Right-click any column header and click Select Columns . 2. In the Select Columns dialog box, use the arrow keys to move the columns between the Selected columns to the Available columns boxes. Only columns in the Select Columns box appear in the grid view window. To reorder columns: You can drag and drop columns into the desired location. Or use the following steps:</maml:para> <maml:para>1. Right-click any column header and click Select Columns . 2. In the Select Columns dialog box, use the Move up and Move down buttons to reorder the columns. Columns at the top of the list appear to the left of columns at the bottom of the list in the grid view window. How to Sort Table Data - To sort the data, click a column header.</maml:para> <maml:para>- To change the sort order, click the column header again. Each time you click the same header,</maml:para> <maml:para> the sort order toggles between ascending to descending order. The current order is indicated by a triangle in the column header. How to Select Table Data - To select a row, select the row or use the up or down arrow to navigate to the row.</maml:para> <maml:para>- To select all rows (except for the header row), press <kbd>CTRL</kbd>+<kbd>A</kbd>.</maml:para> <maml:para>- To select consecutive rows, press and hold the <kbd>SHIFT</kbd> key while clicking the rows or using the</maml:para> <maml:para> arrow keys. - To select nonconsecutive rows, press the <kbd>CTRL</kbd> key and click to add a row to the selection.</maml:para> <maml:para>- You cannot select columns, and you cannot select the entire column header row. How to Copy Rows - To copy one or more rows from the table, select the rows and then press CTRL+C.</maml:para> <maml:para> You can paste the data into any text or spreadsheet program. You cannot copy columns or parts of rows and you cannot copy the column header row. How to Search in the Table (Quick Filter) Use the Filter box to search for data in the table. When you type in the box, only items that include the typed text appear in the table.</maml:para> <maml:para>- Search for text. To search for text in the table, in the Filter box, type the text to find.</maml:para> <maml:para>- Search for multiple words. To search for multiple words in the table, type the words separated by</maml:para> <maml:para> spaces. `Out-GridView` displays rows that include all the words (logical AND). - Search for literal phrases. To search for phrases that include spaces or special characters, enclose the phrase in quotation marks. `Out-GridView` displays rows that include an exact match for the phrase. - Search in columns. To search for text in one or more columns, use the following format:</maml:para> <maml:para> `<column>:<text> [<column>:<text>] ...`</maml:para> <maml:para> For example, to find "Net" in the DisplayName column, in the Filter box, type:</maml:para> <maml:para> `displayname:net`</maml:para> <maml:para> To find rows with "Net" in the DisplayName and Name columns, in the Filter box, type:</maml:para> <maml:para> `displayname:net name:net`</maml:para> <maml:para>- Turn off search. To display the entire table again, click the red X button in the top right corner of the Filter box or delete the text from the Filter box. Use Criteria to Filter the Table You can use rules or criteria to determine which items are displayed in the table. Items appear only when they satisfy all the criteria that you establish. The available criteria are determined by the properties of the objects displayed in the grid view window and the .NET Framework types of those properties.</maml:para> <maml:para>Each criterion has the following format:</maml:para> <maml:para>`<column> <operator> <value>`</maml:para> <maml:para>Criteria for different properties are connected by AND . Criteria for the same property are connected by OR . You cannot change the logical connectors.</maml:para> <maml:para>The criteria only affects the display. It does not delete items from the table. How to Add Criteria 1. To display the Add criteria menu button, in the upper right corner of the window, click the Expand arrow. 2. Click the Add Criteria menu button. 3. Click to select columns (properties). You can select one or many properties. 4. When you are finished selecting properties, click the Add button. 5. To cancel the additions, click Cancel . 6. To add more criteria, click the Add Criteria button again. How to Edit a Criterion - To change an operator, click the blue operator value, and then select a different operator from the drop-down list. - To enter or change a value, type a value in the value box. If you enter a value that is not valid, a circular X icon appears. To remove it, change the value. - To create an OR statement, add a criteria with the same property. How to Delete Criteria - To delete selected criteria, click the red X beside each criterion.</maml:para> <maml:para>- To delete all criteria, click the Clear All button.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>---------- Example 1: Output processes to a grid view ----------</maml:title> <dev:code>Get-Process | Out-GridView</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>- Example 2: Use a variable to output processes to a grid view -</maml:title> <dev:code>$P = Get-Process $P | Out-GridView</dev:code> <dev:remarks> <maml:para>The output of the `Get-Process` cmdlet is saved in the `$P` variable. Then, `$P` is piped to `Out-GridView`.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--- Example 3: Display a selected properties in a grid view ---</maml:title> <dev:code>Get-Process | Select-Object -Property Name, WorkingSet, PeakWorkingSet | Sort-Object -Property WorkingSet -Descending | Out-GridView</dev:code> <dev:remarks> <maml:para>The output of `Get-Process` is piped to `Select-Object` to select the Name , WorkingSet , and PeakWorkingSet properties. Another pipeline operator sends the filtered objects to the `Sort-Object` cmdlet to sort them in descending order by the value of the WorkingSet property. Then, the sorted results are piped to `Out-GridView`. You can now use the features of the grid view to search, sort, and filter the data.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 4: Save output to a variable, and then output a grid view</maml:title> <dev:code>($A = Get-ChildItem -Path $PSHOME -Recurse) | Out-GridView</dev:code> <dev:remarks> <maml:para>`Get-ChildItem` gets all the files in the PowerShell installation directory and its subdirectories using the the `$PSHOME` automatic variable. The parentheses in the command establish the order of operations. As a result, the output from the `Get-ChildItem` command is saved in the `$A` variable before it is sent to `Out-GridView`.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 5: Output processes for a specified computer to a grid view</maml:title> <dev:code>Get-Process -ComputerName "Server01" | ogv -Title "Processes - Server01"</dev:code> <dev:remarks> <maml:para>The examle uses `ogv`, which is the alias for the `Out-GridView` cmdlet. The Title parameter specifies the window title.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>- Example 6: Output data from remote computers to a grid view -</maml:title> <dev:code>Invoke-Command -ComputerName S1, S2, S3 -ScriptBlock {Get-Culture} | Out-GridView</dev:code> <dev:remarks> <maml:para>`Invoke-Command` runs `Get-Culture` on three remote computers. The resulting data is piped to `Out-GridView`. Notice that the script block that runs on the remote computer does not include the `Out-GridView` command. If it did, the command would fail when it tried to open a grid view window on each of the remote computers.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 7: Pass multiple items through `Out-GridView` ----</maml:title> <dev:code>Get-Process | Out-GridView -PassThru | Export-Csv -Path .\ProcessLog.csv</dev:code> <dev:remarks> <maml:para>The PassThru parameter of `Out-GridView` lets you send multiple items down the pipeline. The PassThru parameter is equivalent to using the Multiple value of the OutputMode parameter.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 8: Create a Windows shortcut to `Out-GridView` ----</maml:title> <dev:code>pwsh -Command "Get-Service | Out-GridView -Wait"</dev:code> <dev:remarks> <maml:para>This command line can be used in a Windows shortcut. Without the Wait parameter, PowerShell would exit as soon as the `Out-GridView` window opened, which would close the `Out-GridView` window almost immediately.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/out-gridview?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-File</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-Printer</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-String</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Out-Printer</command:name> <command:verb>Out</command:verb> <command:noun>Printer</command:noun> <maml:description> <maml:para>Sends output to a printer.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Out-Printer` cmdlet sends output to the default printer or to an alternate printer, if one is specified.</maml:para> <maml:para>> [!NOTE] > This cmdlet was reintroduced in PowerShell 7. This cmdlet is only available on Windows systems > that support the Windows Desktop.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Out-Printer</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="PrinterName"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Sends the output to the specified printer. The parameter name Name is optional.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be sent to the printer. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be sent to the printer. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="PrinterName"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Sends the output to the specified printer. The parameter name Name is optional.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe any object to `Out-Printer`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>`Out-Printer` does not return any objects.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>The cmdlets that contain the `Out` verb do not format objects. They just render them and send them to the specified display destination. If you send an unformatted object to an `Out` cmdlet, the cmdlet sends it to a formatting cmdlet before rendering it.</maml:para> <maml:para>`Out-Printer` sends data to the printer, but does not emit any output objects to the pipeline. If you pipe the output of `Out-Printer` to `Get-Member`, `Get-Member` reports that no objects have been specified.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>- Example 1 - Send a file to be printed on the default printer -</maml:title> <dev:code>Get-Content -Path ./readme.txt | Out-Printer</dev:code> <dev:remarks> <maml:para>`Get-Content`gets the contents of the `readme.txt` file in the current directory and pipes it to `Out-Printer`, which sends it to the default printer.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 2: Print a string to a remote printer --------</maml:title> <dev:code>"Hello, World" | Out-Printer -Name "\\Server01\Prt-6B Color"</dev:code> <dev:remarks> <maml:para>The Name parameter selects a specific printer, rather than the default.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 3 - Print a help topic to the default printer ----</maml:title> <dev:code>$H = Get-Help -Full Get-CimInstance Out-Printer -InputObject $H</dev:code> <dev:remarks> <maml:para>`Get-Help` gets the full version of the Help topic for `Get-CimInstance` and stores it in the `$H` variable. The InputObject parameter passes the value of `$H` to `Out-Printer`.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/out-printer?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-File</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-String</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Out-String</command:name> <command:verb>Out</command:verb> <command:noun>String</command:noun> <maml:description> <maml:para>Sends objects to the host as a series of strings.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Out-String` cmdlet converts the objects that PowerShell manages into an array of strings. By default, `Out-String` accumulates the strings and returns them as a single string, but you can use the Stream parameter to direct `Out-String` to return one string at a time. This cmdlet lets you search and manipulate string output as you would in traditional shells when object manipulation is less convenient.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Out-String</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be written to a string. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Stream</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends a separate string for each object. By default, the strings for each object are accumulated and sent as a single string.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Width</maml:name> <maml:Description> <maml:para>Specifies the number of characters in each line of output. Any additional characters are truncated, not wrapped. The Width parameter applies only to objects that are being formatted. If you omit this parameter, the width is determined by the characteristics of the host program. The default value for the PowerShell console is 80 characters.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be written to a string. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Stream</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends a separate string for each object. By default, the strings for each object are accumulated and sent as a single string.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Width</maml:name> <maml:Description> <maml:para>Specifies the number of characters in each line of output. Any additional characters are truncated, not wrapped. The Width parameter applies only to objects that are being formatted. If you omit this parameter, the width is determined by the characteristics of the host program. The default value for the PowerShell console is 80 characters.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can send objects down the pipeline to `Out-String`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>`Out-String` returns the string that it creates from the input object.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>The cmdlets that contain the `Out` verb don't format objects. The `Out` cmdlets send objects to the formatter for the specified display destination.</maml:para> <maml:para>The `Out` cmdlets don't have parameters that accept names or file paths. To send the output of a PowerShell command to an `Out` cmdlet, use the pipeline. Or, you can store data in a variable and use the InputObject parameter to pass the data to the cmdlet.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------ Example 1: Output text to the console as a string ------</maml:title> <dev:code>Get-Content -Path C:\Test\Testfile.txt | Out-String</dev:code> <dev:remarks> <maml:para>`Get-Content` sends the contents of the `Testfile.txt` file down the pipeline. Each line of the file has its own properties. `Out-String` converts the objects into an array of strings and then displays the contents as one string in the PowerShell console.</maml:para> <maml:para>> [!NOTE] > To compare the differences about how `Get-Content` and `Out-String` display the properties: > > `Get-Content -Path C:\Test\Testfile.txt | Select-Object -Property *` > > `Get-Content -Path C:\Test\Testfile.txt | Out-String | Select-Object -Property *`</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 2: Get the current culture and convert the data to strings</maml:title> <dev:code>$C = Get-Culture | Select-Object -Property * Out-String -InputObject $C -Width 100</dev:code> <dev:remarks> <maml:para>The `$C` variable stores a Selected.System.Globalization.CultureInfo object. The object is the result of `Get-Culture` sending output down the pipeline to `Select-Object`. The Property parameter uses an asterisk (`*`) wildcard to specify all properties are contained in the object.</maml:para> <maml:para>`Out-String` uses the InputObject parameter to specify the CultureInfo object stored in the `$C` variable. The objects in `$C` are converted to a string. The Width parameter is set to 100 characters per line to prevent truncation.</maml:para> <maml:para>> [!NOTE] > To view the `Out-String` array, store the output to a variable and use an array index to view the > elements. For more information about the array index, see > about_Arrays (../microsoft.powershell.core/about/about_arrays.md). > > `$str = Out-String -InputObject $C -Width 100`</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------------- Example 3: Working with objects ---------------</maml:title> <dev:code>Get-Alias | Out-String -Stream | Select-String -Pattern "gcm" Alias gcm -> Get-Command</dev:code> <dev:remarks> <maml:para>`Get-Alias` gets the System.Management.Automation.AliasInfo objects, one for each alias, and sends the objects down the pipeline. `Out-String` uses the Stream parameter to convert each object to a string rather concatenating all the objects into a single string. The System.String objects are sent down the pipeline and `Select-String` uses the Pattern parameter to find matches for the text gcm .</maml:para> <maml:para>> [!NOTE] > If you omit the Stream parameter, the command displays all the aliases because `Select-String` > finds the text gcm in the single string that `Out-String` returns.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/out-string?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-Default</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-File</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-Null</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-GridView</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-Printer</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Read-Host</command:name> <command:verb>Read</command:verb> <command:noun>Host</command:noun> <maml:description> <maml:para>Reads a line of input from the console.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Read-Host` cmdlet reads a line of input from the console. You can use it to prompt a user for input. Because you can save the input as a secure string, you can use this cmdlet to prompt users for secure data, such as passwords, as well as shared data.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Read-Host</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Prompt</maml:name> <maml:Description> <maml:para>Specifies the text of the prompt. Type a string. If the string includes spaces, enclose it in quotation marks. PowerShell appends a colon (`:`) to the text that you enter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AsSecureString</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet displays asterisks (`*`) in place of the characters that the user types as input. When you use this parameter, the output of the `Read-Host` cmdlet is a SecureString object ( System.Security.SecureString ).</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AsSecureString</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet displays asterisks (`*`) in place of the characters that the user types as input. When you use this parameter, the output of the `Read-Host` cmdlet is a SecureString object ( System.Security.SecureString ).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Prompt</maml:name> <maml:Description> <maml:para>Specifies the text of the prompt. Type a string. If the string includes spaces, enclose it in quotation marks. PowerShell appends a colon (`:`) to the text that you enter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe input to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.String or System.Security.SecureString</maml:name> </dev:type> <maml:description> <maml:para>If the AsSecureString parameter is used, `Read-Host` returns a SecureString . Otherwise, it returns a string.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1: Save console input to a variable ---------</maml:title> <dev:code>$Age = Read-Host "Please enter your age"</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 2: Save console input as a secure string -------</maml:title> <dev:code>$pwd_secure_string = Read-Host "Enter a Password" -AsSecureString</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/read-host?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Clear-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertFrom-SecureString</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Register-EngineEvent</command:name> <command:verb>Register</command:verb> <command:noun>EngineEvent</command:noun> <maml:description> <maml:para>Subscribes to events that are generated by the PowerShell engine and by the `New-Event` cmdlet.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Register-EngineEvent` cmdlet subscribes to events that are generated by the PowerShell engine and the `New-Event` cmdlet. Use the SourceIdentifier parameter to specify the event.</maml:para> <maml:para>You can use this cmdlet to subscribe to the Exiting engine event and events generated by the `New-Event` cmdlet. These events are automatically added to your event queue in your session without subscribing. However, subscribing lets you forward the events, specify an action to respond to the events, and cancel the subscription.</maml:para> <maml:para>When the subscribed event is raised, it is added to the event queue in your session. To get events in the event queue, use the `Get-Event` cmdlet.</maml:para> <maml:para>When you subscribe to a event, an event subscriber is added to your session. To get the event subscribers in the session, use the `Get-EventSubscriber` cmdlet. To cancel the subscription, use the `Unregister-Event` cmdlet, which deletes the event subscriber from the session.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Register-EngineEvent</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="100" aliases="none"> <maml:name>SourceIdentifier</maml:name> <maml:Description> <maml:para>Specifies the source identifier of the event to which you are subscribing. The source identifier must be unique in the current session. This parameter is required.</maml:para> <maml:para>The value of this parameter appears in the value of the SourceIdentifier property of the subscriber object and of all event objects associated with this subscription.</maml:para> <maml:para>The value is specific to the source of the event. This can be an arbitrary value you created to use with the `New-Event` cmdlet. The PowerShell engine supports the EngineEvent values PowerShell.Exiting and PowerShell.OnIdle .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="101" aliases="none"> <maml:name>Action</maml:name> <maml:Description> <maml:para>Specifies commands to handle the events. The commands in the Action run when an event is raised, instead of sending the event to the event queue. Enclose the commands in braces ( { } ) to create a script block.</maml:para> <maml:para>The value of the Action parameter can include the `$Event`, `$EventSubscriber`, `$Sender`, `$EventArgs`, and `$Args` automatic variables, which provide information about the event to the Action script block. For more information, see about_Automatic_Variables (../Microsoft.PowerShell.Core/About/about_Automatic_Variables.md).</maml:para> <maml:para>When you specify an action, `Register-EngineEvent` returns an event job object that represents that action. You can use the Job cmdlets to manage the event job.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScriptBlock</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Forward</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends events for this subscription to the session on the local computer. Use this parameter when you are registering for events on a remote computer or in a remote session.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>MaxTriggerCount</maml:name> <maml:Description> <maml:para>Specifies the maximum number of times that the action will be executed for the event subscription.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>MessageData</maml:name> <maml:Description> <maml:para>Specifies additional data associated with the event. The value of this parameter appears in the MessageData property of the event object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SupportEvent</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet hides the event subscription. Add this parameter when the current subscription is part of a more complex event registration mechanism and it should not be discovered independently.</maml:para> <maml:para>To view or cancel a subscription that was created with the SupportEvent parameter, add the Force parameter to the `Get-EventSubscriber` or `Unregister-Event` cmdlets.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="101" aliases="none"> <maml:name>Action</maml:name> <maml:Description> <maml:para>Specifies commands to handle the events. The commands in the Action run when an event is raised, instead of sending the event to the event queue. Enclose the commands in braces ( { } ) to create a script block.</maml:para> <maml:para>The value of the Action parameter can include the `$Event`, `$EventSubscriber`, `$Sender`, `$EventArgs`, and `$Args` automatic variables, which provide information about the event to the Action script block. For more information, see about_Automatic_Variables (../Microsoft.PowerShell.Core/About/about_Automatic_Variables.md).</maml:para> <maml:para>When you specify an action, `Register-EngineEvent` returns an event job object that represents that action. You can use the Job cmdlets to manage the event job.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScriptBlock</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Forward</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends events for this subscription to the session on the local computer. Use this parameter when you are registering for events on a remote computer or in a remote session.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>MaxTriggerCount</maml:name> <maml:Description> <maml:para>Specifies the maximum number of times that the action will be executed for the event subscription.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>MessageData</maml:name> <maml:Description> <maml:para>Specifies additional data associated with the event. The value of this parameter appears in the MessageData property of the event object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="100" aliases="none"> <maml:name>SourceIdentifier</maml:name> <maml:Description> <maml:para>Specifies the source identifier of the event to which you are subscribing. The source identifier must be unique in the current session. This parameter is required.</maml:para> <maml:para>The value of this parameter appears in the value of the SourceIdentifier property of the subscriber object and of all event objects associated with this subscription.</maml:para> <maml:para>The value is specific to the source of the event. This can be an arbitrary value you created to use with the `New-Event` cmdlet. The PowerShell engine supports the EngineEvent values PowerShell.Exiting and PowerShell.OnIdle .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SupportEvent</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet hides the event subscription. Add this parameter when the current subscription is part of a more complex event registration mechanism and it should not be discovered independently.</maml:para> <maml:para>To view or cancel a subscription that was created with the SupportEvent parameter, add the Force parameter to the `Get-EventSubscriber` or `Unregister-Event` cmdlets.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe input to `Register-EngineEvent`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None or System.Management.Automation.PSEventJob</maml:name> </dev:type> <maml:description> <maml:para>If you use the Action parameter, `Register-EngineEvent` returns a System.Management.Automation.PSEventJob object. Otherwise, it does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>Events, event subscriptions, and the event queue exist only in the current session. If you close the current session, the event queue is discarded and the event subscription is canceled.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>Example 1: Register a PowerShell engine event on remote computers</maml:title> <dev:code>$S = New-PSSession -ComputerName "Server01, Server02" Invoke-Command -Session $S { Register-EngineEvent -SourceIdentifier ([System.Management.Automation.PsEngineEvent]::Exiting) -Forward }</dev:code> <dev:remarks> <maml:para>`New-PSSession` creates a user-managed session (PSSession) on each of the remote computers.The `Invoke-Command` cmdlet runs the `Register-EngineEvent` command in the remote sessions. `Register-EngineEvent` uses the SourceIdentifier parameter to identify the event. The Forward parameter tell the engine to forward the events from the remote session to the local session.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 2: Take a specified action when the Exiting event occurs</maml:title> <dev:code>Register-EngineEvent -SourceIdentifier PowerShell.Exiting -SupportEvent -Action { Get-History | Export-Clixml $Home\history.clixml }</dev:code> <dev:remarks> <maml:para>The SupportEvent parameter is added to hide the event subscription. When PowerShell exits, in this case, the command history from the exiting session is exported an XML file in the user's `$Home` directory.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--- Example 3: Create and subscribe to a user-defined event ---</maml:title> <dev:code>Register-EngineEvent -SourceIdentifier MyEventSource -Action { "Event: {0}" -f $event.messagedata | Out-File c:\temp\MyEvents.txt -Append } Start-Job -Name TestJob -ScriptBlock { While ($True) { Register-EngineEvent -SourceIdentifier MyEventSource -Forward Start-Sleep -seconds 2 "Doing some work..." New-Event -SourceIdentifier MyEventSource -Message ("{0} - Work done..." -f (Get-Date)) } } Start-Sleep -seconds 4 Get-EventSubscriber Get-Job SubscriptionId : 12 SourceObject : EventName : SourceIdentifier : MyEventSource Action : System.Management.Automation.PSEventJob HandlerDelegate : SupportEvent : False ForwardEvent : False Id Name PSJobTypeName State HasMoreData Location Command -- ---- ------------- ----- ----------- -------- ------- 18 MyEventSource Running True … 19 TestJob BackgroundJob Running True localhost …</dev:code> <dev:remarks> <maml:para>`Register-EngineEvent` created Job Id 18. `Start-Job` created Job Id 19. In Example #4, we remove the event subscription and the jobs, then inspect the log file.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 4: Unregister events and clean up jobs --------</maml:title> <dev:code>PS> Start-Sleep -seconds 10 PS> Get-EventSubscriber | Unregister-Event PS> Get-Job Id Name PSJobTypeName State HasMoreData Location Command -- ---- ------------- ----- ----------- -------- ------- 18 MyEventSource Stopped False … 19 TestJob BackgroundJob Running True localhost … PS> Stop-Job -Id 19 PS> Get-Job | Remove-Job PS> Get-Content C:\temp\MyEvents.txt Event: 2/18/2020 2:36:19 PM - Work done... Event: 2/18/2020 2:36:21 PM - Work done... Event: 2/18/2020 2:36:23 PM - Work done... Event: 2/18/2020 2:36:25 PM - Work done... Event: 2/18/2020 2:36:27 PM - Work done... Event: 2/18/2020 2:36:29 PM - Work done... Event: 2/18/2020 2:36:31 PM - Work done...</dev:code> <dev:remarks> <maml:para>The `Unregister-Event` cmdlet stops the job associated with the event subscription (Job Id 18). Job Id 19 is still running and creating new events. We use the Job cmdlets stop the job and remove the unneeded job objects. `Get-Content` displays the contents of the log file.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/register-engineevent?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-ObjectEvent</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Unregister-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Wait-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Register-ObjectEvent</command:name> <command:verb>Register</command:verb> <command:noun>ObjectEvent</command:noun> <maml:description> <maml:para>Subscribes to the events that are generated by a Microsoft .NET Framework object.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Register-ObjectEvent` cmdlet subscribes to events that are generated by .NET objects on the local computer or on a remote computer.</maml:para> <maml:para>When the subscribed event is raised, it is added to the event queue in your session. To get events in the event queue, use the `Get-Event` cmdlet.</maml:para> <maml:para>You can use the parameters of `Register-ObjectEvent` to specify property values of the events that can help you to identify the event in the queue. You can also use the Action parameter to specify actions to take when a subscribed event is raised and the Forward parameter to send remote events to the event queue in the local session.</maml:para> <maml:para>When you subscribe to an event, an event subscriber is added to your session. To get the event subscribers in the session, use the `Get-EventSubscriber` cmdlet. To cancel the subscription, use the `Unregister-Event` cmdlet, which deletes the event subscriber from the session.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Register-ObjectEvent</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the .NET object that generates the events. Enter a variable that contains the object, or type a command or expression that gets the object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>EventName</maml:name> <maml:Description> <maml:para>Specifies the event to which you are subscribing.</maml:para> <maml:para>The value of this parameter must be the name of the event that the .NET object exposes. For example, the ManagementEventWatcher class has events named EventArrived and Stopped . To find the event name of an event, use the `Get-Member` cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="100" aliases="none"> <maml:name>SourceIdentifier</maml:name> <maml:Description> <maml:para>Specifies a name that you select for the subscription. The name that you select must be unique in the current session. The default value is the GUID that PowerShell assigns.</maml:para> <maml:para>The value of this parameter appears in the value of the SourceIdentifier property of the subscriber object and all event objects associated with this subscription.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="101" aliases="none"> <maml:name>Action</maml:name> <maml:Description> <maml:para>Specifies the commands to handle the event. The commands in the Action run when an event is raised, instead of sending the event to the event queue. Enclose the commands in braces ( { } ) to create a script block.</maml:para> <maml:para>The value of the Action parameter can include the `$Event`, `$EventSubscriber`, `$Sender`, `$EventArgs`, and `$Args` automatic variables. These variables provide information about the event to the Action script block. For more information, see about_Automatic_Variables (../Microsoft.PowerShell.Core/About/about_Automatic_Variables.md).</maml:para> <maml:para>When you specify an action, `Register-ObjectEvent` returns an event job object that represents that action. You can use the Job cmdlets to manage the event job.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScriptBlock</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Forward</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends events for this subscription to a remote session. Use this parameter when you are registering for events on a remote computer or in a remote session.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>MaxTriggerCount</maml:name> <maml:Description> <maml:para>Specifies the maximum number of times an event can be triggered.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>MessageData</maml:name> <maml:Description> <maml:para>Specifies any additional data to be associated with this event subscription. The value of this parameter appears in the MessageData property of all events associated with this subscription.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SupportEvent</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet hides the event subscription. Use this parameter when the current subscription is part of a more complex event registration mechanism and should not be discovered independently.</maml:para> <maml:para>To view or cancel a subscription that was created with the SupportEvent parameter, use the Force parameter of the `Get-EventSubscriber` and `Unregister-Event` cmdlets.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="101" aliases="none"> <maml:name>Action</maml:name> <maml:Description> <maml:para>Specifies the commands to handle the event. The commands in the Action run when an event is raised, instead of sending the event to the event queue. Enclose the commands in braces ( { } ) to create a script block.</maml:para> <maml:para>The value of the Action parameter can include the `$Event`, `$EventSubscriber`, `$Sender`, `$EventArgs`, and `$Args` automatic variables. These variables provide information about the event to the Action script block. For more information, see about_Automatic_Variables (../Microsoft.PowerShell.Core/About/about_Automatic_Variables.md).</maml:para> <maml:para>When you specify an action, `Register-ObjectEvent` returns an event job object that represents that action. You can use the Job cmdlets to manage the event job.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScriptBlock</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>EventName</maml:name> <maml:Description> <maml:para>Specifies the event to which you are subscribing.</maml:para> <maml:para>The value of this parameter must be the name of the event that the .NET object exposes. For example, the ManagementEventWatcher class has events named EventArrived and Stopped . To find the event name of an event, use the `Get-Member` cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Forward</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends events for this subscription to a remote session. Use this parameter when you are registering for events on a remote computer or in a remote session.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the .NET object that generates the events. Enter a variable that contains the object, or type a command or expression that gets the object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>MaxTriggerCount</maml:name> <maml:Description> <maml:para>Specifies the maximum number of times an event can be triggered.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>MessageData</maml:name> <maml:Description> <maml:para>Specifies any additional data to be associated with this event subscription. The value of this parameter appears in the MessageData property of all events associated with this subscription.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="100" aliases="none"> <maml:name>SourceIdentifier</maml:name> <maml:Description> <maml:para>Specifies a name that you select for the subscription. The name that you select must be unique in the current session. The default value is the GUID that PowerShell assigns.</maml:para> <maml:para>The value of this parameter appears in the value of the SourceIdentifier property of the subscriber object and all event objects associated with this subscription.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SupportEvent</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet hides the event subscription. Use this parameter when the current subscription is part of a more complex event registration mechanism and should not be discovered independently.</maml:para> <maml:para>To view or cancel a subscription that was created with the SupportEvent parameter, use the Force parameter of the `Get-EventSubscriber` and `Unregister-Event` cmdlets.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe objects to `Register-ObjectEvent`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None or System.Management.Automation.PSEventJob</maml:name> </dev:type> <maml:description> <maml:para>When you use the Action parameter, `Register-ObjectEvent` returns a System.Management.Automation.PSEventJob object. Otherwise, it does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>Events, event subscriptions, and the event queue exist only in the current session. If you close the current session, the event queue is discarded and the event subscription is canceled.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--- Example 1: Subscribe to events when a new process starts ---</maml:title> <dev:code>$queryParameters = '__InstanceCreationEvent', (New-Object TimeSpan 0,0,1), "TargetInstance isa 'Win32_Process'" $Query = New-Object System.Management.WqlEventQuery -ArgumentList $queryParameters $ProcessWatcher = New-Object System.Management.ManagementEventWatcher $Query Register-ObjectEvent -InputObject $ProcessWatcher -EventName "EventArrived"</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 2: Specify an action to respond to an event -----</maml:title> <dev:code>$queryParameters = '__InstanceCreationEvent', (New-Object TimeSpan 0,0,1), "TargetInstance isa 'Win32_Process'" $Query = New-Object System.Management.WqlEventQuery -ArgumentList $queryParameters $ProcessWatcher = New-Object System.Management.ManagementEventWatcher $query $newEventArgs = @{ SourceIdentifier = 'PowerShell.ProcessCreated' Sender = $Sender EventArguments = $EventArgs.NewEvent.TargetInstance } $Action = { New-Event @newEventArgs } Register-ObjectEvent -InputObject $ProcessWatcher -EventName "EventArrived" -Action $Action Id Name PSJobTypeName State HasMoreData Location Command -- ---- ------------- ----- ----------- -------- ------- 5 3db2d67a-efff-... NotStarted False New-Event @newEventArgs</dev:code> <dev:remarks> <maml:para>The action uses the `$Sender` and `$EventArgs` automatic variables which are populated only for event actions.</maml:para> <maml:para>The `Register-ObjectEvent` command returns a job object that represents the action, which runs as a background job. You can use the Job cmdlets, such as `Get-Job` and `Receive-Job`, to manage the background job. For more information, see about_Jobs (../Microsoft.PowerShell.Core/About/about_Jobs.md).</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 3: Subscribe to object events on remote computers --</maml:title> <dev:code># ProcessCreationEvent.ps1 function Enable-ProcessCreationEvent { $queryParameters = "__InstanceCreationEvent", (New-Object TimeSpan 0,0,1), "TargetInstance isa 'Win32_Process'" $Query = New-Object System.Management.WqlEventQuery -ArgumentList $queryParameters $objectEventArgs = @{ Input = New-Object System.Management.ManagementEventWatcher $Query EventName = 'EventArrived' SourceIdentifier = 'WMI.ProcessCreated' MessageData = 'Test' Forward = $True } Register-ObjectEvent @objectEventArgs } $S = New-PSSession -ComputerName "Server01, Server02" Invoke-Command -Session $S -FilePath ProcessCreationEvent.ps1 Invoke-Command -Session $S { Enable-ProcessCreationEvent }</dev:code> <dev:remarks> <maml:para>The first we create PSSessions on two remote computers and save them in the `$S` variable. Next, the `Invoke-Command` cmdlet run the `ProcessCreationEvent.ps1` script in the each of the PSSessions in `$S`. This action creates the `Enable-ProcessCreationEvent` function in the remote sessions. Finally, we run the `Enable-ProcessCreationEvent` function in the remote sessions.</maml:para> <maml:para> The function includes a `Register-ObjectEvent` command that subscribes to instance creation events on the Win32_Process object through the ManagementEventWatcher object and its EventArrived event.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 4: Use the dynamic module in the PSEventJob object --</maml:title> <dev:code>$Timer = New-Object Timers.Timer $Timer.Interval = 500 $Timer.Enabled = $True $objectEventArgs = @{ InputObject = $Timer EventName = 'Elapsed' SourceIdentifier = 'Timer.Random' Action = {$Random = Get-Random -Min 0 -Max 100} } $Job = Register-ObjectEvent @objectEventArgs $Job | Format-List -Property * & $Job.module {$Random} & $Job.module {$Random} State : Running Module : __DynamicModule_53113769-31f2-42dc-830b-8749325e28d6 StatusMessage : HasMoreData : True Location : Command : $Random = Get-Random -Min 0 -Max 100 JobStateInfo : Running Finished : System.Threading.ManualResetEvent InstanceId : 47b5ec9f-bfe3-4605-860a-4674e5d44ca8 Id : 7 Name : Timer.Random ChildJobs : {} PSBeginTime : 6/27/2019 10:19:06 AM PSEndTime : PSJobTypeName : Output : {} Error : {} Progress : {} Verbose : {} Debug : {} Warning : {} Information : {} 60 47</dev:code> <dev:remarks> <maml:para>The PSEventJob has a Module property that contains a dynamic script module that implements the action. Using the call operator (`&`), we invoke the command in the module to display the value of the `$Random` variable.</maml:para> <maml:para>For more information about modules, see about_Modules (../Microsoft.PowerShell.Core/About/about_Modules.md).</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/register-objectevent?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-EngineEvent</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Unregister-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Wait-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Remove-Event</command:name> <command:verb>Remove</command:verb> <command:noun>Event</command:noun> <maml:description> <maml:para>Deletes events from the event queue.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Remove-Event cmdlet deletes events from the event queue in the current session.</maml:para> <maml:para>This cmdlet deletes only the events currently in the queue. To cancel event registrations or unsubscribe, use the Unregister-Event cmdlet.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Remove-Event</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>EventIdentifier</maml:name> <maml:Description> <maml:para>Specifies the event identifier for which the cmdlet deletes. An EventIdentifier or SourceIdentifier parameter is required in every command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Remove-Event</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>SourceIdentifier</maml:name> <maml:Description> <maml:para>Specifies the source identifier for which this cmdlet deletes events from. Wildcards are not permitted. An EventIdentifier or SourceIdentifier parameter is required in every command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>EventIdentifier</maml:name> <maml:Description> <maml:para>Specifies the event identifier for which the cmdlet deletes. An EventIdentifier or SourceIdentifier parameter is required in every command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>SourceIdentifier</maml:name> <maml:Description> <maml:para>Specifies the source identifier for which this cmdlet deletes events from. Wildcards are not permitted. An EventIdentifier or SourceIdentifier parameter is required in every command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSEventArgs</maml:name> </dev:type> <maml:description> <maml:para>You can pipe events from Get-Event to Remove-Event .</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>The cmdlet does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>* Events, event subscriptions, and the event queue exist only in the current session. If you close the current session, the event queue is discarded and the event subscription is canceled.</maml:para> <maml:para>*</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------- Example 1: Remove an event by source identifier -------</maml:title> <dev:code>PS C:\> Remove-Event -SourceIdentifier "ProcessStarted"</dev:code> <dev:remarks> <maml:para>This command deletes events with a source identifier of Process Started from the event queue.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 2: Remove an event by event identifier --------</maml:title> <dev:code>PS C:\> Remove-Event -EventIdentifier 30</dev:code> <dev:remarks> <maml:para>This command deletes the event with an event ID of 30 from the event queue.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------------- Example 3: Remove all events -----------------</maml:title> <dev:code>PS C:\> Get-Event | Remove-Event</dev:code> <dev:remarks> <maml:para>This command deletes all events from the event queue.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/remove-event?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-EngineEvent</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-ObjectEvent</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Unregister-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Wait-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Remove-PSBreakpoint</command:name> <command:verb>Remove</command:verb> <command:noun>PSBreakpoint</command:noun> <maml:description> <maml:para>Deletes breakpoints from the current console.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Remove-PSBreakpoint cmdlet deletes a breakpoint. Enter a breakpoint object or a breakpoint ID.</maml:para> <maml:para>When you remove a breakpoint, the breakpoint object is no longer available or functional. If you have saved a breakpoint object in a variable, the reference still exists, but the breakpoint does not function. Remove-PSBreakpoint is one of several cmdlets designed for debugging Windows PowerShell scripts. For more information about the Windows PowerShell debugger, see about_Debuggers.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Remove-PSBreakpoint</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Breakpoint</maml:name> <maml:Description> <maml:para>Specifies the breakpoints to delete. Enter a variable that contains breakpoint objects or a command that gets breakpoint objects, such as a Get-PSBreakpoint command. You can also pipe breakpoint objects to Remove-PSBreakpoint .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Breakpoint[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Breakpoint[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Remove-PSBreakpoint</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Id</maml:name> <maml:Description> <maml:para>Specifies breakpoint IDs for which this cmdlet deletes breakpoints.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Breakpoint</maml:name> <maml:Description> <maml:para>Specifies the breakpoints to delete. Enter a variable that contains breakpoint objects or a command that gets breakpoint objects, such as a Get-PSBreakpoint command. You can also pipe breakpoint objects to Remove-PSBreakpoint .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Breakpoint[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Breakpoint[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Id</maml:name> <maml:Description> <maml:para>Specifies breakpoint IDs for which this cmdlet deletes breakpoints.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.Breakpoint</maml:name> </dev:type> <maml:description> <maml:para>You can pipe breakpoint objects to Remove-PSBreakpoint .</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>The cmdlet does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------- Example 1: Remove all breakpoints --------------</maml:title> <dev:code>PS C:\> Get-PSBreakpoint | Remove-PSBreakpoint</dev:code> <dev:remarks> <maml:para>This command deletes all of the breakpoints in the current console.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 2: Remove a specified breakpoint -----------</maml:title> <dev:code>PS C:\> $B = Set-PSBreakpoint -Script "sample.ps1" -Variable "Name" PS C:\> $B | Remove-PSBreakpoint</dev:code> <dev:remarks> <maml:para>This command deletes a breakpoint.</maml:para> <maml:para>The first command uses the Set-PSBreakpoint cmdlet to create a breakpoint on the Name variable in the Sample.ps1 script. Then, it saves the breakpoint object in the $B variable.</maml:para> <maml:para>The second command uses the Remove-PSBreakpoint cmdlet to delete the new breakpoint. It uses a pipeline operator (|) to send the breakpoint object in the $B variable to the Remove-PSBreakpoint cmdlet.</maml:para> <maml:para>As a result of this command, if you run the script, it runs to completion without stopping. Also, the Get-PSBreakpoint cmdlet does not return this breakpoint.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------- Example 3: Remove a breakpoint by ID -------------</maml:title> <dev:code>PS C:\> Remove-PSBreakpoint -Id 2</dev:code> <dev:remarks> <maml:para>This command deletes the breakpoint with breakpoint ID 2.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 4: Use a function to remove all breakpoints -----</maml:title> <dev:code>PS C:\> function del-psb { get-psbreakpoint | remove-psbreakpoint }</dev:code> <dev:remarks> <maml:para>This simple function deletes all of the breakpoints in the current console. It uses the Get-PSBreakpoint cmdlet to get the breakpoints. Then, it uses a pipeline operator (|) to send the breakpoints to the Remove-PSBreakpoint cmdlet, which deletes them.</maml:para> <maml:para>As a result, you can type `del-psb` instead of the longer command.</maml:para> <maml:para>To save the function, add it to your Windows PowerShell profile.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/remove-psbreakpoint?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Disable-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Enable-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-PSCallStack</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Remove-TypeData</command:name> <command:verb>Remove</command:verb> <command:noun>TypeData</command:noun> <maml:description> <maml:para>Deletes extended types from the current session.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Remove-TypeData` cmdlet deletes extended type data from the current session. This cmdlet affects only the current session and sessions that are created in the current session.</maml:para> <maml:para>You can add properties and methods to objects in PowerShell by defining them in `Update-TypeData` commands and `Types.ps1xml` files. `Remove-TypeData` deletes those extended properties and methods from the current session. `Remove-TypeData` does not delete the `Types.ps1xml` files or delete any extended type definitions from the `Types.ps1xml` files. For more information about `Types.ps1xml` files, see about_Types.ps1xml (../Microsoft.PowerShell.Core/about/about_Types.ps1xml.md).</maml:para> <maml:para>This cmdlet was introduced in Windows PowerShell 3.0.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Remove-TypeData</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies an array of files that this cmdlet deletes from the session extended type data. This parameter is required.</maml:para> <maml:para>Enter the paths and file names of one or more `Types.ps1xml` files. Wildcards are not supported. If you omit the path, the default location is the current directory.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Remove-TypeData</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>TypeData</maml:name> <maml:Description> <maml:para>Specifies the type data that this cmdlet deletes from the session. This parameter is required. Enter a variable that contains TypeData objects ( System.Management.Automation.Runspaces.TypeData ) or a command that gets TypeData objects, such as a `Get-TypeData` command. You can also pipe TypeData objects to `Remove-TypeData`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Runspaces.TypeData</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.TypeData</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Remove-TypeData</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>TypeName</maml:name> <maml:Description> <maml:para>Specifies the types that this cmdlet deletes all extended type data for. For types in the System namespace, enter the short name. Otherwise, the full type name is required. Wildcards are not supported.</maml:para> <maml:para>You can pipe type names to `Remove-TypeData`. When you pipe an object to `Remove-TypeData`, `Remove-TypeData` gets the type name of the object and removes all type data for the object type.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies an array of files that this cmdlet deletes from the session extended type data. This parameter is required.</maml:para> <maml:para>Enter the paths and file names of one or more `Types.ps1xml` files. Wildcards are not supported. If you omit the path, the default location is the current directory.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>TypeData</maml:name> <maml:Description> <maml:para>Specifies the type data that this cmdlet deletes from the session. This parameter is required. Enter a variable that contains TypeData objects ( System.Management.Automation.Runspaces.TypeData ) or a command that gets TypeData objects, such as a `Get-TypeData` command. You can also pipe TypeData objects to `Remove-TypeData`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Runspaces.TypeData</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.TypeData</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>TypeName</maml:name> <maml:Description> <maml:para>Specifies the types that this cmdlet deletes all extended type data for. For types in the System namespace, enter the short name. Otherwise, the full type name is required. Wildcards are not supported.</maml:para> <maml:para>You can pipe type names to `Remove-TypeData`. When you pipe an object to `Remove-TypeData`, `Remove-TypeData` gets the type name of the object and removes all type data for the object type.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.Runspaces.TypeData</maml:name> </dev:type> <maml:description> <maml:para>You can pipe TypeData object, such as the ones that the `Get-TypeData` cmdlet returns, to `Remove-TypeData`.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe the type names to `Remove-TypeData`. When you pipe an object to `Remove-TypeData`, `Remove-TypeData` gets the type name of the object and removes all type data for the object type.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>This cmdlet does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>`Remove-TypeData` can remove only the extended type data in the current session. It cannot remove extended type data that is on the computer, but has not been added to the current session, such as extended types that are defined in modules that have not been imported into the current session.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------- Example 1: Remove type data for a specified type -------</maml:title> <dev:code>Remove-TypeData -TypeName System.Array</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 2: Remove an extended data type from a session ----</maml:title> <dev:code>Get-TypeData System.DateTime (Get-Date).DateTime Get-TypeData System.DateTime | Remove-TypeData (Get-Date).DateTime TypeName Members -------- ------- System.DateTime {[DateTime, System.Management.Automation.Runspaces.ScriptPropertyData]} Friday, January 20, 2012 9:01:00 PM</dev:code> <dev:remarks> <maml:para>The next `Get-TypeData` cmdlet to get all extended type data for the System.DateTime type and pipes that to the `Remove-TypeData` cmdlet to delete the extended type data. The last `Get-Date` cmdlet shows the effect of deleting the extended type data for the System.DateTime type. Because the System.DateTime property no longer exists, a command to get its value returns nothing.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 3: Remove extended types for modules ---------</maml:title> <dev:code>Get-Module | Remove-TypeData</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--- Example 4: Remove extended types from specified modules ---</maml:title> <dev:code>Remove-TypeData -Path "$PSHOME\Modules\PSScheduledJob", "$PSHOME\Modules\PSWorkflow\PSWorkflow.types.ps1xml"</dev:code> <dev:remarks> <maml:para>For more information about modules, see about_Modules (../Microsoft.PowerShell.Core/About/about_Modules.md).</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 5: Remove extended types from a remote session ----</maml:title> <dev:code>Invoke-Command -Session $S {Get-TypeData -TypeName *CIM* | Remove-TypeData}</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/remove-typedata?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-TypeData</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Update-TypeData</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Remove-Variable</command:name> <command:verb>Remove</command:verb> <command:noun>Variable</command:noun> <maml:description> <maml:para>Deletes a variable and its value.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Remove-Variable` cmdlet deletes a variable and its value from the scope in which it is defined, such as the current session. You cannot use this cmdlet to delete variables that are set as constants or those that are owned by the system.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Remove-Variable</maml:name> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the name of the variable to be removed. The parameter name ( Name ) is optional. Wildcards are permitted</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Exclude</maml:name> <maml:Description> <maml:para>Specifies an array of items that this cmdlet omits from the operation. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as "s*". Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet removes a variable even if it is read-only. Even using the Force parameter, the cmdlet cannot remove a constant.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Include</maml:name> <maml:Description> <maml:para>Specifies an array of items that this cmdlet deletes in the operation. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as s*. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Gets only the variables in the specified scope. The acceptable values for this parameter are:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Script</maml:para> <maml:para>- A number relative to the current scope (0 through the number of scopes, where 0 is the current</maml:para> <maml:para> scope and 1 is its parent)</maml:para> <maml:para>Local is the default. For more information, see about_Scopes (../Microsoft.PowerShell.Core/About/about_Scopes.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Exclude</maml:name> <maml:Description> <maml:para>Specifies an array of items that this cmdlet omits from the operation. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as "s*". Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet removes a variable even if it is read-only. Even using the Force parameter, the cmdlet cannot remove a constant.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Include</maml:name> <maml:Description> <maml:para>Specifies an array of items that this cmdlet deletes in the operation. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as s*. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the name of the variable to be removed. The parameter name ( Name ) is optional. Wildcards are permitted</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Gets only the variables in the specified scope. The acceptable values for this parameter are:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Script</maml:para> <maml:para>- A number relative to the current scope (0 through the number of scopes, where 0 is the current</maml:para> <maml:para> scope and 1 is its parent)</maml:para> <maml:para>Local is the default. For more information, see about_Scopes (../Microsoft.PowerShell.Core/About/about_Scopes.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSVariable</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a variable object to `Remove-Variable`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>This cmdlet does not return any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>- Changes affect only the current scope, such as a session. To delete a variable from all sessions, add a `Remove-Variable` command to your PowerShell profile.</maml:para> <maml:para>- You can also refer to `Remove-Variable` by its built-in alias, `rv`. For more information, see about_Aliases (../Microsoft.PowerShell.Core/About/about_Aliases.md).</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>----------------- Example 1: Remove a variable -----------------</maml:title> <dev:code>Remove-Variable Smp</dev:code> <dev:remarks> <maml:para>This command deletes the `$Smp` variable.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/remove-variable?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Clear-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Select-Object</command:name> <command:verb>Select</command:verb> <command:noun>Object</command:noun> <maml:description> <maml:para>Selects objects or object properties.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Select-Object` cmdlet selects specified properties of an object or set of objects. It can also select unique objects, a specified number of objects, or objects in a specified position in an array.</maml:para> <maml:para>To select objects from a collection, use the First , Last , Unique , Skip , and Index parameters. To select object properties, use the Property parameter. When you select properties, `Select-Object` returns new objects that have only the specified properties.</maml:para> <maml:para>Beginning in Windows PowerShell 3.0, `Select-Object` includes an optimization feature that prevents commands from creating and processing objects that are not used.</maml:para> <maml:para>When you include a `Select-Object` command with the First or Index parameters in a command pipeline, PowerShell stops the command that generates the objects as soon as the selected number of objects is generated, even when the command that generates the objects appears before the `Select-Object` command in the pipeline. To turn off this optimizing behavior, use the Wait parameter.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Select-Object</maml:name> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the properties to select. These properties are added as NoteProperty members to the output objects. Wildcards are permitted.</maml:para> <maml:para>The value of the Property parameter can be a new calculated property. To create a calculated, property, use a hash table.</maml:para> <maml:para>Valid keys are:</maml:para> <maml:para>- Name (or Label): `<string>`</maml:para> <maml:para>- Expression `<string>` or `<script block>`</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>ExcludeProperty</maml:name> <maml:Description> <maml:para>Specifies the properties that this cmdlet excludes from the operation. Wildcards are permitted. This parameter is effective only when the command also includes the Property parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ExpandProperty</maml:name> <maml:Description> <maml:para>Specifies a property to select, and indicates that an attempt should be made to expand that property.</maml:para> <maml:para>- If the specified property is an array, each value of the array is included in the output.</maml:para> <maml:para>- If the specified property is an object, the objects properties are expanded for every InputObject In either case, the Type of objects output will match the Type of the expanded property.</maml:para> <maml:para>If the Property parameter is specified, `Select-Object` will attempt to add each selected property as a NoteProperty to every outputted object.</maml:para> <maml:para>> [!WARNING] > If you receive the error: Select : Property cannot be processed because property `<PropertyName>` > already exists, consider the following. > Note that when using `-ExpandProperty`, `Select-Object` can not replace an existing property. > This means: > > - If the expanded object has a property of the same name, an error will occur. > - If the Selected object has a property of the same name as an Expanded objects property, an > error will occur.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>First</maml:name> <maml:Description> <maml:para>Specifies the number of objects to select from the beginning of an array of input objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies objects to send to the cmdlet through the pipeline. This parameter enables you to pipe objects to `Select-Object`.</maml:para> <maml:para>When you pass objects to the InputObject parameter, instead of using the pipeline, `Select-Object` treats the InputObject as a single object, even if the value is a collection. It is recommended that you use the pipeline when passing collections to `Select-Object`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Last</maml:name> <maml:Description> <maml:para>Specifies the number of objects to select from the end of an array of input objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Skip</maml:name> <maml:Description> <maml:para>Skips (does not select) the specified number of items. By default, the Skip parameter counts from the beginning of the array or list of objects, but if the command uses the Last parameter, it counts from the end of the list or array.</maml:para> <maml:para>Unlike the Index parameter, which starts counting at 0, the Skip parameter begins at 1.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Unique</maml:name> <maml:Description> <maml:para>Specifies that if a subset of the input objects has identical properties and values, only a single member of the subset will be selected.</maml:para> <maml:para>This parameter is case-sensitive. As a result, strings that differ only in character casing are considered to be unique.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Wait</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet turns off optimization. PowerShell runs commands in the order that they appear in the command pipeline and lets them generate all objects. By default, if you include a `Select-Object` command with the First or Index parameters in a command pipeline, PowerShell stops the command that generates the objects as soon as the selected number of objects is generated.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Select-Object</maml:name> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the properties to select. These properties are added as NoteProperty members to the output objects. Wildcards are permitted.</maml:para> <maml:para>The value of the Property parameter can be a new calculated property. To create a calculated, property, use a hash table.</maml:para> <maml:para>Valid keys are:</maml:para> <maml:para>- Name (or Label): `<string>`</maml:para> <maml:para>- Expression `<string>` or `<script block>`</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>ExcludeProperty</maml:name> <maml:Description> <maml:para>Specifies the properties that this cmdlet excludes from the operation. Wildcards are permitted. This parameter is effective only when the command also includes the Property parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ExpandProperty</maml:name> <maml:Description> <maml:para>Specifies a property to select, and indicates that an attempt should be made to expand that property.</maml:para> <maml:para>- If the specified property is an array, each value of the array is included in the output.</maml:para> <maml:para>- If the specified property is an object, the objects properties are expanded for every InputObject In either case, the Type of objects output will match the Type of the expanded property.</maml:para> <maml:para>If the Property parameter is specified, `Select-Object` will attempt to add each selected property as a NoteProperty to every outputted object.</maml:para> <maml:para>> [!WARNING] > If you receive the error: Select : Property cannot be processed because property `<PropertyName>` > already exists, consider the following. > Note that when using `-ExpandProperty`, `Select-Object` can not replace an existing property. > This means: > > - If the expanded object has a property of the same name, an error will occur. > - If the Selected object has a property of the same name as an Expanded objects property, an > error will occur.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies objects to send to the cmdlet through the pipeline. This parameter enables you to pipe objects to `Select-Object`.</maml:para> <maml:para>When you pass objects to the InputObject parameter, instead of using the pipeline, `Select-Object` treats the InputObject as a single object, even if the value is a collection. It is recommended that you use the pipeline when passing collections to `Select-Object`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SkipLast</maml:name> <maml:Description> <maml:para>Skips (does not select) the specified number of items from the end of the list or array. Works in the same way as using Skip together with Last parameter.</maml:para> <maml:para>Unlike the Index parameter, which starts counting at 0, the SkipLast parameter begins at 1.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Unique</maml:name> <maml:Description> <maml:para>Specifies that if a subset of the input objects has identical properties and values, only a single member of the subset will be selected.</maml:para> <maml:para>This parameter is case-sensitive. As a result, strings that differ only in character casing are considered to be unique.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Select-Object</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Index</maml:name> <maml:Description> <maml:para>Selects objects from an array based on their index values. Enter the indexes in a comma-separated list. Indexes in an array begin with 0, where 0 represents the first value and (n-1) represents the last value.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies objects to send to the cmdlet through the pipeline. This parameter enables you to pipe objects to `Select-Object`.</maml:para> <maml:para>When you pass objects to the InputObject parameter, instead of using the pipeline, `Select-Object` treats the InputObject as a single object, even if the value is a collection. It is recommended that you use the pipeline when passing collections to `Select-Object`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Unique</maml:name> <maml:Description> <maml:para>Specifies that if a subset of the input objects has identical properties and values, only a single member of the subset will be selected.</maml:para> <maml:para>This parameter is case-sensitive. As a result, strings that differ only in character casing are considered to be unique.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Wait</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet turns off optimization. PowerShell runs commands in the order that they appear in the command pipeline and lets them generate all objects. By default, if you include a `Select-Object` command with the First or Index parameters in a command pipeline, PowerShell stops the command that generates the objects as soon as the selected number of objects is generated.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>ExcludeProperty</maml:name> <maml:Description> <maml:para>Specifies the properties that this cmdlet excludes from the operation. Wildcards are permitted. This parameter is effective only when the command also includes the Property parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ExpandProperty</maml:name> <maml:Description> <maml:para>Specifies a property to select, and indicates that an attempt should be made to expand that property.</maml:para> <maml:para>- If the specified property is an array, each value of the array is included in the output.</maml:para> <maml:para>- If the specified property is an object, the objects properties are expanded for every InputObject In either case, the Type of objects output will match the Type of the expanded property.</maml:para> <maml:para>If the Property parameter is specified, `Select-Object` will attempt to add each selected property as a NoteProperty to every outputted object.</maml:para> <maml:para>> [!WARNING] > If you receive the error: Select : Property cannot be processed because property `<PropertyName>` > already exists, consider the following. > Note that when using `-ExpandProperty`, `Select-Object` can not replace an existing property. > This means: > > - If the expanded object has a property of the same name, an error will occur. > - If the Selected object has a property of the same name as an Expanded objects property, an > error will occur.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>First</maml:name> <maml:Description> <maml:para>Specifies the number of objects to select from the beginning of an array of input objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Index</maml:name> <maml:Description> <maml:para>Selects objects from an array based on their index values. Enter the indexes in a comma-separated list. Indexes in an array begin with 0, where 0 represents the first value and (n-1) represents the last value.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies objects to send to the cmdlet through the pipeline. This parameter enables you to pipe objects to `Select-Object`.</maml:para> <maml:para>When you pass objects to the InputObject parameter, instead of using the pipeline, `Select-Object` treats the InputObject as a single object, even if the value is a collection. It is recommended that you use the pipeline when passing collections to `Select-Object`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Last</maml:name> <maml:Description> <maml:para>Specifies the number of objects to select from the end of an array of input objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the properties to select. These properties are added as NoteProperty members to the output objects. Wildcards are permitted.</maml:para> <maml:para>The value of the Property parameter can be a new calculated property. To create a calculated, property, use a hash table.</maml:para> <maml:para>Valid keys are:</maml:para> <maml:para>- Name (or Label): `<string>`</maml:para> <maml:para>- Expression `<string>` or `<script block>`</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Skip</maml:name> <maml:Description> <maml:para>Skips (does not select) the specified number of items. By default, the Skip parameter counts from the beginning of the array or list of objects, but if the command uses the Last parameter, it counts from the end of the list or array.</maml:para> <maml:para>Unlike the Index parameter, which starts counting at 0, the Skip parameter begins at 1.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SkipLast</maml:name> <maml:Description> <maml:para>Skips (does not select) the specified number of items from the end of the list or array. Works in the same way as using Skip together with Last parameter.</maml:para> <maml:para>Unlike the Index parameter, which starts counting at 0, the SkipLast parameter begins at 1.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Unique</maml:name> <maml:Description> <maml:para>Specifies that if a subset of the input objects has identical properties and values, only a single member of the subset will be selected.</maml:para> <maml:para>This parameter is case-sensitive. As a result, strings that differ only in character casing are considered to be unique.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Wait</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet turns off optimization. PowerShell runs commands in the order that they appear in the command pipeline and lets them generate all objects. By default, if you include a `Select-Object` command with the First or Index parameters in a command pipeline, PowerShell stops the command that generates the objects as soon as the selected number of objects is generated.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe any object to `Select-Object`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para></maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>- You can also refer to the `Select-Object` cmdlet by its built-in alias, `select`. For more information, see about_Aliases (../Microsoft.PowerShell.Core/About/about_Aliases.md). - The optimization feature of `Select-Object` is available only for commands that write objects to the pipeline as they are processed. It has no effect on commands that buffer processed objects and write them as a collection. Writing objects immediately is a cmdlet design best practice. For more information, see Write Single Records to the Pipeline in Strongly Encouraged Development Guidelines (/powershell/scripting/developer/windows-powershell).</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------ Example 1: Select objects by property ------------</maml:title> <dev:code>Get-Process | Select-Object -Property ProcessName, Id, WS</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>- Example 2: Select objects by property and format the results -</maml:title> <dev:code>Get-Process Explorer | Select-Object -Property ProcessName -ExpandProperty Modules | Format-List ProcessName : explorer ModuleName : explorer.exe FileName : C:\WINDOWS\explorer.exe BaseAddress : 140697278152704 ModuleMemorySize : 3919872 EntryPointAddress : 140697278841168 FileVersionInfo : File: C:\WINDOWS\explorer.exe InternalName: explorer OriginalFilename: EXPLORER.EXE.MUI FileVersion: 10.0.17134.1 (WinBuild.160101.0800) FileDescription: Windows Explorer Product: Microsoft Windows Operating System ProductVersion: 10.0.17134.1 ...</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 3: Select processes using the most memory ------</maml:title> <dev:code>Get-Process | Sort-Object -Property WS | Select-Object -Last 5 Handles NPM(K) PM(K) WS(K) VS(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- 2866 320 33432 45764 203 222.41 1292 svchost 577 17 23676 50516 265 50.58 4388 WINWORD 826 11 75448 76712 188 19.77 3780 Ps 1367 14 73152 88736 216 61.69 676 Ps 1612 44 66080 92780 380 900.59 6132 INFOPATH</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 4: Select unique characters from an array ------</maml:title> <dev:code>"a","b","c","a","a","a" | Select-Object -Unique a b c</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>- Example 5: Select newest and oldest events in the event log -</maml:title> <dev:code>$a = Get-EventLog -LogName "Windows PowerShell" $a | Select-Object -Index 0, ($A.count - 1)</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 6: Select all but the first object ----------</maml:title> <dev:code>New-PSSession -ComputerName (Get-Content Servers.txt | Select-Object -Skip 1)</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 7: Rename files and select several to review -----</maml:title> <dev:code>Get-ChildItem *.txt -ReadOnly | Rename-Item -NewName {$_.BaseName + "-ro.txt"} -PassThru | Select-Object -First 5 -Wait</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 8: Demonstrate the intricacies of the -ExpandProperty parameter</maml:title> <dev:code># Create a custom object to use for the Select-Object example. $object = [pscustomobject]@{Name="CustomObject";Expand=@(1,2,3,4,5)} # Use the ExpandProperty parameter to Expand the property. $object | Select-Object -ExpandProperty Expand -Property Name 1 2 3 4 5 # The output did not contain the Name property, but it was added successfully. # Use Get-Member to confirm the Name property was added and populated. $object | Select-Object -ExpandProperty Expand -Property Name | Get-Member TypeName: System.Int32 Name MemberType Definition ---- ---------- ---------- CompareTo Method int CompareTo(System.Object value), int CompareTo(int value), int IComparable.CompareTo(System.Object obj)... Equals Method bool Equals(System.Object obj), bool Equals(int obj), bool IEquatable[int].Equals(int other) GetHashCode Method int GetHashCode() GetType Method type GetType() GetTypeCode Method System.TypeCode GetTypeCode(), System.TypeCode IConvertible.GetTypeCode() ToBoolean Method bool IConvertible.ToBoolean(System.IFormatProvider provider) ToByte Method byte IConvertible.ToByte(System.IFormatProvider provider) ToChar Method char IConvertible.ToChar(System.IFormatProvider provider) ToDateTime Method datetime IConvertible.ToDateTime(System.IFormatProvider provider) ToDecimal Method decimal IConvertible.ToDecimal(System.IFormatProvider provider) ToDouble Method double IConvertible.ToDouble(System.IFormatProvider provider) ToInt16 Method int16 IConvertible.ToInt16(System.IFormatProvider provider) ToInt32 Method int IConvertible.ToInt32(System.IFormatProvider provider) ToInt64 Method long IConvertible.ToInt64(System.IFormatProvider provider) ToSByte Method sbyte IConvertible.ToSByte(System.IFormatProvider provider) ToSingle Method float IConvertible.ToSingle(System.IFormatProvider provider) ToString Method string ToString(), string ToString(string format), string ToString(System.IFormatProvider provider)... ToType Method System.Object IConvertible.ToType(type conversionType, System.IFormatProvider provider) ToUInt16 Method uint16 IConvertible.ToUInt16(System.IFormatProvider provider) ToUInt32 Method uint32 IConvertible.ToUInt32(System.IFormatProvider provider) ToUInt64 Method uint64 IConvertible.ToUInt64(System.IFormatProvider provider) Name NoteProperty string Name=CustomObject</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 9: Create custom properties on objects --------</maml:title> <dev:code>$customObject = 1 | Select-Object -Property MyCustomProperty $customObject.MyCustomProperty = "New Custom Property" $customObject MyCustomProperty ---------------- New Custom Property</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title> Example 10: Create calculated properties for each InputObject </maml:title> <dev:code># Create a calculated property called $_.StartTime.DayOfWeek Get-Process | Select-Object -Property ProcessName,{$_.StartTime.DayOfWeek} ProcessName $_.StartTime.DayOfWeek ---- ---------------------- alg Wednesday ati2evxx Wednesday ati2evxx Thursday ... # Add a custom property to calculate the size in KiloBytes of each FileInfo object you pass in. # Use the pipeline variable to divide each file's length by 1 KiloBytes $size = @{label="Size(KB)";expression={$_.length/1KB}} # Create an additional calculated property with the number of Days since the file was last accessed. # You can also shorten the key names to be 'l', and 'e', or use Name instead of Label. $days = @{l="Days";e={((Get-Date) - $_.LastAccessTime).Days}} # You can also shorten the name of your label key to 'l' and your expression key to 'e'. Get-ChildItem $PSHOME -File | Select-Object Name, $size, $days Name Size(KB) Days ---- -------- ---- Certificate.format.ps1xml 12.5244140625 223 Diagnostics.Format.ps1xml 4.955078125 223 DotNetTypes.format.ps1xml 134.9833984375 223</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/select-object?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Group-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Sort-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Where-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Select-String</command:name> <command:verb>Select</command:verb> <command:noun>String</command:noun> <maml:description> <maml:para>Finds text in strings and files.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Select-String` cmdlet searches for text and text patterns in input strings and files. You can use `Select-String` similar to grep in UNIX or findstr.exe in Windows.</maml:para> <maml:para>`Select-String` is based on lines of text. By default, `Select-String` finds the first match in each line and, for each match, it displays the file name, line number, and all text in the line containing the match. You can direct `Select-String` to find multiple matches per line, display text before and after the match, or display a Boolean value (True or False) that indicates whether a match is found.</maml:para> <maml:para>`Select-String` uses regular expression matching, but it can also perform a match that searches the input for the text that you specify.</maml:para> <maml:para>`Select-String` can display all the text matches or stop after the first match in each input file. `Select-String` can be used to display all text that doesn't match the specified pattern.</maml:para> <maml:para>You can also specify that `Select-String` should expect a particular character encoding, such as when you're searching files of Unicode text. `Select-String` uses the byte-order-mark (BOM) to detect the encoding format of the file. If the file has no BOM, it assumes the encoding is UTF8.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Select-String</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Pattern</maml:name> <maml:Description> <maml:para>Specifies the text to find on each line. The pattern value is treated as a regular expression.</maml:para> <maml:para>To learn about regular expressions, see about_Regular_Expressions (../Microsoft.PowerShell.Core/About/about_Regular_Expressions.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AllMatches</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet searches for more than one match in each line of text. Without this parameter, `Select-String` finds only the first match in each line of text.</maml:para> <maml:para>When `Select-String` finds more than one match in a line of text, it still emits only one MatchInfo object for the line, but the Matches property of the object contains all the matches.</maml:para> <maml:para>> [!NOTE] > This parameter is ignored when used in combination with the SimpleMatch parameter. If you wish > to return all matches and the pattern that you are searching for contains regular expression > characters, you must escape those characters rather than using SimpleMatch . See > about_Regular_Expressions (../Microsoft.PowerShell.Core/About/about_Regular_Expressions.md)for > more information about escaping regular expressions.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CaseSensitive</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet matches are case-sensitive. By default, matches aren't case-sensitive.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Context</maml:name> <maml:Description> <maml:para>Captures the specified number of lines before and after the line that matches the pattern.</maml:para> <maml:para>If you enter one number as the value of this parameter, that number determines the number of lines captured before and after the match. If you enter two numbers as the value, the first number determines the number of lines before the match and the second number determines the number of lines after the match. For example, `-Context 2,3`.</maml:para> <maml:para>In the default display, lines with a match are indicated by a right angle bracket (`>`) (ASCII 62) in the first column of the display. Unmarked lines are the context.</maml:para> <maml:para>The Context parameter doesn't change the number of objects generated by `Select-String`. `Select-String` generates one MatchInfo (/dotnet/api/microsoft.powershell.commands.matchinfo)object for each match. The context is stored as an array of strings in the Context property of the object.</maml:para> <maml:para>When the output of a `Select-String` command is sent down the pipeline to another `Select-String` command, the receiving command searches only the text in the matched line. The matched line is the value of the Line property of the MatchInfo object, not the text in the context lines. As a result, the Context parameter isn't valid on the receiving `Select-String` command.</maml:para> <maml:para>When the context includes a match, the MatchInfo object for each match includes all the context lines, but the overlapping lines appear only once in the display.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is `default`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ascii` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `bigendianunicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `oem` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `utf7` Uses UTF-7.</maml:para> <maml:para>- `utf8` Uses UTF-8.</maml:para> <maml:para>- `utf32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">ASCII</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">BigEndianUnicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Default</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OEM</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF7</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF8</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF32</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Default</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Exclude</maml:name> <maml:Description> <maml:para>Exclude the specified items. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as `*.txt`. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Include</maml:name> <maml:Description> <maml:para>Includes the specified items. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as `*.txt`. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the text to be searched. Enter a variable that contains the text, or type a command or expression that gets the text.</maml:para> <maml:para>Using the InputObject parameter isn't the same as sending strings down the pipeline to `Select-String`.</maml:para> <maml:para>When you pipe more than one string to the `Select-String` cmdlet, it searches for the specified text in each string and returns each string that contains the search text.</maml:para> <maml:para>When you use the InputObject parameter to submit a collection of strings, `Select-String` treats the collection as a single combined string. `Select-String` returns the strings as a unit if it finds the search text in any string.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>List</maml:name> <maml:Description> <maml:para>Only the first instance of matching text is returned from each input file. This is the most efficient way to retrieve a list of files that have contents matching the regular expression.</maml:para> <maml:para>By default, `Select-String` returns a MatchInfo object for each match it finds.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NotMatch</maml:name> <maml:Description> <maml:para>The NotMatch parameter finds text that doesn't match the specified pattern.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Quiet</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet returns a Boolean value (True or False), instead of a MatchInfo object. The value is True if the pattern is found; otherwise the value is False.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SimpleMatch</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet uses a simple match rather than a regular expression match. In a simple match, `Select-String` searches the input for the text in the Pattern parameter. It doesn't interpret the value of the Pattern parameter as a regular expression statement.</maml:para> <maml:para>Also, when SimpleMatch is used, the Matches property of the MatchInfo object returned is empty.</maml:para> <maml:para>> [!NOTE] > When this parameter is used with the AllMatches parameter, the AllMatches is ignored.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Select-String</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Pattern</maml:name> <maml:Description> <maml:para>Specifies the text to find on each line. The pattern value is treated as a regular expression.</maml:para> <maml:para>To learn about regular expressions, see about_Regular_Expressions (../Microsoft.PowerShell.Core/About/about_Regular_Expressions.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AllMatches</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet searches for more than one match in each line of text. Without this parameter, `Select-String` finds only the first match in each line of text.</maml:para> <maml:para>When `Select-String` finds more than one match in a line of text, it still emits only one MatchInfo object for the line, but the Matches property of the object contains all the matches.</maml:para> <maml:para>> [!NOTE] > This parameter is ignored when used in combination with the SimpleMatch parameter. If you wish > to return all matches and the pattern that you are searching for contains regular expression > characters, you must escape those characters rather than using SimpleMatch . See > about_Regular_Expressions (../Microsoft.PowerShell.Core/About/about_Regular_Expressions.md)for > more information about escaping regular expressions.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CaseSensitive</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet matches are case-sensitive. By default, matches aren't case-sensitive.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Context</maml:name> <maml:Description> <maml:para>Captures the specified number of lines before and after the line that matches the pattern.</maml:para> <maml:para>If you enter one number as the value of this parameter, that number determines the number of lines captured before and after the match. If you enter two numbers as the value, the first number determines the number of lines before the match and the second number determines the number of lines after the match. For example, `-Context 2,3`.</maml:para> <maml:para>In the default display, lines with a match are indicated by a right angle bracket (`>`) (ASCII 62) in the first column of the display. Unmarked lines are the context.</maml:para> <maml:para>The Context parameter doesn't change the number of objects generated by `Select-String`. `Select-String` generates one MatchInfo (/dotnet/api/microsoft.powershell.commands.matchinfo)object for each match. The context is stored as an array of strings in the Context property of the object.</maml:para> <maml:para>When the output of a `Select-String` command is sent down the pipeline to another `Select-String` command, the receiving command searches only the text in the matched line. The matched line is the value of the Line property of the MatchInfo object, not the text in the context lines. As a result, the Context parameter isn't valid on the receiving `Select-String` command.</maml:para> <maml:para>When the context includes a match, the MatchInfo object for each match includes all the context lines, but the overlapping lines appear only once in the display.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is `default`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ascii` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `bigendianunicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `oem` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `utf7` Uses UTF-7.</maml:para> <maml:para>- `utf8` Uses UTF-8.</maml:para> <maml:para>- `utf32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">ASCII</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">BigEndianUnicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Default</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OEM</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF7</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF8</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF32</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Default</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Exclude</maml:name> <maml:Description> <maml:para>Exclude the specified items. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as `*.txt`. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Include</maml:name> <maml:Description> <maml:para>Includes the specified items. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as `*.txt`. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>List</maml:name> <maml:Description> <maml:para>Only the first instance of matching text is returned from each input file. This is the most efficient way to retrieve a list of files that have contents matching the regular expression.</maml:para> <maml:para>By default, `Select-String` returns a MatchInfo object for each match it finds.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to the files to be searched. The value of the LiteralPath parameter is used exactly as it's typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences. For more information, see about_Quoting_Rules (../Microsoft.Powershell.Core/About/about_Quoting_Rules.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NotMatch</maml:name> <maml:Description> <maml:para>The NotMatch parameter finds text that doesn't match the specified pattern.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Quiet</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet returns a Boolean value (True or False), instead of a MatchInfo object. The value is True if the pattern is found; otherwise the value is False.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SimpleMatch</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet uses a simple match rather than a regular expression match. In a simple match, `Select-String` searches the input for the text in the Pattern parameter. It doesn't interpret the value of the Pattern parameter as a regular expression statement.</maml:para> <maml:para>Also, when SimpleMatch is used, the Matches property of the MatchInfo object returned is empty.</maml:para> <maml:para>> [!NOTE] > When this parameter is used with the AllMatches parameter, the AllMatches is ignored.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Select-String</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Pattern</maml:name> <maml:Description> <maml:para>Specifies the text to find on each line. The pattern value is treated as a regular expression.</maml:para> <maml:para>To learn about regular expressions, see about_Regular_Expressions (../Microsoft.PowerShell.Core/About/about_Regular_Expressions.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the path to the files to search. Wildcards are permitted. The default location is the local directory.</maml:para> <maml:para>Specify files in the directory, such as `log1.txt`, ` .doc`, or ` .*`. If you specify only a directory, the command fails.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Local directory</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AllMatches</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet searches for more than one match in each line of text. Without this parameter, `Select-String` finds only the first match in each line of text.</maml:para> <maml:para>When `Select-String` finds more than one match in a line of text, it still emits only one MatchInfo object for the line, but the Matches property of the object contains all the matches.</maml:para> <maml:para>> [!NOTE] > This parameter is ignored when used in combination with the SimpleMatch parameter. If you wish > to return all matches and the pattern that you are searching for contains regular expression > characters, you must escape those characters rather than using SimpleMatch . See > about_Regular_Expressions (../Microsoft.PowerShell.Core/About/about_Regular_Expressions.md)for > more information about escaping regular expressions.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CaseSensitive</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet matches are case-sensitive. By default, matches aren't case-sensitive.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Context</maml:name> <maml:Description> <maml:para>Captures the specified number of lines before and after the line that matches the pattern.</maml:para> <maml:para>If you enter one number as the value of this parameter, that number determines the number of lines captured before and after the match. If you enter two numbers as the value, the first number determines the number of lines before the match and the second number determines the number of lines after the match. For example, `-Context 2,3`.</maml:para> <maml:para>In the default display, lines with a match are indicated by a right angle bracket (`>`) (ASCII 62) in the first column of the display. Unmarked lines are the context.</maml:para> <maml:para>The Context parameter doesn't change the number of objects generated by `Select-String`. `Select-String` generates one MatchInfo (/dotnet/api/microsoft.powershell.commands.matchinfo)object for each match. The context is stored as an array of strings in the Context property of the object.</maml:para> <maml:para>When the output of a `Select-String` command is sent down the pipeline to another `Select-String` command, the receiving command searches only the text in the matched line. The matched line is the value of the Line property of the MatchInfo object, not the text in the context lines. As a result, the Context parameter isn't valid on the receiving `Select-String` command.</maml:para> <maml:para>When the context includes a match, the MatchInfo object for each match includes all the context lines, but the overlapping lines appear only once in the display.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is `default`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ascii` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `bigendianunicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `oem` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `utf7` Uses UTF-7.</maml:para> <maml:para>- `utf8` Uses UTF-8.</maml:para> <maml:para>- `utf32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">ASCII</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">BigEndianUnicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Default</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OEM</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF7</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF8</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF32</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Default</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Exclude</maml:name> <maml:Description> <maml:para>Exclude the specified items. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as `*.txt`. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Include</maml:name> <maml:Description> <maml:para>Includes the specified items. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as `*.txt`. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>List</maml:name> <maml:Description> <maml:para>Only the first instance of matching text is returned from each input file. This is the most efficient way to retrieve a list of files that have contents matching the regular expression.</maml:para> <maml:para>By default, `Select-String` returns a MatchInfo object for each match it finds.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NotMatch</maml:name> <maml:Description> <maml:para>The NotMatch parameter finds text that doesn't match the specified pattern.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Quiet</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet returns a Boolean value (True or False), instead of a MatchInfo object. The value is True if the pattern is found; otherwise the value is False.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SimpleMatch</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet uses a simple match rather than a regular expression match. In a simple match, `Select-String` searches the input for the text in the Pattern parameter. It doesn't interpret the value of the Pattern parameter as a regular expression statement.</maml:para> <maml:para>Also, when SimpleMatch is used, the Matches property of the MatchInfo object returned is empty.</maml:para> <maml:para>> [!NOTE] > When this parameter is used with the AllMatches parameter, the AllMatches is ignored.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>AllMatches</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet searches for more than one match in each line of text. Without this parameter, `Select-String` finds only the first match in each line of text.</maml:para> <maml:para>When `Select-String` finds more than one match in a line of text, it still emits only one MatchInfo object for the line, but the Matches property of the object contains all the matches.</maml:para> <maml:para>> [!NOTE] > This parameter is ignored when used in combination with the SimpleMatch parameter. If you wish > to return all matches and the pattern that you are searching for contains regular expression > characters, you must escape those characters rather than using SimpleMatch . See > about_Regular_Expressions (../Microsoft.PowerShell.Core/About/about_Regular_Expressions.md)for > more information about escaping regular expressions.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CaseSensitive</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet matches are case-sensitive. By default, matches aren't case-sensitive.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Context</maml:name> <maml:Description> <maml:para>Captures the specified number of lines before and after the line that matches the pattern.</maml:para> <maml:para>If you enter one number as the value of this parameter, that number determines the number of lines captured before and after the match. If you enter two numbers as the value, the first number determines the number of lines before the match and the second number determines the number of lines after the match. For example, `-Context 2,3`.</maml:para> <maml:para>In the default display, lines with a match are indicated by a right angle bracket (`>`) (ASCII 62) in the first column of the display. Unmarked lines are the context.</maml:para> <maml:para>The Context parameter doesn't change the number of objects generated by `Select-String`. `Select-String` generates one MatchInfo (/dotnet/api/microsoft.powershell.commands.matchinfo)object for each match. The context is stored as an array of strings in the Context property of the object.</maml:para> <maml:para>When the output of a `Select-String` command is sent down the pipeline to another `Select-String` command, the receiving command searches only the text in the matched line. The matched line is the value of the Line property of the MatchInfo object, not the text in the context lines. As a result, the Context parameter isn't valid on the receiving `Select-String` command.</maml:para> <maml:para>When the context includes a match, the MatchInfo object for each match includes all the context lines, but the overlapping lines appear only once in the display.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is `default`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ascii` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `bigendianunicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `oem` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `utf7` Uses UTF-7.</maml:para> <maml:para>- `utf8` Uses UTF-8.</maml:para> <maml:para>- `utf32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Default</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Exclude</maml:name> <maml:Description> <maml:para>Exclude the specified items. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as `*.txt`. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Include</maml:name> <maml:Description> <maml:para>Includes the specified items. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as `*.txt`. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the text to be searched. Enter a variable that contains the text, or type a command or expression that gets the text.</maml:para> <maml:para>Using the InputObject parameter isn't the same as sending strings down the pipeline to `Select-String`.</maml:para> <maml:para>When you pipe more than one string to the `Select-String` cmdlet, it searches for the specified text in each string and returns each string that contains the search text.</maml:para> <maml:para>When you use the InputObject parameter to submit a collection of strings, `Select-String` treats the collection as a single combined string. `Select-String` returns the strings as a unit if it finds the search text in any string.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>List</maml:name> <maml:Description> <maml:para>Only the first instance of matching text is returned from each input file. This is the most efficient way to retrieve a list of files that have contents matching the regular expression.</maml:para> <maml:para>By default, `Select-String` returns a MatchInfo object for each match it finds.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the path to the files to be searched. The value of the LiteralPath parameter is used exactly as it's typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences. For more information, see about_Quoting_Rules (../Microsoft.Powershell.Core/About/about_Quoting_Rules.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NotMatch</maml:name> <maml:Description> <maml:para>The NotMatch parameter finds text that doesn't match the specified pattern.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the path to the files to search. Wildcards are permitted. The default location is the local directory.</maml:para> <maml:para>Specify files in the directory, such as `log1.txt`, ` .doc`, or ` .*`. If you specify only a directory, the command fails.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Local directory</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Pattern</maml:name> <maml:Description> <maml:para>Specifies the text to find on each line. The pattern value is treated as a regular expression.</maml:para> <maml:para>To learn about regular expressions, see about_Regular_Expressions (../Microsoft.PowerShell.Core/About/about_Regular_Expressions.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Quiet</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet returns a Boolean value (True or False), instead of a MatchInfo object. The value is True if the pattern is found; otherwise the value is False.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SimpleMatch</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet uses a simple match rather than a regular expression match. In a simple match, `Select-String` searches the input for the text in the Pattern parameter. It doesn't interpret the value of the Pattern parameter as a regular expression statement.</maml:para> <maml:para>Also, when SimpleMatch is used, the Matches property of the MatchInfo object returned is empty.</maml:para> <maml:para>> [!NOTE] > When this parameter is used with the AllMatches parameter, the AllMatches is ignored.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe any object that has a ToString method to `Select-String`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.MatchInfo or System.Boolean</maml:name> </dev:type> <maml:description> <maml:para>By default, the output is a set of MatchInfo objects with one for each match found. If you use the Quiet parameter, the output is a Boolean value indicating whether the pattern was found.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>`Select-String` is similar to grep in UNIX or findstr.exe in Windows.</maml:para> <maml:para>The sls alias for the `Select-String` cmdlet was introduced in PowerShell 3.0.</maml:para> <maml:para>> [!NOTE] > According to Approved Verbs for PowerShell Commands (/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands), > the official alias prefix for `Select-*` cmdlets is `sc`, not `sl`. Therefore, the proper alias > for `Select-String` should be `scs`, not `sls`. This is an exception to this rule.</maml:para> <maml:para>To use `Select-String`, type the text that you want to find as the value of the Pattern parameter. To specify the text to be searched, use the following criteria:</maml:para> <maml:para>- Type the text in a quoted string, and then pipe it to `Select-String`.</maml:para> <maml:para>- Store a text string in a variable, and then specify the variable as the value of the InputObject parameter. - If the text is stored in files, use the Path parameter to specify the path to the files.</maml:para> <maml:para>By default, `Select-String` interprets the value of the Pattern parameter as a regular expression. For more information, see about_Regular_Expressions (../Microsoft.PowerShell.Core/About/about_Regular_Expressions.md). You can use the SimpleMatch parameter to override the regular expression matching. The SimpleMatch parameter finds instances of the value of the Pattern parameter in the input.</maml:para> <maml:para>The default output of `Select-String` is a MatchInfo object, which includes detailed information about the matches. The information in the object is useful when you're searching for text in files, because MatchInfo objects have properties such as Filename and Line . When the input isn't from the file, the value of these parameters is InputStream .</maml:para> <maml:para>If you don't need the information in the MatchInfo object, use the Quiet parameter. The Quiet parameter returns a Boolean value (True or False) to indicate whether it found a match, instead of a MatchInfo object.</maml:para> <maml:para>When matching phrases, `Select-String` uses the current culture that is set for the system. To find the current culture, use the `Get-Culture` cmdlet.</maml:para> <maml:para>To find the properties of a MatchInfo object, type the following command:</maml:para> <maml:para>`Select-String -Path test.txt -Pattern 'test' | Get-Member | Format-List -Property *`</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------ Example 1: Find a case-sensitive match ------------</maml:title> <dev:code>'Hello', 'HELLO' | Select-String -Pattern 'HELLO' -CaseSensitive -SimpleMatch</dev:code> <dev:remarks> <maml:para>The text strings Hello and HELLO are sent down the pipeline to the `Select-String` cmdlet. `Select-String` uses the Pattern parameter to specify HELLO . The CaseSensitive parameter specifies that the case must match only the upper-case pattern. SimpleMatch is an optional parameter and specifies that the string in the pattern isn't interpreted as a regular expression. `Select-String` displays HELLO in the PowerShell console.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------ Example 2: Find matches in text files ------------</maml:title> <dev:code>Get-Alias | Out-File -FilePath .\Alias.txt Get-Command | Out-File -FilePath .\Command.txt Select-String -Path .\*.txt -Pattern 'Get' Alias.txt:8:Alias cat -> Get-Content Alias.txt:28:Alias dir -> Get-ChildItem Alias.txt:43:Alias gal -> Get-Alias Command.txt:966:Cmdlet Get-Acl Command.txt:967:Cmdlet Get-Alias</dev:code> <dev:remarks> <maml:para>In this example, `Get-Alias` and `Get-Command` are used with the `Out-File` cmdlet to create two text files in the current directory, Alias.txt and Command.txt .</maml:para> <maml:para>`Select-String` uses the Path parameter with the asterisk (`*`) wildcard to search all files in the current directory with the file name extension `.txt`. The Pattern parameter specifies the text to match Get- . `Select-String` displays the output in the PowerShell console. The file name and line number precede each line of content that contains a match for the Pattern parameter.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------------- Example 3: Find a pattern match ---------------</maml:title> <dev:code>Select-String -Path "$PSHOME\en-US\*.txt" -Pattern '\?' C:\Program Files\PowerShell\6\en-US\default.help.txt:27: beginning at https://go.microsoft.com/fwlink/?LinkID=108518. C:\Program Files\PowerShell\6\en-US\default.help.txt:50: or go to: https://go.microsoft.com/fwlink/?LinkID=210614</dev:code> <dev:remarks> <maml:para>The `Select-String` cmdlet uses two parameters, Path and Pattern . The Path parameter uses the variable `$PSHOME` that specifies the PowerShell directory. The remainder of the path includes the subdirectory en-US and specifies each `*.txt` file in the directory. The Pattern parameter specifies to match a question mark (`?`) in each file. A backslash (``) is used as an escape character and is necessary because the question mark (`?`) is a regular expression quantifier. `Select-String` displays the output in the PowerShell console. The file name and line number precede each line of content that contains a match for the Pattern parameter.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 4: Use Select-String in a function ----------</maml:title> <dev:code>PS> Function Search-Help >> { >> $PSHelp = "$PSHOME\en-US\*.txt" >> Select-String -Path $PSHelp -Pattern 'About_' >> } PS> PS> Search-Help C:\Windows\System32\WindowsPowerShell\v1.0\en-US\about_ActivityCommonParameters.help.txt:2: about_ActivityCommonParameters C:\Windows\System32\WindowsPowerShell\v1.0\en-US\about_ActivityCommonParameters.help.txt:31: see about_WorkflowCommonParameters. C:\Windows\System32\WindowsPowerShell\v1.0\en-US\about_ActivityCommonParameters.help.txt:33: about_CommonParameters.</dev:code> <dev:remarks> <maml:para>The function is created on the PowerShell command line. The `Function` command uses the name Search-Help . Press Enter to begin adding statements to the function. From the `>>` prompt, add each statement and press Enter as shown in the example. After the closing bracket is added, you're returned to a PowerShell prompt.</maml:para> <maml:para>The function contains two commands. The `$PSHelp` variable stores the path to the PowerShell help files. `$PSHOME` is the PowerShell installation directory with the subdirectory en-US that specifies each `*.txt` file in the directory.</maml:para> <maml:para>The `Select-String` command in the function uses the Path and Pattern parameters. The Path parameter uses the `$PSHelp` variable to get the path. The Pattern parameter uses the string About_ as the search criteria.</maml:para> <maml:para>To run the function, type `Search-Help`. The function's `Select-String` command displays the output in the PowerShell console.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 5: Search for a string in a Windows event log ----</maml:title> <dev:code>$Events = Get-WinEvent -LogName Application -MaxEvents 50 $Events | Select-String -InputObject {$_.message} -Pattern 'Failed'</dev:code> <dev:remarks> <maml:para>The `Get-WinEvent` cmdlet uses the LogName parameter to specify the Application log. The MaxEvents parameter gets the 50 most recent events from the log. The log content is stored in the variable named `$Events`.</maml:para> <maml:para>The `$Events` variable is sent down the pipeline to the `Select-String` cmdlet. `Select-String` uses the InputObject parameter. The `$_` variable represents the current object and `message` is a property of the event. The Pattern parameter species the string Failed and searches for matches in `$_.message`. `Select-String` displays the output in the PowerShell console.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 6: Find a string in subdirectories ----------</maml:title> <dev:code>Get-ChildItem -Path C:\Windows\System32\*.txt -Recurse | Select-String -Pattern 'Microsoft' -CaseSensitive</dev:code> <dev:remarks> <maml:para>`Get-ChildItem` uses the Path parameter to specify C:\Windows\System32*.txt . The Recurse parameter includes the subdirectories. The objects are sent down the pipeline to `Select-String`.</maml:para> <maml:para>`Select-String` uses the Pattern parameter and specifies the string Microsoft . The CaseSensitive parameter is used to match the exact case of the string. `Select-String` displays the output in the PowerShell console.</maml:para> <maml:para>> [!NOTE] > Dependent upon your permissions, you might see Access denied messages in the output.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 7: Find strings that do not match a pattern -----</maml:title> <dev:code>Get-Command | Out-File -FilePath .\Command.txt Select-String -Path .\Command.txt -Pattern 'Get', 'Set' -NotMatch</dev:code> <dev:remarks> <maml:para>The `Get-Command` cmdlet sends objects down the pipeline to the `Out-File` to create the Command.txt file in the current directory. `Select-String` uses the Path parameter to specify the Command.txt file. The Pattern parameter specifies Get and Set as the search pattern. The NotMatch parameter excludes Get and Set from the results. `Select-String` displays the output in the PowerShell console that doesn't include Get or Set .</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 8: Find lines before and after a match --------</maml:title> <dev:code>Get-Command | Out-File -FilePath .\Command.txt Select-String -Path .\Command.txt -Pattern 'Get-Computer' -Context 2, 3 Command.txt:1186:Cmdlet Get-CmsMessage 3.0.0.0 Microsoft.PowerShell.Security Command.txt:1187:Cmdlet Get-Command 3.0.0.0 Microsoft.PowerShell.Core > Command.txt:1188:Cmdlet Get-ComputerInfo 3.1.0.0 Microsoft.PowerShell.Management > Command.txt:1189:Cmdlet Get-ComputerRestorePoint 3.1.0.0 Microsoft.PowerShell.Management Command.txt:1190:Cmdlet Get-Content 3.1.0.0 Microsoft.PowerShell.Management Command.txt:1191:Cmdlet Get-ControlPanelItem 3.1.0.0 Microsoft.PowerShell.Management Command.txt:1192:Cmdlet Get-Counter 3.0.0.0 Microsoft.PowerShell.Diagnostics</dev:code> <dev:remarks> <maml:para>The `Get-Command` cmdlet sends objects down the pipeline to the `Out-File` to create the Command.txt file in the current directory. `Select-String` uses the Path parameter to specify the Command.txt file. The Pattern parameter specifies Get-Computer as the search pattern. The Context parameter uses two values, before and after, and marks pattern matches in the output with an angle bracket (`>`). The Context parameter outputs the two lines before the first pattern match and three lines after the last pattern match.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------- Example 9: Find all pattern matches -------------</maml:title> <dev:code>PS> $A = Get-ChildItem -Path "$PSHOME\en-US\*.txt" | Select-String -Pattern 'PowerShell' PS> $A C:\Windows\System32\WindowsPowerShell\v1.0\en-US\about_ActivityCommonParameters.help.txt:5: Describes the parameters that Windows PowerShell C:\Windows\System32\WindowsPowerShell\v1.0\en-US\about_ActivityCommonParameters.help.txt:9: Windows PowerShell Workflow adds the activity common PS> $A.Matches Groups : {0} Success : True Name : 0 Captures : {0} Index : 4 Length : 10 Value : PowerShell PS> $A.Matches.Length 2073 PS> $B = Get-ChildItem -Path "$PSHOME\en-US\*.txt" | Select-String -Pattern 'PowerShell' -AllMatches PS> $B.Matches.Length 2200</dev:code> <dev:remarks> <maml:para>The `Get-ChildItem` cmdlet uses the Path parameter. The Path parameter uses the variable `$PSHOME` that specifies the PowerShell directory. The remainder of the path includes the subdirectory en-US and specifies each `*.txt` file in the directory. The `Get-ChildItem` objects are stored in the `$A` variable. The `$A` variable is sent down the pipeline to the `Select-String` cmdlet. `Select-String` uses the Pattern parameter to search each file for the string PowerShell .</maml:para> <maml:para>From the PowerShell command line, the `$A` variable contents are displayed. There's a line that contains two occurrences of the string PowerShell .</maml:para> <maml:para>The `$A.Matches` property lists the first occurrence of the pattern PowerShell on each line.</maml:para> <maml:para>The `$A.Matches.Length` property counts the first occurrence of the pattern PowerShell on each line.</maml:para> <maml:para>The `$B` variable uses the same `Get-ChildItem` and `Select-String` cmdlets, but adds the AllMatches parameter. AllMatches finds each occurrence of the pattern PowerShell on each line. The objects stored in the `$A` and `$B` variables are identical.</maml:para> <maml:para>The `$B.Matches.Length` property increases because for each line, every occurrence of the pattern PowerShell is counted.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/select-string?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Automatic_Variables</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Comparison_Operators</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Functions</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Quoting_Rules</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Regular_Expressions</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-ChildItem</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Command</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Member</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-WinEvent</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-File</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Select-Xml</command:name> <command:verb>Select</command:verb> <command:noun>Xml</command:noun> <maml:description> <maml:para>Finds text in an XML string or document.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Select-Xml cmdlet lets you use XPath queries to search for text in XML strings and documents. Enter an XPath query, and use the Content , Path , or Xml parameter to specify the XML to be searched.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Select-Xml</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>XPath</maml:name> <maml:Description> <maml:para>Specifies an XPath search query. The query language is case-sensitive. This parameter is required.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>Content</maml:name> <maml:Description> <maml:para>Specifies a string that contains the XML to search. You can also pipe strings to Select-Xml .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Namespace</maml:name> <maml:Description> <maml:para>Specifies a hash table of the namespaces used in the XML. Use the format @{<namespaceName> = <namespaceValue>}.</maml:para> <maml:para>When the XML uses the default namespace, which begins with xmlns, use an arbitrary key for the namespace name. You cannot use xmlns. In the XPath statement, prefix each node name with the namespace name and a colon, such as //namespaceName:Node.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Collections.Hashtable</command:parameterValue> <dev:type> <maml:name>System.Collections.Hashtable</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Select-Xml</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>XPath</maml:name> <maml:Description> <maml:para>Specifies an XPath search query. The query language is case-sensitive. This parameter is required.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the paths and file names of the XML files to search. Unlike Path , the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Namespace</maml:name> <maml:Description> <maml:para>Specifies a hash table of the namespaces used in the XML. Use the format @{<namespaceName> = <namespaceValue>}.</maml:para> <maml:para>When the XML uses the default namespace, which begins with xmlns, use an arbitrary key for the namespace name. You cannot use xmlns. In the XPath statement, prefix each node name with the namespace name and a colon, such as //namespaceName:Node.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Collections.Hashtable</command:parameterValue> <dev:type> <maml:name>System.Collections.Hashtable</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Select-Xml</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>XPath</maml:name> <maml:Description> <maml:para>Specifies an XPath search query. The query language is case-sensitive. This parameter is required.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the path and file names of the XML files to search. Wildcard characters are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Namespace</maml:name> <maml:Description> <maml:para>Specifies a hash table of the namespaces used in the XML. Use the format @{<namespaceName> = <namespaceValue>}.</maml:para> <maml:para>When the XML uses the default namespace, which begins with xmlns, use an arbitrary key for the namespace name. You cannot use xmlns. In the XPath statement, prefix each node name with the namespace name and a colon, such as //namespaceName:Node.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Collections.Hashtable</command:parameterValue> <dev:type> <maml:name>System.Collections.Hashtable</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Select-Xml</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>XPath</maml:name> <maml:Description> <maml:para>Specifies an XPath search query. The query language is case-sensitive. This parameter is required.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="1" aliases="Node"> <maml:name>Xml</maml:name> <maml:Description> <maml:para>Specifies one or more XML nodes.</maml:para> <maml:para>An XML document will be processed as a collection of XML nodes. If you pipe an XML document to Select-Xml , each document node will be searched separately as it comes through the pipeline.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Xml.XmlNode[]</command:parameterValue> <dev:type> <maml:name>System.Xml.XmlNode[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Namespace</maml:name> <maml:Description> <maml:para>Specifies a hash table of the namespaces used in the XML. Use the format @{<namespaceName> = <namespaceValue>}.</maml:para> <maml:para>When the XML uses the default namespace, which begins with xmlns, use an arbitrary key for the namespace name. You cannot use xmlns. In the XPath statement, prefix each node name with the namespace name and a colon, such as //namespaceName:Node.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Collections.Hashtable</command:parameterValue> <dev:type> <maml:name>System.Collections.Hashtable</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>Content</maml:name> <maml:Description> <maml:para>Specifies a string that contains the XML to search. You can also pipe strings to Select-Xml .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the paths and file names of the XML files to search. Unlike Path , the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Namespace</maml:name> <maml:Description> <maml:para>Specifies a hash table of the namespaces used in the XML. Use the format @{<namespaceName> = <namespaceValue>}.</maml:para> <maml:para>When the XML uses the default namespace, which begins with xmlns, use an arbitrary key for the namespace name. You cannot use xmlns. In the XPath statement, prefix each node name with the namespace name and a colon, such as //namespaceName:Node.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Collections.Hashtable</command:parameterValue> <dev:type> <maml:name>System.Collections.Hashtable</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the path and file names of the XML files to search. Wildcard characters are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="1" aliases="Node"> <maml:name>Xml</maml:name> <maml:Description> <maml:para>Specifies one or more XML nodes.</maml:para> <maml:para>An XML document will be processed as a collection of XML nodes. If you pipe an XML document to Select-Xml , each document node will be searched separately as it comes through the pipeline.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Xml.XmlNode[]</command:parameterValue> <dev:type> <maml:name>System.Xml.XmlNode[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>XPath</maml:name> <maml:Description> <maml:para>Specifies an XPath search query. The query language is case-sensitive. This parameter is required.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String or System.Xml.XmlNode</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a path or XML node to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.SelectXmlInfo</maml:name> </dev:type> <maml:description> <maml:para></maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>* XPath is a standard language that is designed to identify parts of an XML document. For more information about the XPath language, see XPath Reference (https://msdn.microsoft.com/library/ms256115) and the Selection Filters section of the [Event Selection](https://msdn.microsoft.com/library/aa385231)in the MSDN library.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------ Example 1: Select AliasProperty nodes ------------</maml:title> <dev:code>PS C:\> $Path = "$Pshome\Types.ps1xml" PS C:\> $XPath = "/Types/Type/Members/AliasProperty" PS C:\> Select-Xml -Path $Path -XPath $Xpath | Select-Object -ExpandProperty Node Name ReferencedMemberName ---- -------------------- Count Length Name Key Name ServiceName RequiredServices ServicesDependedOn ProcessName Name Handles Handlecount VM VirtualSize WS WorkingSetSize Name ProcessName Handles Handlecount VM VirtualMemorySize WS WorkingSet PM PagedMemorySize NPM NonpagedSystemMemorySize Name __Class Namespace ModuleName</dev:code> <dev:remarks> <maml:para>This example gets the alias properties in the Types.ps1xml. (For information about this file, see about_Types.ps1xml.)</maml:para> <maml:para>The first command saves the path to the Types.ps1xml file in the $Path variable.</maml:para> <maml:para>The second command saves the XML path to the AliasProperty node in the $XPath variable.</maml:para> <maml:para>The third command uses the Select-Xml cmdlet to get the AliasProperty nodes that are identified by the XPath statement from the Types.ps1xml file. The command uses a pipeline operator to send the AliasProperty nodes to the Select-Object cmdlet. The ExpandProperty parameter expands the Node object and returns its Name and ReferencedMemberName properties.</maml:para> <maml:para>The result shows the Name and ReferencedMemberName of each alias property in the Types.ps1xml file. For example, there is a Count property that is an alias of the Length property.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------------- Example 2: Input an XML document ---------------</maml:title> <dev:code>PS C:\> [xml]$Types = Get-Content $Pshome\Types.ps1xml PS C:\> Select-Xml -Xml $Types -XPath "//MethodName"</dev:code> <dev:remarks> <maml:para>This example shows how to use the XML parameter to provide an XML document to the Select-Xml cmdlet.</maml:para> <maml:para>The first command uses the Get-Content cmdlet to get the content of the Types.ps1xml file and save it in the $Types variable. The [xml] casts the variable as an XML object.</maml:para> <maml:para>The second command uses the Select-Xml cmdlet to get the MethodName nodes in the Types.ps1xml file. The command uses the Xml parameter to specify the XML content in the $Types variable and the XPath parameter to specify the path to the MethodName node.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 3: Search PowerShell Help files -----------</maml:title> <dev:code>PS C:\> $Namespace = @{command = "http://schemas.microsoft.com/maml/dev/command/2004/10"; maml = "http://schemas.microsoft.com/maml/2004/10"; dev = "http://schemas.microsoft.com/maml/dev/2004/10"} The second command saves the path to the help files in the $Path variable.If there are no help files in this path on your computer, use the Update-Help cmdlet to download the help files. For more information about Updatable Help, see about_Updatable_Help (https://go.microsoft.com/fwlink/?LinkId=235801). PS C:\> $Path = "$Pshome\en-us\*dll-Help.xml" The third command uses the **Select-Xml** cmdlet to search the XML for cmdlet names by finding Command:Name element anywhere in the files. It saves the results in the $Xml variable.**Select-Xml** returns a **SelectXmlInfo** object that has a Node property, which is a **System.Xml.XmlElement** object. The Node property has an InnerXML property, which contains the actual XML that is retrieved. PS C:\> $Xml = Select-Xml -Path $Path -Namespace $Namespace -XPath "//command:name" The fourth command sends the XML in the $Xml variable to the Format-Table cmdlet. The **Format-Table** command uses a calculated property to get the Node.InnerXML property of each object in the $Xml variable, trim the white space before and after the text, and display it in the table, along with the path to the source file. PS C:\> $Xml | Format-Table @{Label="Name"; Expression= {($_.node.innerxml).trim()}}, Path -AutoSize Name Path ---- ---- Export-Counter C:\Windows\system32\WindowsPowerShell\v1.0\en-us\Microsoft.PowerShell.Commands.Diagnostics.dll-Help.xml Get-Counter C:\Windows\system32\WindowsPowerShell\v1.0\en-us\Microsoft.PowerShell.Commands.Diagnostics.dll-Help.xml Get-WinEvent C:\Windows\system32\WindowsPowerShell\v1.0\en-us\Microsoft.PowerShell.Commands.Diagnostics.dll-Help.xml Import-Counter C:\Windows\system32\WindowsPowerShell\v1.0\en-us\Microsoft.PowerShell.Commands.Diagnostics.dll-Help.xml Add-Computer C:\Windows\system32\WindowsPowerShell\v1.0\en-us\Microsoft.PowerShell.Commands.Management.dll-Help.xml Add-Content C:\Windows\system32\WindowsPowerShell\v1.0\en-us\Microsoft.PowerShell.Commands.Management.dll-Help.xml Checkpoint-Computer C:\Windows\system32\WindowsPowerShell\v1.0\en-us\Microsoft.PowerShell.Commands.Management.dll-Help.xml ...</dev:code> <dev:remarks> <maml:para>This example shows how to use the Select-Xml cmdlet to search the PowerShell XML-based cmdlet help files. In this example, we'll search for the cmdlet name that serves as a title for each help file and the path to the help file.</maml:para> <maml:para>The first command creates a hash table that represents the XML namespace that is used for the help files and saves it in the $Namespace variable.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------ Example 4: Different ways to input XML ------------</maml:title> <dev:code>PS C:\> $Xml = @" <?xml version="1.0" encoding="utf-8"?> <Book> <projects> <project name="Book1" date="2009-01-20"> <editions> <edition language="English">En.Book1.com</edition> <edition language="German">Ge.Book1.Com</edition> <edition language="French">Fr.Book1.com</edition> <edition language="Polish">Pl.Book1.com</edition> </editions> </project> </projects> </Book> "@ The second command uses the *Content* parameter of **Select-Xml** to specify the XML in the $Xml variable. PS C:\> Select-Xml -Content $Xml -XPath "//edition" | foreach {$_.node.InnerXML} En.Book1.com Ge.Book1.Com Fr.Book1.com Pl.Book1.com The third command is equivalent to the second. It uses a pipeline operator (|) to send the XML in the $Xml variable to the **Select-Xml** cmdlet. PS C:\> $Xml | Select-Xml -XPath "//edition" | foreach {$_.node.InnerXML} En.Book1.com Ge.Book1.Com Fr.Book1.com Pl.Book1.com</dev:code> <dev:remarks> <maml:para>This example shows two different ways to send XML to the Select-Xml cmdlet.</maml:para> <maml:para>The first command saves a here-string that contains XML in the $Xml variable. (For more information about here-strings, see about_Quoting_Rules.)</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 5: Use the default xmlns namespace ----------</maml:title> <dev:code>PS C:\> $SnippetNamespace = @{snip = "http://schemas.microsoft.com/PowerShell/Snippets"} The second command uses the **Select-Xml** cmdlet to get the content of the Title element of each snippet. It uses the *Path* parameter to specify the Snippets directory and the *Namespace* parameter to specify the namespace in the $SnippetNamespace variable. The value of the *XPath* parameter is the "snip" namespace key, a colon (:), and the name of the Title element.The command uses a pipeline operator (|) to send each **Node** property that **Select-Xml** returns to the ForEach-Object cmdlet, which gets the title in the value of the **InnerXml** property of the node. PS C:\> Select-Xml -Path $Home\Documents\WindowsPowerShell\Snippets -Namespace $SnippetNamespace -XPath "//snip:Title" | foreach {$_.Node.Innerxml}</dev:code> <dev:remarks> <maml:para>This example shows how to use the Select-Xml cmdlet with XML documents that use the default xmlns namespace. The example gets the titles of Windows PowerShell ISE user-created snippet files. For information about snippets, see New-IseSnippet.</maml:para> <maml:para>The first command creates a hash table for the default namespace that snippet XML files use and assigns it to the $SnippetNamespace variable. The hash table value is the XMLNS schema URI in the snippet XML. The hash table key name, snip, is arbitrary. You can use any name that is not reserved, but you cannot use xmlns.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/select-xml?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-Xml</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Send-MailMessage</command:name> <command:verb>Send</command:verb> <command:noun>MailMessage</command:noun> <maml:description> <maml:para>Sends an email message.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Send-MailMessage` cmdlet sends an email message from within PowerShell.</maml:para> <maml:para>You must specify a Simple Mail Transfer Protocol (SMTP) server or the `Send-MailMessage` command fails. Use the SmtpServer parameter or set the `$PSEmailServer` variable to a valid SMTP server. The value assigned to `$PSEmailServer` is the default SMTP setting for PowerShell. For more information, see about_Preference_Variables (../Microsoft.PowerShell.Core/About/about_Preference_Variables.md).</maml:para> <maml:para>> [!WARNING] > The `Send-MailMessage` cmdlet is obsolete. This cmdlet does not guarantee secure connections to > SMTP servers. While there is no immediate replacement available in PowerShell, we recommend you do > not use `Send-MailMessage`. For more information, see > Platform Compatibility note DE0005 (https://aka.ms/SendMailMessage).</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Send-MailMessage</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>To</maml:name> <maml:Description> <maml:para>The To parameter is required. This parameter specifies the recipient's email address. If there are multiple recipients, separate their addresses with a comma (`,`). Enter names (optional) and the email address, such as `Name <someone@fabrikam.com>`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="sub"> <maml:name>Subject</maml:name> <maml:Description> <maml:para>The Subject parameter is required. This parameter specifies the subject of the email message.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none"> <maml:name>Body</maml:name> <maml:Description> <maml:para>Specifies the content of the email message.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="3" aliases="ComputerName"> <maml:name>SmtpServer</maml:name> <maml:Description> <maml:para>Specifies the name of the SMTP server that sends the email message.</maml:para> <maml:para>The default value is the value of the `$PSEmailServer` preference variable. If the preference variable is not set and this parameter is not used, the `Send-MailMessage` command fails.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>$PSEmailServer</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="PsPath"> <maml:name>Attachments</maml:name> <maml:Description> <maml:para>Specifies the path and file names of files to be attached to the email message. You can use this parameter or pipe the paths and file names to `Send-MailMessage`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Bcc</maml:name> <maml:Description> <maml:para>Specifies the email addresses that receive a copy of the mail but are not listed as recipients of the message. Enter names (optional) and the email address, such as `Name <someone@fabrikam.com>`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="BAH"> <maml:name>BodyAsHtml</maml:name> <maml:Description> <maml:para>Specifies that the value of the Body parameter contains HTML.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Cc</maml:name> <maml:Description> <maml:para>Specifies the email addresses to which a carbon copy (CC) of the email message is sent. Enter names (optional) and the email address, such as `Name <someone@fabrikam.com>`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Credential</maml:name> <maml:Description> <maml:para>Specifies a user account that has permission to perform this action. The default is the current user.</maml:para> <maml:para>Type a user name, such as User01 or Domain01\User01 . Or, enter a PSCredential object, such as one from the `Get-Credential` cmdlet.</maml:para> <maml:para>Credentials are stored in a PSCredential (/dotnet/api/system.management.automation.pscredential)object and the password is stored as a SecureString (/dotnet/api/system.security.securestring).</maml:para> <maml:para>> [!NOTE] > For more information about SecureString data protection, see > How secure is SecureString? (/dotnet/api/system.security.securestring#how-secure-is-securestring).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSCredential</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSCredential</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Current user</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="DNO"> <maml:name>DeliveryNotificationOption</maml:name> <maml:Description> <maml:para>Specifies the delivery notification options for the email message. You can specify multiple values. None is the default value. The alias for this parameter is DNO .</maml:para> <maml:para>The delivery notifications are sent to the address in the From parameter.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `None`: No notification.</maml:para> <maml:para>- `OnSuccess`: Notify if the delivery is successful.</maml:para> <maml:para>- `OnFailure`: Notify if the delivery is unsuccessful.</maml:para> <maml:para>- `Delay`: Notify if the delivery is delayed.</maml:para> <maml:para>- `Never`: Never notify.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">None</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OnSuccess</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OnFailure</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Delay</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Never</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Net.Mail.DeliveryNotificationOptions</command:parameterValue> <dev:type> <maml:name>System.Net.Mail.DeliveryNotificationOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="BE"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is `Default`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ASCII` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `BigEndianUnicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `Default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `OEM` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `Unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `UTF7` Uses UTF-7.</maml:para> <maml:para>- `UTF8` Uses UTF-8.</maml:para> <maml:para>- `UTF32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">ASCII</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">BigEndianUnicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Default</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OEM</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unicode</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF7</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF8</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">UTF32</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Text.Encoding</command:parameterValue> <dev:type> <maml:name>System.Text.Encoding</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Default</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>From</maml:name> <maml:Description> <maml:para>The From parameter is required. This parameter specifies the sender's email address. Enter a name (optional) and email address, such as `Name <someone@fabrikam.com>`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Port</maml:name> <maml:Description> <maml:para>Specifies an alternate port on the SMTP server. The default value is 25, which is the default SMTP port.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>25</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Priority</maml:name> <maml:Description> <maml:para>Specifies the priority of the email message. Normal is the default. The acceptable values for this parameter are Normal, High, and Low.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Normal</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">High</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Low</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Net.Mail.MailPriority</command:parameterValue> <dev:type> <maml:name>System.Net.Mail.MailPriority</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Normal</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseSsl</maml:name> <maml:Description> <maml:para>The Secure Sockets Layer (SSL) protocol is used to establish a secure connection to the remote computer to send mail. By default, SSL is not used.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="PsPath"> <maml:name>Attachments</maml:name> <maml:Description> <maml:para>Specifies the path and file names of files to be attached to the email message. You can use this parameter or pipe the paths and file names to `Send-MailMessage`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Bcc</maml:name> <maml:Description> <maml:para>Specifies the email addresses that receive a copy of the mail but are not listed as recipients of the message. Enter names (optional) and the email address, such as `Name <someone@fabrikam.com>`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none"> <maml:name>Body</maml:name> <maml:Description> <maml:para>Specifies the content of the email message.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="BAH"> <maml:name>BodyAsHtml</maml:name> <maml:Description> <maml:para>Specifies that the value of the Body parameter contains HTML.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Cc</maml:name> <maml:Description> <maml:para>Specifies the email addresses to which a carbon copy (CC) of the email message is sent. Enter names (optional) and the email address, such as `Name <someone@fabrikam.com>`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Credential</maml:name> <maml:Description> <maml:para>Specifies a user account that has permission to perform this action. The default is the current user.</maml:para> <maml:para>Type a user name, such as User01 or Domain01\User01 . Or, enter a PSCredential object, such as one from the `Get-Credential` cmdlet.</maml:para> <maml:para>Credentials are stored in a PSCredential (/dotnet/api/system.management.automation.pscredential)object and the password is stored as a SecureString (/dotnet/api/system.security.securestring).</maml:para> <maml:para>> [!NOTE] > For more information about SecureString data protection, see > How secure is SecureString? (/dotnet/api/system.security.securestring#how-secure-is-securestring).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSCredential</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSCredential</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Current user</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="DNO"> <maml:name>DeliveryNotificationOption</maml:name> <maml:Description> <maml:para>Specifies the delivery notification options for the email message. You can specify multiple values. None is the default value. The alias for this parameter is DNO .</maml:para> <maml:para>The delivery notifications are sent to the address in the From parameter.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `None`: No notification.</maml:para> <maml:para>- `OnSuccess`: Notify if the delivery is successful.</maml:para> <maml:para>- `OnFailure`: Notify if the delivery is unsuccessful.</maml:para> <maml:para>- `Delay`: Notify if the delivery is delayed.</maml:para> <maml:para>- `Never`: Never notify.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Net.Mail.DeliveryNotificationOptions</command:parameterValue> <dev:type> <maml:name>System.Net.Mail.DeliveryNotificationOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="BE"> <maml:name>Encoding</maml:name> <maml:Description> <maml:para>Specifies the type of encoding for the target file. The default value is `Default`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- `ASCII` Uses ASCII (7-bit) character set.</maml:para> <maml:para>- `BigEndianUnicode` Uses UTF-16 with the big-endian byte order.</maml:para> <maml:para>- `Default` Uses the encoding that corresponds to the system's active code page (usually ANSI).</maml:para> <maml:para>- `OEM` Uses the encoding that corresponds to the system's current OEM code page.</maml:para> <maml:para>- `Unicode` Uses UTF-16 with the little-endian byte order.</maml:para> <maml:para>- `UTF7` Uses UTF-7.</maml:para> <maml:para>- `UTF8` Uses UTF-8.</maml:para> <maml:para>- `UTF32` Uses UTF-32 with the little-endian byte order.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Text.Encoding</command:parameterValue> <dev:type> <maml:name>System.Text.Encoding</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Default</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>From</maml:name> <maml:Description> <maml:para>The From parameter is required. This parameter specifies the sender's email address. Enter a name (optional) and email address, such as `Name <someone@fabrikam.com>`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Port</maml:name> <maml:Description> <maml:para>Specifies an alternate port on the SMTP server. The default value is 25, which is the default SMTP port.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>25</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Priority</maml:name> <maml:Description> <maml:para>Specifies the priority of the email message. Normal is the default. The acceptable values for this parameter are Normal, High, and Low.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Net.Mail.MailPriority</command:parameterValue> <dev:type> <maml:name>System.Net.Mail.MailPriority</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Normal</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="3" aliases="ComputerName"> <maml:name>SmtpServer</maml:name> <maml:Description> <maml:para>Specifies the name of the SMTP server that sends the email message.</maml:para> <maml:para>The default value is the value of the `$PSEmailServer` preference variable. If the preference variable is not set and this parameter is not used, the `Send-MailMessage` command fails.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>$PSEmailServer</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="sub"> <maml:name>Subject</maml:name> <maml:Description> <maml:para>The Subject parameter is required. This parameter specifies the subject of the email message.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>To</maml:name> <maml:Description> <maml:para>The To parameter is required. This parameter specifies the recipient's email address. If there are multiple recipients, separate their addresses with a comma (`,`). Enter names (optional) and the email address, such as `Name <someone@fabrikam.com>`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>UseSsl</maml:name> <maml:Description> <maml:para>The Secure Sockets Layer (SSL) protocol is used to establish a secure connection to the remote computer to send mail. By default, SSL is not used.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe the path and file names of attachments to `Send-MailMessage`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>This cmdlet does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-- Example 1: Send an email from one person to another person --</maml:title> <dev:code>Send-MailMessage -From 'User01 <user01@fabrikam.com>' -To 'User02 <user02@fabrikam.com>' -Subject 'Test mail'</dev:code> <dev:remarks> <maml:para>The `Send-MailMessage` cmdlet uses the From parameter to specify the message's sender. The To parameter specifies the message's recipient. The Subject parameter uses the text string Test mail as the message because the optional Body parameter is not included.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------------- Example 2: Send an attachment ----------------</maml:title> <dev:code>Send-MailMessage -From 'User01 <user01@fabrikam.com>' -To 'User02 <user02@fabrikam.com>', 'User03 <user03@fabrikam.com>' -Subject 'Sending the Attachment' -Body "Forgot to send the attachment. Sending now." -Attachments .\data.csv -Priority High -DeliveryNotificationOption OnSuccess, OnFailure -SmtpServer 'smtp.fabrikam.com'</dev:code> <dev:remarks> <maml:para>The `Send-MailMessage` cmdlet uses the From parameter to specify the message's sender. The To parameter specifies the message's recipients. The Subject parameter describes the content of the message. The Body parameter is the content of the message.</maml:para> <maml:para>The Attachments parameter specifies the file in the current directory that is attached to the email message. The Priority parameter sets the message to High priority. The -DeliveryNotificationOption parameter specifies two values, OnSuccess and OnFailure . The sender will receive email notifications to confirm the success or failure of the message delivery. The SmtpServer parameter sets the SMTP server to smtp.fabrikam.com .</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 3: Send email to a mailing list -----------</maml:title> <dev:code>Send-MailMessage -From 'User01 <user01@fabrikam.com>' -To 'ITGroup <itdept@fabrikam.com>' -Cc 'User02 <user02@fabrikam.com>' -Bcc 'ITMgr <itmgr@fabrikam.com>' -Subject "Don't forget today's meeting!" -Credential domain01\admin01 -UseSsl</dev:code> <dev:remarks> <maml:para>The `Send-MailMessage` cmdlet uses the From parameter to specify the message's sender. The To parameter specifies the message's recipients. The Cc parameter sends a copy of the message to the specified recipient. The Bcc parameter sends a blind copy of the message. A blind copy is an email address that is hidden from the other recipients. The Subject parameter is the message because the optional Body parameter is not included.</maml:para> <maml:para>The Credential parameter specifies a domain administrator's credentials are used to send the message. The UseSsl parameter specifies that Secure Socket Layer (SSL) creates a secure connection.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/send-mailmessage?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Preference_Variables</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Credential</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Set-Alias</command:name> <command:verb>Set</command:verb> <command:noun>Alias</command:noun> <maml:description> <maml:para>Creates or changes an alias for a cmdlet or other command in the current PowerShell session.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Set-Alias` cmdlet creates or changes an alias for a cmdlet or a command, such as a function, script, file, or other executable. An alias is an alternate name that refers to a cmdlet or command. For example, `sal` is the alias for the `Set-Alias` cmdlet. For more information, see about_Aliases (../Microsoft.PowerShell.Core/About/about_Aliases.md).</maml:para> <maml:para>A cmdlet can have multiple aliases, but an alias can only be associated with one cmdlet. You can use `Set-Alias` to reassign an existing alias to another cmdlet, or change an alias's properties, such as the description.</maml:para> <maml:para>An alias that is created or changed by `Set-Alias` is not permanent and is only available during the current PowerShell session. When the PowerShell session is closed, the alias is removed.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Set-Alias</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the name of a new alias. An alias name can contain alphanumeric characters and hyphens. Alias names cannot be numeric, such as 123.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> <maml:name>Value</maml:name> <maml:Description> <maml:para>Specifies the name of the cmdlet or command that the alias runs. The Value parameter is the alias's Definition property.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Description</maml:name> <maml:Description> <maml:para>Specifies a description of the alias. You can type any string. If the description includes spaces, enclose it single quotation marks.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Use the Force parameter to change or delete an alias that has the Option parameter set to ReadOnly .</maml:para> <maml:para>The Force parameter cannot change or delete an alias with the Option parameter set to Constant .</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Option</maml:name> <maml:Description> <maml:para>Sets the Option property value of the alias. Values such as ReadOnly and Constant protect an alias from unintended changes. To see the Option property of all aliases in the session, type `Get-Alias | Format-Table -Property Name, Options -Autosize`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- AllScope The alias is copied to any new scopes that are created. - Constant Cannot be changed or deleted. - None Sets no options and is the default. - Private The alias is available only in the current scope. - ReadOnly Cannot be changed or deleted unless the Force parameter is used. - Unspecified</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">AllScope</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Constant</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">None</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Private</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ReadOnly</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unspecified</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScopedItemOptions</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScopedItemOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object that represents the alias. Use a format cmdlet such as `Format-List` to display the object. By default, `Set-Alias` does not generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope in which this alias is valid. The default value is Local . For more information, see about_Scopes (../Microsoft.PowerShell.Core/About/about_Scopes.md).</maml:para> <maml:para>The acceptable values are as follows:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Private</maml:para> <maml:para>- Numbered scopes</maml:para> <maml:para>- Script</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Global</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Local</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Private</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Numbered scopes</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Script</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Local</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Description</maml:name> <maml:Description> <maml:para>Specifies a description of the alias. You can type any string. If the description includes spaces, enclose it single quotation marks.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Use the Force parameter to change or delete an alias that has the Option parameter set to ReadOnly .</maml:para> <maml:para>The Force parameter cannot change or delete an alias with the Option parameter set to Constant .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the name of a new alias. An alias name can contain alphanumeric characters and hyphens. Alias names cannot be numeric, such as 123.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Option</maml:name> <maml:Description> <maml:para>Sets the Option property value of the alias. Values such as ReadOnly and Constant protect an alias from unintended changes. To see the Option property of all aliases in the session, type `Get-Alias | Format-Table -Property Name, Options -Autosize`.</maml:para> <maml:para>The acceptable values for this parameter are as follows:</maml:para> <maml:para>- AllScope The alias is copied to any new scopes that are created. - Constant Cannot be changed or deleted. - None Sets no options and is the default. - Private The alias is available only in the current scope. - ReadOnly Cannot be changed or deleted unless the Force parameter is used. - Unspecified</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScopedItemOptions</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScopedItemOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object that represents the alias. Use a format cmdlet such as `Format-List` to display the object. By default, `Set-Alias` does not generate any output.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope in which this alias is valid. The default value is Local . For more information, see about_Scopes (../Microsoft.PowerShell.Core/About/about_Scopes.md).</maml:para> <maml:para>The acceptable values are as follows:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Private</maml:para> <maml:para>- Numbered scopes</maml:para> <maml:para>- Script</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Local</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> <maml:name>Value</maml:name> <maml:Description> <maml:para>Specifies the name of the cmdlet or command that the alias runs. The Value parameter is the alias's Definition property.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>`Set-Alias` does not accept input from the pipeline.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None or System.Management.Automation.AliasInfo</maml:name> </dev:type> <maml:description> <maml:para>When you use the PassThru parameter, `Set-Alias` generates a System.Management.Automation.AliasInfo object representing the alias. Otherwise, `Set-Alias` does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>PowerShell includes built-in aliases that are available in each PowerShell session. The `Get-Alias` cmdlet displays the aliases available in a PowerShell session.</maml:para> <maml:para>To create a new alias, use `Set-Alias` or `New-Alias`. To remove an alias use the `Remove-Item` cmdlet. For example, `Remove-Item -Path Alias:aliasname`.</maml:para> <maml:para>To create an alias that is available in each PowerShell session, add it to your PowerShell profile. For more information, see about_Profiles (../Microsoft.PowerShell.Core/About/about_Profiles.md).</maml:para> <maml:para>An alias can be saved and reused in another PowerShell session by doing an export and import. To save an alias to a file, use `Export-Alias`. To add a saved alias to a new PowerShell session, use `Import-Alias`.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>----------- Example 1: Create an alias for a cmdlet -----------</maml:title> <dev:code>PS> Set-Alias -Name list -Value Get-ChildItem PS> Get-Alias -Name list CommandType Name ----------- ---- Alias list -> Get-ChildItem</dev:code> <dev:remarks> <maml:para>The `Set-Alias` cmdlet creates an alias in the current PowerShell session. The Name parameter specifies the alias's name, `list`. The Value parameter specifies the cmdlet that the alias runs.</maml:para> <maml:para>To run the alias, type `list` on the PowerShell command line.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>- Example 2: Reassign an existing alias to a different cmdlet -</maml:title> <dev:code>PS> Get-Alias -Name list CommandType Name ----------- ---- Alias list -> Get-ChildItem PS> Set-Alias -Name list -Value Get-Location PS> Get-Alias -Name list CommandType Name ----------- ---- Alias list -> Get-Location</dev:code> <dev:remarks> <maml:para>The `Get-Alias` cmdlet uses the Name parameter to display the `list` alias. The `list` alias is associated with the `Get-ChildItem` cmdlet. When the `list` alias is run, the items in the current directory are displayed.</maml:para> <maml:para>The `Set-Alias` cmdlet uses the Name parameter to specify the `list` alias. The Value parameter associates the alias to the `Get-Location` cmdlet.</maml:para> <maml:para>The `Get-Alias` cmdlet uses the Name parameter to display the `list` alias. The `list` alias is associated with the `Get-Location` cmdlet. When the `list` alias is run, the current directory's location is displayed.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 3: Create and change a read-only alias --------</maml:title> <dev:code>PS> Set-Alias -Name loc -Value Get-Location -Option ReadOnly -PassThru | Format-List -Property * DisplayName : loc -> Get-Location Definition : Get-Location Options : ReadOnly Description : Name : loc CommandType : Alias PS> Set-Alias -Name loc -Value Get-Location -Option ReadOnly -Description 'Displays the current directory' -Force -PassThru | Format-List -Property * DisplayName : loc -> Get-Location Definition : Get-Location Options : ReadOnly Description : Displays the current directory Name : loc CommandType : Alias</dev:code> <dev:remarks> <maml:para>The `Set-Alias` cmdlet creates an alias in the current PowerShell session. The Name parameter specifies the alias's name, `loc`. The Value parameter specifies the `Get-Location` cmdlet that the alias runs. The Option parameter specifies the ReadOnly value. The PassThru parameter represents the alias object and sends the object down the pipeline to the `Format-List` cmdlet. `Format-List` uses the Property parameter with an asterisk (`*`) so that all of the properties are displayed. The example output shows a partial list of those properties.</maml:para> <maml:para>The `loc` alias is changed with the addition of two parameters. Description adds text to explain the alias's purpose. The Force parameter is needed because the `loc` alias is read-only. If the Force parameter is not used, the change fails.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 4: Create an alias to an executable file -------</maml:title> <dev:code>PS> Set-Alias -Name np -Value C:\Windows\notepad.exe PS> Get-Alias -Name np CommandType Name ----------- ---- Alias np -> notepad.exe</dev:code> <dev:remarks> <maml:para>The `Set-Alias` cmdlet creates an alias in the current PowerShell session. The Name parameter specifies the alias's name, `np`. The Value parameter specifies the path and application name C:\Windows\notepad.exe . The `Get-Alias` cmdlet uses the Name parameter to show that the `np` alias is associated with notepad.exe .</maml:para> <maml:para>To run the alias, type `np` on the PowerShell command line to open notepad.exe .</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--- Example 5: Create an alias for a command with parameters ---</maml:title> <dev:code>PS> Function CD32 {Set-Location -Path C:\Windows\System32} PS> Set-Alias -Name Go -Value CD32</dev:code> <dev:remarks> <maml:para>A function named `CD32` is created. The function uses the `Set-Location` cmdlet with the Path parameter to specify the directory, C:\Windows\System32 .</maml:para> <maml:para>The `Set-Alias` cmdlet creates an alias to the function in the current PowerShell session. The Name parameter specifies the alias's name, `Go`. The Value parameter specifies the function's name, `CD32`.</maml:para> <maml:para>To run the alias, type `Go` on the PowerShell command line. The `CD32` function runs and changes to the directory C:\Windows\System32 .</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/set-alias?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Aliases</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Functions</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Profiles</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Scopes</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Export-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Import-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Alias</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-Item</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Set-Date</command:name> <command:verb>Set</command:verb> <command:noun>Date</command:noun> <maml:description> <maml:para>Changes the system time on the computer to a time that you specify.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Set-Date` cmdlet changes the system date and time on the computer to a date and time that you specify. You can specify a new date and/or time by typing a string or by passing a DateTime or TimeSpan object to `Set-Date`. To specify a new date or time, use the Date parameter. To specify a change interval, use the Adjust parameter.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Set-Date</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Adjust</maml:name> <maml:Description> <maml:para>Specifies the value for which this cmdlet adds or subtracts from the current date and time. can type an adjustment in standard date and time format for your locale or use the Adjust parameter to pass a TimeSpan object from `New-TimeSpan` to `Set-Date`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.TimeSpan</command:parameterValue> <dev:type> <maml:name>System.TimeSpan</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisplayHint</maml:name> <maml:Description> <maml:para>Specifies which elements of the date and time are displayed.The acceptable values for this parameter are:</maml:para> <maml:para>- Date . displays only the date. - Time . displays only the time. - DateTime . displays the date and time.</maml:para> <maml:para>This parameter affects only the display. It does not affect the DateTime object that `Get-Date` retrieves.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Date</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Time</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DateTime</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.DisplayHintType</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.DisplayHintType</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Set-Date</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Date</maml:name> <maml:Description> <maml:para>Changes the date and time to the specified values. You can type a new date in the short date format and a time in the standard time format for your locale. Or, you can pass a DateTime object from `Get-Date`.</maml:para> <maml:para>If you specify a date, but not a time, `Set-Date` changes the time to midnight on the specified date. If you specify only a time, it does not change the date.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.DateTime</command:parameterValue> <dev:type> <maml:name>System.DateTime</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisplayHint</maml:name> <maml:Description> <maml:para>Specifies which elements of the date and time are displayed.The acceptable values for this parameter are:</maml:para> <maml:para>- Date . displays only the date. - Time . displays only the time. - DateTime . displays the date and time.</maml:para> <maml:para>This parameter affects only the display. It does not affect the DateTime object that `Get-Date` retrieves.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Date</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Time</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DateTime</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.DisplayHintType</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.DisplayHintType</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Adjust</maml:name> <maml:Description> <maml:para>Specifies the value for which this cmdlet adds or subtracts from the current date and time. can type an adjustment in standard date and time format for your locale or use the Adjust parameter to pass a TimeSpan object from `New-TimeSpan` to `Set-Date`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.TimeSpan</command:parameterValue> <dev:type> <maml:name>System.TimeSpan</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Date</maml:name> <maml:Description> <maml:para>Changes the date and time to the specified values. You can type a new date in the short date format and a time in the standard time format for your locale. Or, you can pass a DateTime object from `Get-Date`.</maml:para> <maml:para>If you specify a date, but not a time, `Set-Date` changes the time to midnight on the specified date. If you specify only a time, it does not change the date.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.DateTime</command:parameterValue> <dev:type> <maml:name>System.DateTime</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DisplayHint</maml:name> <maml:Description> <maml:para>Specifies which elements of the date and time are displayed.The acceptable values for this parameter are:</maml:para> <maml:para>- Date . displays only the date. - Time . displays only the time. - DateTime . displays the date and time.</maml:para> <maml:para>This parameter affects only the display. It does not affect the DateTime object that `Get-Date` retrieves.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">Microsoft.PowerShell.Commands.DisplayHintType</command:parameterValue> <dev:type> <maml:name>Microsoft.PowerShell.Commands.DisplayHintType</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.DateTime</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a date to `Set-Date`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.DateTime</maml:name> </dev:type> <maml:description> <maml:para>`Set-Date` returns an object that represents the date that it set.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>- Use this cmdlet cautiously when changing the date and time on the computer. The change might prevent the computer from receiving system-wide events and updates that are triggered by a date or time. Use the WhatIf and Confirm parameters to avoid errors. - You can use standard .NET methods with the DateTime and TimeSpan objects used with `Set-Date`, such as AddDays , AddMonths , and FromFileTime . For more information, see DateTime Methods (/dotnet/api/system.datetime)and TimeSpan Methods (/dotnet/api/system.timespan)in the MSDN library.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1: Add three days to the system date ---------</maml:title> <dev:code>Set-Date -Date (Get-Date).AddDays(3)</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 2: Set the system clock back 10 minutes -------</maml:title> <dev:code>Set-Date -Adjust -0:10:0 -DisplayHint Time</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 3: Set the date and time to a variable value -----</maml:title> <dev:code>$T = Get-Date Set-Date -Date $T</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 4: Add 90 minutes to the system clock --------</maml:title> <dev:code>$90mins = New-TimeSpan -Minutes 90 Set-Date -Adjust $90mins</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/set-date?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Date</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-TimeSpan</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Set-PSBreakpoint</command:name> <command:verb>Set</command:verb> <command:noun>PSBreakpoint</command:noun> <maml:description> <maml:para>Sets a breakpoint on a line, command, or variable.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Set-PSBreakpoint` cmdlet sets a breakpoint in a script or in any command run in the current session. You can use `Set-PSBreakpoint` to set a breakpoint before executing a script or running a command, or during debugging, when stopped at another breakpoint.</maml:para> <maml:para>`Set-PSBreakpoint` cannot set a breakpoint on a remote computer. To debug a script on a remote computer, copy the script to the local computer and then debug it locally.</maml:para> <maml:para>Each `Set-PSBreakpoint` command creates one of the following three types of breakpoints:</maml:para> <maml:para>- Line breakpoint - Sets breakpoints at particular line and column coordinates.</maml:para> <maml:para>- Command breakpoint - Sets breakpoints on commands and functions.</maml:para> <maml:para>- Variable breakpoint - Sets breakpoints on variables.</maml:para> <maml:para></maml:para> <maml:para>You can set a breakpoint on multiple lines, commands, or variables in a single `Set-PSBreakpoint` command, but each `Set-PSBreakpoint` command sets only one type of breakpoint.</maml:para> <maml:para>At a breakpoint, PowerShell temporarily stops executing and gives control to the debugger. The command prompt changes to `DBG>`, and a set of debugger commands become available for use. However, you can use the Action parameter to specify an alternate response, such as conditions for the breakpoint or instructions to perform additional tasks such as logging or diagnostics.</maml:para> <maml:para>The `Set-PSBreakpoint` cmdlet is one of several cmdlets designed for debugging PowerShell scripts. For more information about the PowerShell debugger, see about_Debuggers (../Microsoft.PowerShell.Core/About/about_Debuggers.md).</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Set-PSBreakpoint</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Script</maml:name> <maml:Description> <maml:para>Specifies an array of script files that this cmdlet sets a breakpoint in. Enter the paths and file names of one or more script files. If the files are in the current directory, you can omit the path. Wildcards are permitted.</maml:para> <maml:para>By default, variable breakpoints and command breakpoints are set on any command that runs in the current session. This parameter is required only when setting a line breakpoint.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Line</maml:name> <maml:Description> <maml:para>Sets a line breakpoint in a script. Enter one or more line numbers, separated by commas. PowerShell stops immediately before executing the statement that begins on each of the specified lines.</maml:para> <maml:para>Lines are counted from the top left margin of the script file beginning with line number 1 (not 0). If you specify a blank line, execution stops before the next non-blank line. If the line is out of range, the breakpoint is never hit.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none"> <maml:name>Column</maml:name> <maml:Description> <maml:para>Specifies the column number of the column in the script file on which execution stops. Enter only one column number. The default is column 1.</maml:para> <maml:para>The Column value is used with the value of the Line parameter to specify the breakpoint. If the Line parameter specifies multiple lines, the Column parameter sets a breakpoint at the specified column on each of the specified lines. PowerShell stops executing before the statement or expression that includes the character at the specified line and column position.</maml:para> <maml:para>Columns are counted from the top left margin beginning with column number 1 (not 0). If you specify a column that does not exist in the script, an error is not declared, but the breakpoint is never executed.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>1</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Action</maml:name> <maml:Description> <maml:para>Specifies commands that run at each breakpoint instead of breaking. Enter a script block that contains the commands. You can use this parameter to set conditional breakpoints or to perform other tasks, such as testing or logging.</maml:para> <maml:para>If this parameter is omitted, or no action is specified, execution stops at the breakpoint, and the debugger starts.</maml:para> <maml:para>When the Action parameter is used, the Action script block runs at each breakpoint. Execution does not stop unless the script block includes the Break keyword. If you use the Continue keyword in the script block, execution resumes until the next breakpoint.</maml:para> <maml:para>For more information, see about_Script_Blocks (../Microsoft.PowerShell.Core/About/about_Script_Blocks.md), about_Break (../Microsoft.PowerShell.Core/About/about_Break.md), and about_Continue (../Microsoft.PowerShell.Core/About/about_Continue.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScriptBlock</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Set-PSBreakpoint</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Script</maml:name> <maml:Description> <maml:para>Specifies an array of script files that this cmdlet sets a breakpoint in. Enter the paths and file names of one or more script files. If the files are in the current directory, you can omit the path. Wildcards are permitted.</maml:para> <maml:para>By default, variable breakpoints and command breakpoints are set on any command that runs in the current session. This parameter is required only when setting a line breakpoint.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Action</maml:name> <maml:Description> <maml:para>Specifies commands that run at each breakpoint instead of breaking. Enter a script block that contains the commands. You can use this parameter to set conditional breakpoints or to perform other tasks, such as testing or logging.</maml:para> <maml:para>If this parameter is omitted, or no action is specified, execution stops at the breakpoint, and the debugger starts.</maml:para> <maml:para>When the Action parameter is used, the Action script block runs at each breakpoint. Execution does not stop unless the script block includes the Break keyword. If you use the Continue keyword in the script block, execution resumes until the next breakpoint.</maml:para> <maml:para>For more information, see about_Script_Blocks (../Microsoft.PowerShell.Core/About/about_Script_Blocks.md), about_Break (../Microsoft.PowerShell.Core/About/about_Break.md), and about_Continue (../Microsoft.PowerShell.Core/About/about_Continue.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScriptBlock</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="C"> <maml:name>Command</maml:name> <maml:Description> <maml:para>Sets a command breakpoint. Enter cmdlet names, such as `Get-Process`, or function names. Wildcards are permitted.</maml:para> <maml:para>Execution stops just before each instance of each command is executed. If the command is a function, execution stops each time the function is called and at each BEGIN, PROCESS, and END section.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Set-PSBreakpoint</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Script</maml:name> <maml:Description> <maml:para>Specifies an array of script files that this cmdlet sets a breakpoint in. Enter the paths and file names of one or more script files. If the files are in the current directory, you can omit the path. Wildcards are permitted.</maml:para> <maml:para>By default, variable breakpoints and command breakpoints are set on any command that runs in the current session. This parameter is required only when setting a line breakpoint.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Action</maml:name> <maml:Description> <maml:para>Specifies commands that run at each breakpoint instead of breaking. Enter a script block that contains the commands. You can use this parameter to set conditional breakpoints or to perform other tasks, such as testing or logging.</maml:para> <maml:para>If this parameter is omitted, or no action is specified, execution stops at the breakpoint, and the debugger starts.</maml:para> <maml:para>When the Action parameter is used, the Action script block runs at each breakpoint. Execution does not stop unless the script block includes the Break keyword. If you use the Continue keyword in the script block, execution resumes until the next breakpoint.</maml:para> <maml:para>For more information, see about_Script_Blocks (../Microsoft.PowerShell.Core/About/about_Script_Blocks.md), about_Break (../Microsoft.PowerShell.Core/About/about_Break.md), and about_Continue (../Microsoft.PowerShell.Core/About/about_Continue.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScriptBlock</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Mode</maml:name> <maml:Description> <maml:para>Specifies the mode of access that triggers variable breakpoints. The default is Write .</maml:para> <maml:para>This parameter is valid only when the Variable parameter is used in the command. The mode applies to all breakpoints set in the command. The acceptable values for this parameter are:</maml:para> <maml:para>- Write - Stops execution immediately before a new value is written to the variable. - Read - Stops execution when the variable is read, that is, when its value is accessed, either to be assigned, displayed, or used. In read mode, execution does not stop when the value of the variable changes. - ReadWrite - Stops execution when the variable is read or written.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Read</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Write</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ReadWrite</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.VariableAccessMode</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.VariableAccessMode</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="V"> <maml:name>Variable</maml:name> <maml:Description> <maml:para>Specifies an array of variables that this cmdlet sets breakpoints on. Enter a comma-separated list of variables without dollar signs (`$`).</maml:para> <maml:para>Use the Mode parameter to determine the mode of access that triggers the breakpoints. The default mode, Write, stops execution just before a new value is written to the variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Action</maml:name> <maml:Description> <maml:para>Specifies commands that run at each breakpoint instead of breaking. Enter a script block that contains the commands. You can use this parameter to set conditional breakpoints or to perform other tasks, such as testing or logging.</maml:para> <maml:para>If this parameter is omitted, or no action is specified, execution stops at the breakpoint, and the debugger starts.</maml:para> <maml:para>When the Action parameter is used, the Action script block runs at each breakpoint. Execution does not stop unless the script block includes the Break keyword. If you use the Continue keyword in the script block, execution resumes until the next breakpoint.</maml:para> <maml:para>For more information, see about_Script_Blocks (../Microsoft.PowerShell.Core/About/about_Script_Blocks.md), about_Break (../Microsoft.PowerShell.Core/About/about_Break.md), and about_Continue (../Microsoft.PowerShell.Core/About/about_Continue.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScriptBlock</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none"> <maml:name>Column</maml:name> <maml:Description> <maml:para>Specifies the column number of the column in the script file on which execution stops. Enter only one column number. The default is column 1.</maml:para> <maml:para>The Column value is used with the value of the Line parameter to specify the breakpoint. If the Line parameter specifies multiple lines, the Column parameter sets a breakpoint at the specified column on each of the specified lines. PowerShell stops executing before the statement or expression that includes the character at the specified line and column position.</maml:para> <maml:para>Columns are counted from the top left margin beginning with column number 1 (not 0). If you specify a column that does not exist in the script, an error is not declared, but the breakpoint is never executed.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>1</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="C"> <maml:name>Command</maml:name> <maml:Description> <maml:para>Sets a command breakpoint. Enter cmdlet names, such as `Get-Process`, or function names. Wildcards are permitted.</maml:para> <maml:para>Execution stops just before each instance of each command is executed. If the command is a function, execution stops each time the function is called and at each BEGIN, PROCESS, and END section.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Line</maml:name> <maml:Description> <maml:para>Sets a line breakpoint in a script. Enter one or more line numbers, separated by commas. PowerShell stops immediately before executing the statement that begins on each of the specified lines.</maml:para> <maml:para>Lines are counted from the top left margin of the script file beginning with line number 1 (not 0). If you specify a blank line, execution stops before the next non-blank line. If the line is out of range, the breakpoint is never hit.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32[]</command:parameterValue> <dev:type> <maml:name>System.Int32[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Mode</maml:name> <maml:Description> <maml:para>Specifies the mode of access that triggers variable breakpoints. The default is Write .</maml:para> <maml:para>This parameter is valid only when the Variable parameter is used in the command. The mode applies to all breakpoints set in the command. The acceptable values for this parameter are:</maml:para> <maml:para>- Write - Stops execution immediately before a new value is written to the variable. - Read - Stops execution when the variable is read, that is, when its value is accessed, either to be assigned, displayed, or used. In read mode, execution does not stop when the value of the variable changes. - ReadWrite - Stops execution when the variable is read or written.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.VariableAccessMode</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.VariableAccessMode</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Script</maml:name> <maml:Description> <maml:para>Specifies an array of script files that this cmdlet sets a breakpoint in. Enter the paths and file names of one or more script files. If the files are in the current directory, you can omit the path. Wildcards are permitted.</maml:para> <maml:para>By default, variable breakpoints and command breakpoints are set on any command that runs in the current session. This parameter is required only when setting a line breakpoint.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="V"> <maml:name>Variable</maml:name> <maml:Description> <maml:para>Specifies an array of variables that this cmdlet sets breakpoints on. Enter a comma-separated list of variables without dollar signs (`$`).</maml:para> <maml:para>Use the Mode parameter to determine the mode of access that triggers the breakpoints. The default mode, Write, stops execution just before a new value is written to the variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe input to `Set-PSBreakpoint`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Breakpoint object (System.Management.Automation.LineBreakpoint, System.Management.Automation.VariableBreakpoint, System.Management.Automation.CommandBreakpoint)</maml:name> </dev:type> <maml:description> <maml:para>`Set-PSBreakpoint` returns an object that represents each breakpoint that it sets.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>- `Set-PSBreakpoint` cannot set a breakpoint on a remote computer. To debug a script on a remote computer, copy the script to the local computer and then debug it locally. - When you set a breakpoint on more than one line, command, or variable, `Set-PSBreakpoint` generates a breakpoint object for each entry. - When setting a breakpoint on a function or variable at the command prompt, you can set the breakpoint before or after you create the function or variable.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------ Example 1: Set a breakpoint on a line ------------</maml:title> <dev:code>Set-PSBreakpoint -Script "sample.ps1" -Line 5 Column : 0 Line : 5 Action : Enabled : True HitCount : 0 Id : 0 Script : C:\ps-test\sample.ps1 ScriptName : C:\ps-test\sample.ps1</dev:code> <dev:remarks> <maml:para>When you set a new breakpoint by line number, the `Set-PSBreakpoint` cmdlet generates a line breakpoint object ( System.Management.Automation.LineBreakpoint ) that includes the breakpoint ID and hit count.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 2: Set a breakpoint on a function ----------</maml:title> <dev:code>Set-PSBreakpoint -Command "Increment" -Script "sample.ps1" Command : Increment Action : Enabled : True HitCount : 0 Id : 1 Script : C:\ps-test\sample.ps1 ScriptName : C:\ps-test\sample.ps1</dev:code> <dev:remarks> <maml:para>The result is a command breakpoint object. Before the script runs, the value of the HitCount property is 0.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 3: Set a breakpoint on a variable ----------</maml:title> <dev:code>Set-PSBreakpoint -Script "sample.ps1" -Variable "Server" -Mode ReadWrite</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 4: Set a breakpoint on every command that begins with specified text</maml:title> <dev:code>Set-PSBreakpoint -Script Sample.ps1 -Command "write*"</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 5: Set a breakpoint depending on the value of a variable</maml:title> <dev:code>Set-PSBreakpoint -Script "test.ps1" -Command "DiskTest" -Action { if ($Disk -gt 2) { break } }</dev:code> <dev:remarks> <maml:para>The value of the Action is a script block that tests the value of the `$Disk` variable in the function.</maml:para> <maml:para>The action uses the `break` keyword to stop execution if the condition is met. The alternative (and the default) is Continue .</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 6: Set a breakpoint on a function ----------</maml:title> <dev:code>PS> Set-PSBreakpoint -Command "checklog" Id : 0 Command : checklog Enabled : True HitCount : 0 Action : function CheckLog { >> get-eventlog -log Application | >> where {($_.source -like "TestApp") -and ($_.Message -like "*failed*")} >>} >> PS> Checklog DEBUG: Hit breakpoint(s) DEBUG: Function breakpoint on 'prompt:Checklog'</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 7: Set breakpoints on multiple lines ---------</maml:title> <dev:code>PS C:\> Set-PSBreakpoint -Script "sample.ps1" -Line 1, 14, 19 -Column 2 -Action {&(log.ps1)} Column : 2 Line : 1 Action : Enabled : True HitCount : 0 Id : 6 Script : C:\ps-test\sample.ps1 ScriptName : C:\ps-test\sample.ps1 Column : 2 Line : 14 Action : Enabled : True HitCount : 0 Id : 7 Script : C:\ps-test\sample.ps1 ScriptName : C:\ps-test\sample.ps1 Column : 2 Line : 19 Action : Enabled : True HitCount : 0 Id : 8 Script : C:\ps-test\sample.ps1 ScriptName : C:\ps-test\sample.ps1</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/set-psbreakpoint?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Disable-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Enable-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-PSCallStack</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-PSBreakpoint</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Set-TraceSource</command:name> <command:verb>Set</command:verb> <command:noun>TraceSource</command:noun> <maml:description> <maml:para>Configures, starts, and stops a trace of PowerShell components.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Set-TraceSource cmdlet configures, starts, and stops a trace of a PowerShell component. You can use it to specify which components will be traced and where the tracing output is sent.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Set-TraceSource</maml:name> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies which components are traced. Enter the name of the trace source of each component. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> <maml:name>Option</maml:name> <maml:Description> <maml:para>Specifies the type of events that are traced. The acceptable values for this parameter are:</maml:para> <maml:para>- None</maml:para> <maml:para>- Constructor</maml:para> <maml:para>- Dispose</maml:para> <maml:para>- Finalizer</maml:para> <maml:para>- Method</maml:para> <maml:para>- Property</maml:para> <maml:para>- Delegates</maml:para> <maml:para>- Events</maml:para> <maml:para>- Exception</maml:para> <maml:para>- Lock</maml:para> <maml:para>- Error</maml:para> <maml:para>- Errors</maml:para> <maml:para>- Warning</maml:para> <maml:para>- Verbose</maml:para> <maml:para>- WriteLine</maml:para> <maml:para>- Data</maml:para> <maml:para>- Scope</maml:para> <maml:para>- ExecutionFlow</maml:para> <maml:para>- Assert</maml:para> <maml:para>- All</maml:para> <maml:para></maml:para> <maml:para>All is the default.</maml:para> <maml:para>The following values are combinations of other values:</maml:para> <maml:para>- ExecutionFlow: (Constructor, Dispose, Finalizer, Method, Delegates, Events, and Scope)</maml:para> <maml:para>- Data: (Constructor, Dispose, Finalizer, Property, Verbose, and WriteLine)</maml:para> <maml:para>- Errors: (Error and Exception).</maml:para> <maml:para></maml:para> <maml:para>To specify multiple options, separate them with commas, but with no spaces, and enclose them in quotation marks, such as "Constructor,Dispose".</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">None</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Constructor</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Dispose</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Finalizer</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Method</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Property</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Delegates</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Events</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Exception</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Lock</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Error</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Errors</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Warning</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Verbose</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">WriteLine</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Data</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Scope</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ExecutionFlow</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Assert</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">All</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSTraceSourceOptions</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSTraceSourceOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Debugger</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends the trace output to the debugger. You can view the output in any user-mode or kernel mode debugger or in Microsoft Visual Studio. This parameter also selects the default trace listener.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSPath"> <maml:name>FilePath</maml:name> <maml:Description> <maml:para>Specifies a file that this cmdlet sends the trace output to. This parameter also selects the file trace listener. If you use this parameter to start the trace, use the RemoveFileListener parameter to stop the trace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet overwrites a read-only file. Use with the FilePath parameter.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ListenerOption</maml:name> <maml:Description> <maml:para>Specifies optional data to the prefix of each trace message in the output. The acceptable values for this parameter are:</maml:para> <maml:para>- None</maml:para> <maml:para>- LogicalOperationStack</maml:para> <maml:para>- DateTime</maml:para> <maml:para>- Timestamp</maml:para> <maml:para>- ProcessId</maml:para> <maml:para>- ThreadId</maml:para> <maml:para>- Callstack</maml:para> <maml:para></maml:para> <maml:para>None is the default.</maml:para> <maml:para>To specify multiple options, separate them with commas, but with no spaces, and enclose them in quotation marks, such as "ProcessID,ThreadID".</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">None</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">LogicalOperationStack</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DateTime</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Timestamp</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ProcessId</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ThreadId</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Callstack</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Diagnostics.TraceOptions</command:parameterValue> <dev:type> <maml:name>System.Diagnostics.TraceOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PSHost</maml:name> <maml:Description> <maml:para>ndicates that this cmdlet sends the trace output to the PowerShell host. This parameter also selects the PSHost trace listener.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Set-TraceSource</maml:name> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies which components are traced. Enter the name of the trace source of each component. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>RemoveFileListener</maml:name> <maml:Description> <maml:para>Stops the trace by removing the file trace listener associated with the specified file. Enter the path and file name of the trace output file.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Set-TraceSource</maml:name> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies which components are traced. Enter the name of the trace source of each component. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>RemoveListener</maml:name> <maml:Description> <maml:para>Stops the trace by removing the trace listener.</maml:para> <maml:para>Use the following values with RemoveListener :</maml:para> <maml:para>- To remove PSHost (console), type `Host`.</maml:para> <maml:para>- To remove Debugger, type `Debug`.</maml:para> <maml:para>- To remove all trace listeners, type `*`.</maml:para> <maml:para></maml:para> <maml:para>To remove the file trace listener, use the RemoveFileListener parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Debugger</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends the trace output to the debugger. You can view the output in any user-mode or kernel mode debugger or in Microsoft Visual Studio. This parameter also selects the default trace listener.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSPath"> <maml:name>FilePath</maml:name> <maml:Description> <maml:para>Specifies a file that this cmdlet sends the trace output to. This parameter also selects the file trace listener. If you use this parameter to start the trace, use the RemoveFileListener parameter to stop the trace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet overwrites a read-only file. Use with the FilePath parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ListenerOption</maml:name> <maml:Description> <maml:para>Specifies optional data to the prefix of each trace message in the output. The acceptable values for this parameter are:</maml:para> <maml:para>- None</maml:para> <maml:para>- LogicalOperationStack</maml:para> <maml:para>- DateTime</maml:para> <maml:para>- Timestamp</maml:para> <maml:para>- ProcessId</maml:para> <maml:para>- ThreadId</maml:para> <maml:para>- Callstack</maml:para> <maml:para></maml:para> <maml:para>None is the default.</maml:para> <maml:para>To specify multiple options, separate them with commas, but with no spaces, and enclose them in quotation marks, such as "ProcessID,ThreadID".</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Diagnostics.TraceOptions</command:parameterValue> <dev:type> <maml:name>System.Diagnostics.TraceOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies which components are traced. Enter the name of the trace source of each component. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> <maml:name>Option</maml:name> <maml:Description> <maml:para>Specifies the type of events that are traced. The acceptable values for this parameter are:</maml:para> <maml:para>- None</maml:para> <maml:para>- Constructor</maml:para> <maml:para>- Dispose</maml:para> <maml:para>- Finalizer</maml:para> <maml:para>- Method</maml:para> <maml:para>- Property</maml:para> <maml:para>- Delegates</maml:para> <maml:para>- Events</maml:para> <maml:para>- Exception</maml:para> <maml:para>- Lock</maml:para> <maml:para>- Error</maml:para> <maml:para>- Errors</maml:para> <maml:para>- Warning</maml:para> <maml:para>- Verbose</maml:para> <maml:para>- WriteLine</maml:para> <maml:para>- Data</maml:para> <maml:para>- Scope</maml:para> <maml:para>- ExecutionFlow</maml:para> <maml:para>- Assert</maml:para> <maml:para>- All</maml:para> <maml:para></maml:para> <maml:para>All is the default.</maml:para> <maml:para>The following values are combinations of other values:</maml:para> <maml:para>- ExecutionFlow: (Constructor, Dispose, Finalizer, Method, Delegates, Events, and Scope)</maml:para> <maml:para>- Data: (Constructor, Dispose, Finalizer, Property, Verbose, and WriteLine)</maml:para> <maml:para>- Errors: (Error and Exception).</maml:para> <maml:para></maml:para> <maml:para>To specify multiple options, separate them with commas, but with no spaces, and enclose them in quotation marks, such as "Constructor,Dispose".</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSTraceSourceOptions</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSTraceSourceOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PSHost</maml:name> <maml:Description> <maml:para>ndicates that this cmdlet sends the trace output to the PowerShell host. This parameter also selects the PSHost trace listener.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>RemoveFileListener</maml:name> <maml:Description> <maml:para>Stops the trace by removing the file trace listener associated with the specified file. Enter the path and file name of the trace output file.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>RemoveListener</maml:name> <maml:Description> <maml:para>Stops the trace by removing the trace listener.</maml:para> <maml:para>Use the following values with RemoveListener :</maml:para> <maml:para>- To remove PSHost (console), type `Host`.</maml:para> <maml:para>- To remove Debugger, type `Debug`.</maml:para> <maml:para>- To remove all trace listeners, type `*`.</maml:para> <maml:para></maml:para> <maml:para>To remove the file trace listener, use the RemoveFileListener parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a string that contains a name to Set-TraceSource .</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None or System.Management.Automation.PSTraceSource</maml:name> </dev:type> <maml:description> <maml:para>When you use the PassThru parameter, Set-TraceSource generates a System.Management.Automation.PSTraceSource object representing the trace session. Otherwise, this cmdlet does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>* Tracing is a method that developers use to debug and refine programs. When tracing, the program generates detailed messages about each step in its internal processing.</maml:para> <maml:para> The PowerShell tracing cmdlets are designed to help PowerShell developers, but they are available to all users. They let you monitor nearly every aspect of the functionality of PowerShell.</maml:para> <maml:para> A trace source is the part of each PowerShell component that manages tracing and generates trace messages for the component. To trace a component, you identify its trace source.</maml:para> <maml:para> A trace listener receives the output of the trace and displays it to the user. You can elect to send the trace data to a user-mode or kernel-mode debugger, to the console, to a file, or to a custom listener derived from the System.Diagnostics.TraceListener class. To start a trace, use the Name parameter to specify a trace source and the FilePath , Debugger , or PSHost parameters to specify a listener (a destination for the output). Use the Options parameter to determine the types of events that are traced and the ListenerOption* parameter to configure the trace output. To change the configuration of a trace, enter a Set-TraceSource * command as you would to start a trace. PowerShell recognizes that the trace source is already being traced. It stops the trace, adds the new configuration, and starts or restarts the trace. To stop a trace, use the RemoveListener parameter. To stop a trace that uses the file listener (a trace started by using the FilePath parameter), use the RemoveFileListener* parameter. When you remove the listener, the trace stops. To determine which components can be traced, use Get-TraceSource. The trace sources for each module are loaded automatically when the component is in use, and they appear in the output of Get-TraceSource *.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------- Example 1: Trace the ParameterBinding component -------</maml:title> <dev:code>PS C:\> Set-TraceSource -Name "ParameterBinding" -Option ExecutionFlow -PSHost -ListenerOption "ProcessId,TimeStamp"</dev:code> <dev:remarks> <maml:para>This command starts tracing for the ParameterBinding component of PowerShell. It uses the Name parameter to specify the trace source, the Option parameter to select the ExecutionFlow trace events, and the PSHost parameter to select the PowerShell host listener, which sends the output to the console. The ListenerOption parameter adds the ProcessID and TimeStamp values to the trace message prefix.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------------- Example 2: Stop a trace -------------------</maml:title> <dev:code>PS C:\> Set-TraceSource -Name "ParameterBinding" -RemoveListener "Host"</dev:code> <dev:remarks> <maml:para>This command stops the trace of the ParameterBinding component of PowerShell. It uses the Name parameter to identify the component that was being traced and the RemoveListener parameter to identify the trace listener.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/set-tracesource?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-TraceSource</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Trace-Command</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Set-Variable</command:name> <command:verb>Set</command:verb> <command:noun>Variable</command:noun> <maml:description> <maml:para>Sets the value of a variable. Creates the variable if one with the requested name does not exist.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Set-Variable cmdlet assigns a value to a specified variable or changes the current value. If the variable does not exist, the cmdlet creates it.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Set-Variable</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the variable name.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="1" aliases="none"> <maml:name>Value</maml:name> <maml:Description> <maml:para>Specifies the value of the variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Description</maml:name> <maml:Description> <maml:para>Specifies the description of the variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Exclude</maml:name> <maml:Description> <maml:para>Specifies an array of items that this cmdlet excludes from the operation. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as `*.txt`. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Allows you to create a variable with the same name as an existing read-only variable, or to change the value of a read-only variable.</maml:para> <maml:para>By default, you can overwrite a variable, unless the variable has an option value of ReadOnly or Constant. For more information, see the Option parameter.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Include</maml:name> <maml:Description> <maml:para>Specifies an array of items that this cmdlet includes in the operation. The value of this parameter qualifies the Name parameter. Enter a name or name pattern, such as `c*`. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Option</maml:name> <maml:Description> <maml:para>Specifies the value of the Options property of the variable.</maml:para> <maml:para>Valid values are:</maml:para> <maml:para>- None: Sets no options. ("None" is the default.)</maml:para> <maml:para>- ReadOnly: Can be deleted. Cannot be changed, except by using the Force parameter.</maml:para> <maml:para>- Constant: Cannot be deleted or changed. "Constant" is valid only when you are creating a variable. You cannot change the options of an existing variable to "Constant".</maml:para> <maml:para>- Private: The variable is available only in the current scope.</maml:para> <maml:para>- AllScope: The variable is copied to any new scopes that are created.</maml:para> <maml:para></maml:para> <maml:para>To see the Options property of all variables in the session, type `Get-Variable | Format-Table -Property name, options -Autosize`.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">None</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ReadOnly</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Constant</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Private</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">AllScope</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Unspecified</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScopedItemOptions</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScopedItemOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the new variable. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope of the variable.The acceptable values for this parameter are:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Script</maml:para> <maml:para>- Private</maml:para> <maml:para>- A number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent).</maml:para> <maml:para></maml:para> <maml:para>Local is the default.</maml:para> <maml:para>For more information, see about_Scopes (../Microsoft.PowerShell.Core/About/about_scopes.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Local</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Visibility</maml:name> <maml:Description> <maml:para>Determines whether the variable is visible outside of the session in which it was created. This parameter is designed for use in scripts and commands that will be delivered to other users.</maml:para> <maml:para>Valid values are:</maml:para> <maml:para>- Public: The variable is visible. ("Public" is the default.)</maml:para> <maml:para>- Private: The variable is not visible.</maml:para> <maml:para></maml:para> <maml:para>When a variable is private, it does not appear in lists of variables, such as those returned by Get-Variable, or in displays of the Variable: drive. Commands to read or change the value of a private variable return an error. However, the user can run commands that use a private variable if the commands were written in the session in which the variable was defined.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Public</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Private</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SessionStateEntryVisibility</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SessionStateEntryVisibility</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Public</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Description</maml:name> <maml:Description> <maml:para>Specifies the description of the variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Exclude</maml:name> <maml:Description> <maml:para>Specifies an array of items that this cmdlet excludes from the operation. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as `*.txt`. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Allows you to create a variable with the same name as an existing read-only variable, or to change the value of a read-only variable.</maml:para> <maml:para>By default, you can overwrite a variable, unless the variable has an option value of ReadOnly or Constant. For more information, see the Option parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="named" aliases="none"> <maml:name>Include</maml:name> <maml:Description> <maml:para>Specifies an array of items that this cmdlet includes in the operation. The value of this parameter qualifies the Name parameter. Enter a name or name pattern, such as `c*`. Wildcards are permitted.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies the variable name.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Option</maml:name> <maml:Description> <maml:para>Specifies the value of the Options property of the variable.</maml:para> <maml:para>Valid values are:</maml:para> <maml:para>- None: Sets no options. ("None" is the default.)</maml:para> <maml:para>- ReadOnly: Can be deleted. Cannot be changed, except by using the Force parameter.</maml:para> <maml:para>- Constant: Cannot be deleted or changed. "Constant" is valid only when you are creating a variable. You cannot change the options of an existing variable to "Constant".</maml:para> <maml:para>- Private: The variable is available only in the current scope.</maml:para> <maml:para>- AllScope: The variable is copied to any new scopes that are created.</maml:para> <maml:para></maml:para> <maml:para>To see the Options property of all variables in the session, type `Get-Variable | Format-Table -Property name, options -Autosize`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScopedItemOptions</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScopedItemOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the new variable. By default, this cmdlet does not generate any output.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Scope</maml:name> <maml:Description> <maml:para>Specifies the scope of the variable.The acceptable values for this parameter are:</maml:para> <maml:para>- Global</maml:para> <maml:para>- Local</maml:para> <maml:para>- Script</maml:para> <maml:para>- Private</maml:para> <maml:para>- A number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent).</maml:para> <maml:para></maml:para> <maml:para>Local is the default.</maml:para> <maml:para>For more information, see about_Scopes (../Microsoft.PowerShell.Core/About/about_scopes.md).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Local</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="1" aliases="none"> <maml:name>Value</maml:name> <maml:Description> <maml:para>Specifies the value of the variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Visibility</maml:name> <maml:Description> <maml:para>Determines whether the variable is visible outside of the session in which it was created. This parameter is designed for use in scripts and commands that will be delivered to other users.</maml:para> <maml:para>Valid values are:</maml:para> <maml:para>- Public: The variable is visible. ("Public" is the default.)</maml:para> <maml:para>- Private: The variable is not visible.</maml:para> <maml:para></maml:para> <maml:para>When a variable is private, it does not appear in lists of variables, such as those returned by Get-Variable, or in displays of the Variable: drive. Commands to read or change the value of a private variable return an error. However, the user can run commands that use a private variable if the commands were written in the session in which the variable was defined.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SessionStateEntryVisibility</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SessionStateEntryVisibility</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Public</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Object</maml:name> </dev:type> <maml:description> <maml:para>You can pipe an object that represents the value of the variable to Set-Variable .</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None or System.Management.Automation.PSVariable</maml:name> </dev:type> <maml:description> <maml:para>When you use the PassThru parameter, Set-Variable generates a System.Management.Automation.PSVariable object representing the new or changed variable. Otherwise, this cmdlet does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1: Set a variable and get its value ---------</maml:title> <dev:code>PS C:\> Set-Variable -Name "desc" -Value "A description" PS C:\> Get-Variable -Name "desc"</dev:code> <dev:remarks> <maml:para>These commands set the value of the desc variable to A description, and then gets the value of the variable.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 2: Set a global, read-only variable ---------</maml:title> <dev:code>PS C:\> Set-Variable -Name "processes" -Value (Get-Process) -Option constant -Scope global -Description "All processes" -PassThru | Format-List -Property *</dev:code> <dev:remarks> <maml:para>This command creates a global, read-only variable that contains all processes on the system, and then it displays all properties of the variable.</maml:para> <maml:para>The command uses the Set-Variable cmdlet to create the variable. It uses the PassThru parameter to create an object representing the new variable, and it uses the pipeline operator (|) to pass the object to the Format-List cmdlet. It uses the Property parameter of Format-List with a value of all (*) to display all properties of the newly created variable.</maml:para> <maml:para>The value, "(Get-Process)", is enclosed in parentheses to ensure that it is executed before being stored in the variable. Otherwise, the variable contains the words "Get-Process".</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 3: Understand public vs. private variables ------</maml:title> <dev:code>PS C:\> New-Variable -Name "counter" -Visibility Public -Value 26 PS C:\> $Counter 26 PS C:\> Get-Variable c* Name Value ---- ----- Culture en-US ConsoleFileName ConfirmPreference High CommandLineParameters {} Counter 26 PS C:\> Set-Variable -Name "counter" -Visibility Private PS C:\> Get-Variable c* Name Value ---- ----- Culture en-US ConsoleFileName ConfirmPreference High CommandLineParameters {} PS C:\> $counter "Cannot access the variable '$counter' because it is a private variable" PS C:\> .\use-counter.ps1 #Commands completed successfully.</dev:code> <dev:remarks> <maml:para>This command shows how to change the visibility of a variable to Private. This variable can be read and changed by scripts with the required permissions, but it is not visible to the user.</maml:para> <maml:para>The sample output shows the difference in the behavior of public and private variables.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/set-variable?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Clear-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-Variable</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Show-Command</command:name> <command:verb>Show</command:verb> <command:noun>Command</command:noun> <maml:description> <maml:para>Displays PowerShell command information in a graphical window.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Show-Command` cmdlet lets you create a PowerShell command in a command window. You can use the features of the command window to run the command or have it return the command to you.</maml:para> <maml:para>`Show-Command` is a very useful teaching and learning tool. `Show-Command` works on all command types, including cmdlets, functions, workflows and CIM commands.</maml:para> <maml:para>Without parameters, `Show-Command` displays a command window that lists all available commands in all installed modules. To find the commands in a module, select the module from the Modules drop-down list. To select a command, click the command name.</maml:para> <maml:para>To use the command window, select a command, either by using the Name or by clicking the command name in the Commands list. Each parameter set is displayed on a separate tab. Asterisks indicate the mandatory parameters. To enter values for a parameter, type the value in the text box or select the value from the drop-down box. To add a switch parameter, click to select the parameter check box.</maml:para> <maml:para>When you're ready, you can click Copy to copy the command that you've created to the clipboard or click Run to run the command. You can also use the PassThru parameter to return the command to the host program, such as the PowerShell console. To cancel the command selection and return to the view that displays all commands, press Ctrl and click the selected command.</maml:para> <maml:para>In the PowerShell Integrated Scripting Environment (ISE), a variation of the `Show-Command` window is displayed by default. For information about using this command window, see the PowerShell ISE Help topics.</maml:para> <maml:para>This cmdlet was introduced in PowerShell 3.0.</maml:para> <maml:para>Because this cmdlet requires a user interface, it does not work on Windows Server Core or Windows Nano Server. This cmdlet is only available on Windows systems that support the Windows Desktop.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Show-Command</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="CommandName"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Displays a command window for the specified command. Enter the name of one command, such as the name of a cmdlet, function, or CIM command. If you omit this parameter, `Show-Command` displays a command window that lists all of the PowerShell commands in all modules installed on the computer.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ErrorPopup</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet displays errors in a pop-up window, in addition to displaying them at the command line. By default, when a command that is run in a `Show-Command` window generates an error, the error is displayed only at the command line.</maml:para> <maml:para>Also, when you run the command (by using the Run button in the `Show-Command` window), the ErrorPopup parameter returns the command results to the current command, instead of running the command and returning its output to a new command. You can use this feature to save the command results in a variable.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Height</maml:name> <maml:Description> <maml:para>Specifies the height of the `Show-Command` window in pixels. Enter a value between 300 and the number of pixels in the screen resolution. If the value is too large to display the command window on the screen, `Show-Command` generates an error. The default height is 600 pixels. For a `Show-Command` command that includes the Name parameter, the default height is 300 pixels.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Double</command:parameterValue> <dev:type> <maml:name>System.Double</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NoCommonParameter</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet omits the Common Parameters section of the command display. By default, the Common Parameters appear in an expandable section at the bottom of the command window.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output. To run the command string, copy and paste it at the command prompt or save it in a variable and use the `Invoke-Expression` cmdlet to run the string in the variable.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Width</maml:name> <maml:Description> <maml:para>Specifies the width of the `Show-Command` window in pixels. Enter a value between 300 and the number of pixels in the screen resolution. If the value is too large to display the command window on the screen, `Show-Command` generates an error. The default width is 300 pixels.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Double</command:parameterValue> <dev:type> <maml:name>System.Double</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ErrorPopup</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet displays errors in a pop-up window, in addition to displaying them at the command line. By default, when a command that is run in a `Show-Command` window generates an error, the error is displayed only at the command line.</maml:para> <maml:para>Also, when you run the command (by using the Run button in the `Show-Command` window), the ErrorPopup parameter returns the command results to the current command, instead of running the command and returning its output to a new command. You can use this feature to save the command results in a variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Height</maml:name> <maml:Description> <maml:para>Specifies the height of the `Show-Command` window in pixels. Enter a value between 300 and the number of pixels in the screen resolution. If the value is too large to display the command window on the screen, `Show-Command` generates an error. The default height is 600 pixels. For a `Show-Command` command that includes the Name parameter, the default height is 300 pixels.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Double</command:parameterValue> <dev:type> <maml:name>System.Double</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="CommandName"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Displays a command window for the specified command. Enter the name of one command, such as the name of a cmdlet, function, or CIM command. If you omit this parameter, `Show-Command` displays a command window that lists all of the PowerShell commands in all modules installed on the computer.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NoCommonParameter</maml:name> <maml:Description> <maml:para>Indicates that this cmdlet omits the Common Parameters section of the command display. By default, the Common Parameters appear in an expandable section at the bottom of the command window.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:Description> <maml:para>Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output. To run the command string, copy and paste it at the command prompt or save it in a variable and use the `Invoke-Expression` cmdlet to run the string in the variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Width</maml:name> <maml:Description> <maml:para>Specifies the width of the `Show-Command` window in pixels. Enter a value between 300 and the number of pixels in the screen resolution. If the value is too large to display the command window on the screen, `Show-Command` generates an error. The default width is 300 pixels.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Double</command:parameterValue> <dev:type> <maml:name>System.Double</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe input to `Show-Command`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None, System.String, System.Object</maml:name> </dev:type> <maml:description> <maml:para>When you use the PassThru parameter, `Show-Command` returns a command string. When you use the ErrorPopup parameter, `Show-Command` returns the command output (any object). Otherwise, `Show-Command` does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>`Show-Command` does not work in remote sessions.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------- Example 1: Open the Commands window -------------</maml:title> <dev:code>Show-Command</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 2: Open a cmdlet in the Commands window -------</maml:title> <dev:code>Show-Command -Name "Invoke-Command"</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 3: Open a cmdlet with specified parameters ------</maml:title> <dev:code>Show-Command -Name "Connect-PSSession" -Height 700 -Width 1000 -ErrorPopup</dev:code> <dev:remarks> <maml:para>The Height and Width parameters specify the dimension of the command window. The ErrorPopup parameter displays the error command window.</maml:para> <maml:para>When you click Run , the `Connect-PSSession` command runs, just as would if you typed the `Connect-PSSession` command at the command line.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>- Example 4: Specify new default parameter values for a cmdlet -</maml:title> <dev:code>$PSDefaultParameterValues = @{ "Show-Command:Height" = 700 "Show-Command:Width" = 1000 "Show-Command:ErrorPopup" = $True }</dev:code> <dev:remarks> <maml:para>Now when you run a `Show-Command` command, the new defaults are applied automatically. To use these default values in every PowerShell session, add the `$PSDefaultParameterValues` variable to your PowerShell profile. For more information, see about_Profiles (../Microsoft.PowerShell.Core/About/about_Profiles.md)and about_Parameters_Default_Values (../Microsoft.PowerShell.Core/About/about_Parameters_Default_Values.md).</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------ Example 5: Send output to a grid view ------------</maml:title> <dev:code>Show-Command Get-ChildItem | Out-GridView</dev:code> <dev:remarks> <maml:para>The command uses the `Show-Command` cmdlet to open a command window for the`Get-ChildItem`cmdlet. When you click the Run button, the `Get-ChildItem` command runs and generates output. The pipeline operator ( | ) sends the output of the `Get-ChildItem` command to the `Out-GridView` cmdlet, which displays the `Get-ChildItem` output in an interactive window.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 6: Display a command that you create in the Commands window</maml:title> <dev:code>Show-Command -PassThru Get-EventLog -LogName "Windows PowerShell" -Newest 5</dev:code> <dev:remarks> <maml:para>For example, if you use the `Show-Command` window to create a `Get-EventLog` command that gets the five newest events in the Windows PowerShell event log, and then click OK , the command returns the output shown above. Viewing the command string helps you learn PowerShell.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 7: Save a command to a variable -----------</maml:title> <dev:code>$C = Show-Command -PassThru $C Invoke-Expression $C Get-EventLog -LogName "PowerShell" -Newest 5 Index Time EntryType Source InstanceID Message ----- ---- --------- ------ ---------- ------- 11520 Dec 16 16:37 Information Windows PowerShell 400 Engine state is changed from None to Available... 11519 Dec 16 16:37 Information Windows PowerShell 600 Provider "Variable" is Started. ... 11518 Dec 16 16:37 Information Windows PowerShell 600 Provider "Registry" is Started. ... 11517 Dec 16 16:37 Information Windows PowerShell 600 Provider "Function" is Started. ... 11516 Dec 16 16:37 Information Windows PowerShell 600 Provider "FileSystem" is Started. ...</dev:code> <dev:remarks> <maml:para>The first command uses the PassThru parameter of the `Show-Command` cmdlet and saves the results of the command in the `$C` variable. In this case, we use the `Show-Command` window to create a `Get-EventLog` command that gets the five newest events in the Windows PowerShell event log. When you click OK , `Show-Command` returns the command string, which is saved in the `$C` variable.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 8: Save the output of a command to a variable ----</maml:title> <dev:code>$P = Show-Command Get-Process -ErrorPopup $P Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- 473 33 94096 112532 709 2.06 4492 powershell</dev:code> <dev:remarks> <maml:para>In addition to displaying errors in a window, ErrorPopup returns command output to the current command, instead of creating a new command. When you run this command, the `Show-Command` window opens. You can use the window features to set parameter values. To run the command, click the Run button in the `Show-Command` window.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/show-command?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Sort-Object</command:name> <command:verb>Sort</command:verb> <command:noun>Object</command:noun> <maml:description> <maml:para>Sorts objects by property values.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Sort-Object` cmdlet sorts objects in ascending or descending order based on object property values. If sort properties are not included in a command, PowerShell uses default sort properties.</maml:para> <maml:para>You can sort objects by a single property or multiple properties. Multiple properties use hash tables to sort in ascending order, descending order, or a combination of sort orders. Properties are sorted as case-sensitive or case-insensitive. Use the Unique parameter to eliminate duplicates from the output.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Sort-Object</maml:name> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the property names that `Sort-Object` uses to sort the objects. Wildcards are permitted. Objects are sorted based on the property values. If you do not specify a property, `Sort-Object` sorts based on default properties for the object type.</maml:para> <maml:para>Multiple properties can be sorted in ascending order, descending order, or a combination of sort orders. When you specify multiple properties, the objects are sorted by the first property. If multiple objects have the same value for the first property, those objects are sorted by the second property. This process continues until there are no more specified properties or no groups of objects.</maml:para> <maml:para>The Property parameter's value can be a calculated property. To create a calculated property, use a hash table.</maml:para> <maml:para>Valid keys for a hash table are as follows:</maml:para> <maml:para>- Expression <string> or <script block></maml:para> <maml:para>- Ascending <Boolean></maml:para> <maml:para>- Descending <Boolean></maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Default properties</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CaseSensitive</maml:name> <maml:Description> <maml:para>Indicates that the sort is case-sensitive. By default, sorts are not case-sensitive.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Case-insensitive</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Culture</maml:name> <maml:Description> <maml:para>Specifies the cultural configuration to use for sorts. Use `Get-Culture` to display the system's culture configuration.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Descending</maml:name> <maml:Description> <maml:para>Indicates that `Sort-Object` sorts the objects in descending order. The default is ascending order.</maml:para> <maml:para>To sort multiple properties with different sort orders, use a hash table. For example, with a hash table you can sort one property in ascending order and another property in descending order.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Ascending</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>To sort objects, send them down the pipeline to `Sort-Object`. If you use the InputObject parameter to submit a collection of items, `Sort-Object` receives one object that represents the collection. Because one object cannot be sorted, `Sort-Object` returns the entire collection unchanged.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Unique</maml:name> <maml:Description> <maml:para>Indicates that `Sort-Object` eliminates duplicates and returns only the unique members of the collection. The first instance of a unique value is included in the sorted output. Unique is case-insensitive. Strings that only differ by character case are considered the same. For example, character and CHARACTER.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>All</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CaseSensitive</maml:name> <maml:Description> <maml:para>Indicates that the sort is case-sensitive. By default, sorts are not case-sensitive.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Case-insensitive</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Culture</maml:name> <maml:Description> <maml:para>Specifies the cultural configuration to use for sorts. Use `Get-Culture` to display the system's culture configuration.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Descending</maml:name> <maml:Description> <maml:para>Indicates that `Sort-Object` sorts the objects in descending order. The default is ascending order.</maml:para> <maml:para>To sort multiple properties with different sort orders, use a hash table. For example, with a hash table you can sort one property in ascending order and another property in descending order.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Ascending</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>To sort objects, send them down the pipeline to `Sort-Object`. If you use the InputObject parameter to submit a collection of items, `Sort-Object` receives one object that represents the collection. Because one object cannot be sorted, `Sort-Object` returns the entire collection unchanged.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the property names that `Sort-Object` uses to sort the objects. Wildcards are permitted. Objects are sorted based on the property values. If you do not specify a property, `Sort-Object` sorts based on default properties for the object type.</maml:para> <maml:para>Multiple properties can be sorted in ascending order, descending order, or a combination of sort orders. When you specify multiple properties, the objects are sorted by the first property. If multiple objects have the same value for the first property, those objects are sorted by the second property. This process continues until there are no more specified properties or no groups of objects.</maml:para> <maml:para>The Property parameter's value can be a calculated property. To create a calculated property, use a hash table.</maml:para> <maml:para>Valid keys for a hash table are as follows:</maml:para> <maml:para>- Expression <string> or <script block></maml:para> <maml:para>- Ascending <Boolean></maml:para> <maml:para>- Descending <Boolean></maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Default properties</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Unique</maml:name> <maml:Description> <maml:para>Indicates that `Sort-Object` eliminates duplicates and returns only the unique members of the collection. The first instance of a unique value is included in the sorted output. Unique is case-insensitive. Strings that only differ by character case are considered the same. For example, character and CHARACTER.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>All</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe the objects to be sorted to `Sort-Object`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>`Sort-Object` returns the sorted objects.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>The `Sort-Object` cmdlet sorts objects based on properties specified in the command or the default sort properties for the object type. If an object does not have one of the specified properties, the property value for that object is interpreted by `Sort-Object` as Null and placed at the end of the sort order.</maml:para> <maml:para>`Sort-Object` uses the Compare method for each property. If a property does not implement IComparable , the cmdlet converts the property value to a string and uses the Compare method for System.String . For more information, see PSObject.CompareTo(Object) Method (/dotnet/api/system.management.automation.psobject.compareto).</maml:para> <maml:para>If you sort on an enumerated property such as Status , `Sort-Object` sorts by the enumeration values. Stopped has a value of 1 and Running has a value of 4 . Stopped is sorted before Running because of the enumerated values. For more information, see ServiceControllerStatus (/dotnet/api/system.serviceprocess.servicecontrollerstatus).</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------- Example 1: Sort the current directory by name --------</maml:title> <dev:code>PS> Get-ChildItem -Path C:\Test | Sort-Object Directory: C:\Test Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 2/13/2019 08:55 26 anotherfile.txt -a---- 2/13/2019 13:26 20 Bfile.txt -a---- 2/12/2019 15:40 118014 Command.txt -a---- 2/1/2019 08:43 183 CreateTestFile.ps1 d----- 2/25/2019 18:25 Files d----- 2/25/2019 18:24 Logs -ar--- 2/12/2019 14:31 27 ReadOnlyFile.txt -a---- 2/12/2019 16:24 23 Zsystemlog.log</dev:code> <dev:remarks> <maml:para>The `Get-ChildItem` cmdlet gets the files and subdirectories from the directory specified by the Path parameter, C:\Test . The objects are sent down the pipeline to the `Sort-Object` cmdlet. `Sort-Object` does not specify a property so the output is sorted by the default sort property, Name .</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 2: Sort the current directory by file length -----</maml:title> <dev:code>PS> Get-ChildItem -Path C:\Test -File | Sort-Object -Property Length Directory: C:\Test Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 2/13/2019 13:26 20 Bfile.txt -a---- 2/12/2019 16:24 23 Zsystemlog.log -a---- 2/13/2019 08:55 26 anotherfile.txt -ar--- 2/12/2019 14:31 27 ReadOnlyFile.txt -a---- 2/1/2019 08:43 183 CreateTestFile.ps1 -a---- 2/12/2019 15:40 118014 Command.txt</dev:code> <dev:remarks> <maml:para>The `Get-ChildItem` cmdlet gets the files from the directory specified by the Path parameter. The File parameter specifies that `Get-ChildItem` only gets file objects. The objects are sent down the pipeline to the `Sort-Object` cmdlet. `Sort-Object` uses the Length parameter to sort the files by length in ascending order.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 3: Sort processes by memory usage ----------</maml:title> <dev:code>PS> Get-Process | Sort-Object -Property WS | Select-Object -Last 5 NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName ------ ----- ----- ------ -- -- ----------- 136 193.92 217.11 889.16 87492 8 OUTLOOK 112 347.73 297.02 95.19 106908 8 Teams 206 266.54 323.71 37.17 60620 8 MicrosoftEdgeCP 35 552.19 549.94 131.66 6552 8 Code 0 1.43 595.12 0.00 2780 0 Memory Compression</dev:code> <dev:remarks> <maml:para>The `Get-Process` cmdlet gets the list of processes running on the computer. The process objects are sent down the pipeline to the `Sort-Object` cmdlet. `Sort-Object` uses the Property parameter to sort the objects by WS . The objects are sent down the pipeline to the `Select-Object` cmdlet. `Select-Object` uses the Last parameter to specify the last five objects, which are the objects with the highest WS usage.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 4: Sort HistoryInfo objects by Id ----------</maml:title> <dev:code>PS> Get-History | Sort-Object -Property Id -Descending Id CommandLine -- ----------- 10 Get-Command Sort-Object -Syntax 9 $PSVersionTable 8 Get-Command Sort-Object -Syntax 7 Get-Command Sort-Object -ShowCommandInfo 6 Get-ChildItem -Path C:\Test | Sort-Object -Property Length 5 Get-Help Clear-History -online 4 Get-Help Clear-History -full 3 Get-ChildItem | Get-Member 2 Get-Command Sort-Object -Syntax 1 Set-Location C:\Test\</dev:code> <dev:remarks> <maml:para>The `Get-History` cmdlet gets the history objects from the current PowerShell session. The objects are sent down the pipeline to the `Sort-Object` cmdlet. `Sort-Object` uses the Property parameter to sort the objects by Id . The Descending parameter sorts the command history from newest to oldest.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 5: Use a hash table to sort properties in ascending and descending order</maml:title> <dev:code>PS C:\> Get-Service | Sort-Object -Property @{Expression = "Status"; Descending = $True}, @{Expression = "DisplayName"; Descending = $False} Status Name DisplayName ------ ---- ----------- Running Appinfo Application Information Running BthAvctpSvc AVCTP service Running BrokerInfrastru... Background Tasks Infrastructure Ser... Running BDESVC BitLocker Drive Encryption Service Running CoreMessagingRe... CoreMessaging Running VaultSvc Credential Manager Running DsSvc Data Sharing Service Running Dhcp DHCP Client ... Stopped ALG Application Layer Gateway Service Stopped AppMgmt Application Management Stopped BITS Background Intelligent Transfer Ser... Stopped wbengine Block Level Backup Engine Service Stopped BluetoothUserSe... Bluetooth User Support Service_14fb... Stopped COMSysApp COM+ System Application Stopped smstsmgr ConfigMgr Task Sequence Agent Stopped DeviceInstall Device Install Service Stopped MSDTC Distributed Transaction Coordinator</dev:code> <dev:remarks> <maml:para>The `Get-Service` cmdlet gets the list of services on the computer. The service objects are sent down the pipeline to the `Sort-Object` cmdlet. `Sort-Object` uses the Property parameter with a hash table to specify the property names and sort orders. The Property parameter is sorted by two properties, Status in descending order and DisplayName in ascending order. Status is an enumerated property. Stopped has a value of 1 and Running has a value of 4 . The Descending parameter is set to `$True` so that Running processes are displayed before Stopped processes. DisplayName sets the Descending parameter to `$False` to sort the display names in alphabetical order.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 6: Sort text files by time span -----------</maml:title> <dev:code>PS> Get-ChildItem -Path C:\Test\*.txt | Sort-Object -Property @{Expression = {$_.CreationTime - $_.LastWriteTime}; Descending = $False} | Format-Table CreationTime, LastWriteTime, FullName CreationTime LastWriteTime FullName ------------ ------------- -------- 11/21/2018 12:39:01 2/26/2019 08:59:36 C:\Test\test2.txt 12/4/2018 08:29:41 2/26/2019 08:57:05 C:\Test\powershell_list.txt 2/20/2019 08:15:59 2/26/2019 12:09:43 C:\Test\CreateTestFile.txt 2/20/2019 08:15:59 2/26/2019 12:07:41 C:\Test\Command.txt 2/20/2019 08:15:59 2/26/2019 08:57:52 C:\Test\ReadOnlyFile.txt 11/29/2018 15:16:50 12/4/2018 16:16:24 C:\Test\LogData.txt 2/25/2019 18:25:11 2/26/2019 12:08:47 C:\Test\Zsystemlog.txt 2/25/2019 18:25:11 2/26/2019 08:55:33 C:\Test\Bfile.txt 2/26/2019 08:46:59 2/26/2019 12:12:19 C:\Test\LogFile3.txt</dev:code> <dev:remarks> <maml:para>The `Get-ChildItem` cmdlet uses the Path parameter to specify the directory C:\Test and all of the `*.txt` files. The objects are sent down the pipeline to the `Sort-Object` cmdlet. `Sort-Object` uses the Property parameter with a hash table to determine each files time span between CreationTime and LastWriteTime . The Descending parameter is set to `$False` to sort in the order of longest to shortest time span.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------- Example 7: Sort names in a text file -------------</maml:title> <dev:code>PS> Get-Content -Path C:\Test\ServerNames.txt localhost server01 server25 LOCALHOST Server19 server3 localhost PS> Get-Content -Path C:\Test\ServerNames.txt | Sort-Object localhost LOCALHOST localhost server01 Server19 server25 server3 PS> Get-Content -Path C:\Test\ServerNames.txt | Sort-Object -Unique localhost server01 Server19 server25 server3</dev:code> <dev:remarks> <maml:para>The `Get-Content` cmdlet uses the Path parameter to specify the directory and file name. The file ServerNames.txt contains an unsorted list of computer names.</maml:para> <maml:para>The `Get-Content` cmdlet uses the Path parameter to specify the directory and file name. The file ServerNames.txt contains an unsorted list of computer names. The objects are sent down the pipeline to the `Sort-Object` cmdlet. `Sort-Object` sorts the list in the default order, ascending.</maml:para> <maml:para>The `Get-Content` cmdlet uses the Path parameter to specify the directory and file name. The file ServerNames.txt contains an unsorted list of computer names. The objects are sent down the pipeline to the `Sort-Object` cmdlet. `Sort-Object` uses the Unique parameter to remove duplicate computer names. The list is sorted in the default order, ascending.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------ Example 8: Sort a string as an integer ------------</maml:title> <dev:code>PS> Get-Content -Path C:\Test\ProductId.txt | Sort-Object 0 1 12345 1500 2 2800 3500 4100 500 6200 77 88 99999 PS> Get-Content -Path C:\Test\ProductId.txt | Sort-Object {[int]$_} 0 1 2 77 88 500 1500 2800 3500 4100 6200 12345 99999</dev:code> <dev:remarks> <maml:para>In the second example, `Get-Content` gets the contents of the file and pipes lines to the `Sort-Object` cmdlet. `Sort-Object` uses a script block to convert the strings to integers. In the sample code, `[int]` converts the string to an integer and `$_` represents each string as it comes down the pipeline. The integer objects are sent down the pipeline to the `Sort-Object` cmdlet. `Sort-Object` sorts the integer objects in numeric order.</maml:para> <maml:para>The `Get-Content` cmdlet uses the Path parameter to specify the directory and file name. The file ProductId.txt contains an unsorted list of product numbers. The string objects are sent down the pipeline to the `ForEach-Object` cmdlet. `ForEach-Object` uses a script block to convert the strings to integers. In the sample code, `[int]` converts the string to an integer and `$_` represents each string as it comes down the pipeline. The integer objects are sent down the pipeline to the `Sort-Object` cmdlet. `Sort-Object` sorts the integer objects in numeric order.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/sort-object?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Hash_Tables</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Compare-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ForEach-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Group-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Measure-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Select-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Tee-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Start-Sleep</command:name> <command:verb>Start</command:verb> <command:noun>Sleep</command:noun> <maml:description> <maml:para>Suspends the activity in a script or session for the specified period of time.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Start-Sleep` cmdlet suspends the activity in a script or session for the specified period of time. You can use it for many tasks, such as waiting for an operation to complete or pausing before repeating an operation.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Start-Sleep</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="none"> <maml:name>Milliseconds</maml:name> <maml:Description> <maml:para>Specifies how long the resource sleeps in milliseconds. The parameter can be abbreviated as m .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Start-Sleep</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Seconds</maml:name> <maml:Description> <maml:para>Specifies how long the resource sleeps in seconds. You can omit the parameter name ( Seconds ), or you can abbreviate it as s .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="none"> <maml:name>Milliseconds</maml:name> <maml:Description> <maml:para>Specifies how long the resource sleeps in milliseconds. The parameter can be abbreviated as m .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>Seconds</maml:name> <maml:Description> <maml:para>Specifies how long the resource sleeps in seconds. You can omit the parameter name ( Seconds ), or you can abbreviate it as s .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Int32</maml:name> </dev:type> <maml:description> <maml:para>You can pipe the number of seconds to `Start-Sleep`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>This cmdlet does not return any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>- You can also refer to `Start-Sleep` by its built-in alias, `sleep`. For more information, see about_Aliases (../Microsoft.PowerShell.Core/About/about_Aliases.md). - `Ctrl+C` breaks out of `Start-Sleep`. - `Ctrl+C` does not break out of `[Threading.Thread]::Sleep`. For more information, see Thread.Sleep Method (/dotnet/api/system.threading.thread.sleep).</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1: Sleep all commands for 15 seconds ---------</maml:title> <dev:code>Start-Sleep -s 15</dev:code> <dev:remarks> <maml:para>This command makes all commands in the session sleep for 15 seconds.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------------- Example 2: Sleep all commands ----------------</maml:title> <dev:code>Start-Sleep -m 500</dev:code> <dev:remarks> <maml:para>This command makes all the commands in the session sleep for one-half of a second (500 milliseconds).</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/start-sleep?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Tee-Object</command:name> <command:verb>Tee</command:verb> <command:noun>Object</command:noun> <maml:description> <maml:para>Saves command output in a file or variable and also sends it down the pipeline.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Tee-Object` cmdlet redirects output, that is, it sends the output of a command in two directions (like the letter T). It stores the output in a file or variable and also sends it down the pipeline. If `Tee-Object` is the last command in the pipeline, the command output is displayed at the prompt.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Tee-Object</maml:name> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>FilePath</maml:name> <maml:Description> <maml:para>Specifies a file that this cmdlet saves the object to Wildcard characters are permitted, but must resolve to a single file.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Append</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet appends the output to the specified file. Without this parameter, the new content replaces any existing content in the file without warning.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the object to be saved and displayed. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe an object to `Tee-Object`.</maml:para> <maml:para>When you use the InputObject parameter with `Tee-Object`, instead of piping command results to `Tee-Object`, the InputObject value is treated as a single object even if the value is a collection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Tee-Object</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the object to be saved and displayed. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe an object to `Tee-Object`.</maml:para> <maml:para>When you use the InputObject parameter with `Tee-Object`, instead of piping command results to `Tee-Object`, the InputObject value is treated as a single object even if the value is a collection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies a file that this cmdlet saves the object to. Unlike FilePath , the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Tee-Object</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the object to be saved and displayed. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe an object to `Tee-Object`.</maml:para> <maml:para>When you use the InputObject parameter with `Tee-Object`, instead of piping command results to `Tee-Object`, the InputObject value is treated as a single object even if the value is a collection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Variable</maml:name> <maml:Description> <maml:para>Specifies a variable that the cmdlet saves the object to. Enter a variable name without the preceding dollar sign (`$`).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Append</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet appends the output to the specified file. Without this parameter, the new content replaces any existing content in the file without warning.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>FilePath</maml:name> <maml:Description> <maml:para>Specifies a file that this cmdlet saves the object to Wildcard characters are permitted, but must resolve to a single file.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the object to be saved and displayed. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe an object to `Tee-Object`.</maml:para> <maml:para>When you use the InputObject parameter with `Tee-Object`, instead of piping command results to `Tee-Object`, the InputObject value is treated as a single object even if the value is a collection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies a file that this cmdlet saves the object to. Unlike FilePath , the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Variable</maml:name> <maml:Description> <maml:para>Specifies a variable that the cmdlet saves the object to. Enter a variable name without the preceding dollar sign (`$`).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe objects to `Tee-Object`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>`Tee-Object` returns the object that it redirects.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>You can also use the `Out-File` cmdlet or the redirection operator, both of which save the output in a file but do not send it down the pipeline.</maml:para> <maml:para>`Tee-Object` uses "Unicode" (UTF-16LE) encoding when it writes to files. If you need a different encoding, use the `Out-File` cmdlet with the Encoding parameter.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--- Example 1: Output processes to a file and to the console ---</maml:title> <dev:code>Get-Process | Tee-Object -FilePath "C:\Test1\testfile2.txt" Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- 83 4 2300 4520 39 0.30 4032 00THotkey 272 6 1400 3944 34 0.06 3088 alg 81 3 804 3284 21 2.45 148 ApntEx 81 4 2008 5808 38 0.75 3684 Apoint ...</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title> Example 2: Output processes to a variable and `Select-Object` </maml:title> <dev:code>Get-Process notepad | Tee-Object -Variable proc | Select-Object processname,handles ProcessName Handles ----------- ------- notepad 43 notepad 37 notepad 38 notepad 38</dev:code> <dev:remarks> <maml:para>The `Select-Object` cmdlet selects the ProcessName and Handles properties. Note that the `$proc` variable includes the default information returned by `Get-Process`.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 3: Output system files to two log files -------</maml:title> <dev:code>Get-ChildItem -Path D: -File -System -Recurse | Tee-Object -FilePath "c:\test\AllSystemFiles.txt" -Append | Out-File c:\test\NewSystemFiles.txt</dev:code> <dev:remarks> <maml:para>The command uses the `Get-ChildItem` cmdlet to do a recursive search for system files on the D: drive. A pipeline operator (|) sends the list to `Tee-Object`, which appends the list to the AllSystemFiles.txt file and passes the list down the pipeline to the `Out-File` cmdlet, which saves the list in the NewSystemFiles.txt file.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/tee-object?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Compare-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ForEach-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Group-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Measure-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Select-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Sort-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Where-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Redirection</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Trace-Command</command:name> <command:verb>Trace</command:verb> <command:noun>Command</command:noun> <maml:description> <maml:para>Configures and starts a trace of the specified expression or command.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Trace-Command` cmdlet configures and starts a trace of the specified expression or command. It works like Set-TraceSource, except that it applies only to the specified command.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Trace-Command</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies an array of PowerShell components that are traced. Enter the name of the trace source of each component. Wildcards are permitted. To find the trace sources on your computer, type `Get-TraceSource`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Command</maml:name> <maml:Description> <maml:para>Specifies a command that is being processed during the trace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none"> <maml:name>Option</maml:name> <maml:Description> <maml:para>Determines the type of events that are traced. The acceptable values for this parameter are:</maml:para> <maml:para>- None</maml:para> <maml:para>- Constructor</maml:para> <maml:para>- Dispose</maml:para> <maml:para>- Finalizer</maml:para> <maml:para>- Method</maml:para> <maml:para>- Property</maml:para> <maml:para>- Delegates</maml:para> <maml:para>- Events</maml:para> <maml:para>- Exception</maml:para> <maml:para>- Lock</maml:para> <maml:para>- Error</maml:para> <maml:para>- Errors</maml:para> <maml:para>- Warning</maml:para> <maml:para>- Verbose</maml:para> <maml:para>- WriteLine</maml:para> <maml:para>- Data</maml:para> <maml:para>- Scope</maml:para> <maml:para>- ExecutionFlow</maml:para> <maml:para>- Assert</maml:para> <maml:para>- All</maml:para> <maml:para></maml:para> <maml:para>All is the default.</maml:para> <maml:para>The following values are combinations of other values:</maml:para> <maml:para>- ExecutionFlow: (Constructor, Dispose, Finalizer, Method, Delegates, Events, and Scope)</maml:para> <maml:para>- Data: (Constructor, Dispose, Finalizer, Property, Verbose, and WriteLine)</maml:para> <maml:para>- Errors: (Error and Exception).</maml:para> <maml:para></maml:para> <maml:para>To specify multiple options, separate them with commas, but with no spaces, and enclose them in quotation marks, such as "Constructor,Dispose".</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">None</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Constructor</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Dispose</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Finalizer</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Method</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Property</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Delegates</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Events</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Exception</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Lock</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Error</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Errors</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Warning</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Verbose</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">WriteLine</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Data</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Scope</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ExecutionFlow</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Assert</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">All</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSTraceSourceOptions</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSTraceSourceOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Args"> <maml:name>ArgumentList</maml:name> <maml:Description> <maml:para>Specifies the parameters and parameter values for the command being traced. The alias for ArgumentList is Args . This feature is especially useful for debugging dynamic parameters.</maml:para> <maml:para>For more information about the behavior of ArgumentList , see about_Splatting (../Microsoft.PowerShell.Core/About/about_Splatting.md#splatting-with-arrays).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Debugger</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends the trace output to the debugger. You can view the output in any user-mode or kernel mode debugger or in Visual Studio. This parameter also selects the default trace listener.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSPath"> <maml:name>FilePath</maml:name> <maml:Description> <maml:para>Specifies a file that the cmdlet sends the trace output to. This parameter also selects the file trace listener.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Forces the command to run without asking for user confirmation. Used with the FilePath parameter. Even using the Force parameter, the cmdlet cannot override security restrictions.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies input to the expression that is being processed during the trace. You can enter a variable that represents the input that the expression accepts, or pass an object through the pipeline.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ListenerOption</maml:name> <maml:Description> <maml:para>Specifies optional data to the prefix of each trace message in the output. The acceptable values for this parameter are:</maml:para> <maml:para>- None</maml:para> <maml:para>- LogicalOperationStack</maml:para> <maml:para>- DateTime</maml:para> <maml:para>- Timestamp</maml:para> <maml:para>- ProcessId</maml:para> <maml:para>- ThreadId</maml:para> <maml:para>- Callstack None is the default.</maml:para> <maml:para>To specify multiple options, separate them with commas, but with no spaces, and enclose them in quotation marks, such as "ProcessID,ThreadID".</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">None</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">LogicalOperationStack</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DateTime</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Timestamp</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ProcessId</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ThreadId</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Callstack</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Diagnostics.TraceOptions</command:parameterValue> <dev:type> <maml:name>System.Diagnostics.TraceOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PSHost</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends the trace output to the PowerShell host. This parameter also selects the PSHost trace listener.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Trace-Command</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies an array of PowerShell components that are traced. Enter the name of the trace source of each component. Wildcards are permitted. To find the trace sources on your computer, type `Get-TraceSource`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Expression</maml:name> <maml:Description> <maml:para>Specifies the expression that is being processed during the trace. Enclose the expression in braces (`{}`).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScriptBlock</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none"> <maml:name>Option</maml:name> <maml:Description> <maml:para>Determines the type of events that are traced. The acceptable values for this parameter are:</maml:para> <maml:para>- None</maml:para> <maml:para>- Constructor</maml:para> <maml:para>- Dispose</maml:para> <maml:para>- Finalizer</maml:para> <maml:para>- Method</maml:para> <maml:para>- Property</maml:para> <maml:para>- Delegates</maml:para> <maml:para>- Events</maml:para> <maml:para>- Exception</maml:para> <maml:para>- Lock</maml:para> <maml:para>- Error</maml:para> <maml:para>- Errors</maml:para> <maml:para>- Warning</maml:para> <maml:para>- Verbose</maml:para> <maml:para>- WriteLine</maml:para> <maml:para>- Data</maml:para> <maml:para>- Scope</maml:para> <maml:para>- ExecutionFlow</maml:para> <maml:para>- Assert</maml:para> <maml:para>- All</maml:para> <maml:para></maml:para> <maml:para>All is the default.</maml:para> <maml:para>The following values are combinations of other values:</maml:para> <maml:para>- ExecutionFlow: (Constructor, Dispose, Finalizer, Method, Delegates, Events, and Scope)</maml:para> <maml:para>- Data: (Constructor, Dispose, Finalizer, Property, Verbose, and WriteLine)</maml:para> <maml:para>- Errors: (Error and Exception).</maml:para> <maml:para></maml:para> <maml:para>To specify multiple options, separate them with commas, but with no spaces, and enclose them in quotation marks, such as "Constructor,Dispose".</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">None</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Constructor</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Dispose</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Finalizer</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Method</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Property</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Delegates</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Events</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Exception</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Lock</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Error</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Errors</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Warning</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Verbose</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">WriteLine</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Data</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Scope</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ExecutionFlow</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Assert</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">All</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSTraceSourceOptions</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSTraceSourceOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Debugger</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends the trace output to the debugger. You can view the output in any user-mode or kernel mode debugger or in Visual Studio. This parameter also selects the default trace listener.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSPath"> <maml:name>FilePath</maml:name> <maml:Description> <maml:para>Specifies a file that the cmdlet sends the trace output to. This parameter also selects the file trace listener.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Forces the command to run without asking for user confirmation. Used with the FilePath parameter. Even using the Force parameter, the cmdlet cannot override security restrictions.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies input to the expression that is being processed during the trace. You can enter a variable that represents the input that the expression accepts, or pass an object through the pipeline.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ListenerOption</maml:name> <maml:Description> <maml:para>Specifies optional data to the prefix of each trace message in the output. The acceptable values for this parameter are:</maml:para> <maml:para>- None</maml:para> <maml:para>- LogicalOperationStack</maml:para> <maml:para>- DateTime</maml:para> <maml:para>- Timestamp</maml:para> <maml:para>- ProcessId</maml:para> <maml:para>- ThreadId</maml:para> <maml:para>- Callstack None is the default.</maml:para> <maml:para>To specify multiple options, separate them with commas, but with no spaces, and enclose them in quotation marks, such as "ProcessID,ThreadID".</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">None</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">LogicalOperationStack</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DateTime</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Timestamp</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ProcessId</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ThreadId</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Callstack</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Diagnostics.TraceOptions</command:parameterValue> <dev:type> <maml:name>System.Diagnostics.TraceOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PSHost</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends the trace output to the PowerShell host. This parameter also selects the PSHost trace listener.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Args"> <maml:name>ArgumentList</maml:name> <maml:Description> <maml:para>Specifies the parameters and parameter values for the command being traced. The alias for ArgumentList is Args . This feature is especially useful for debugging dynamic parameters.</maml:para> <maml:para>For more information about the behavior of ArgumentList , see about_Splatting (../Microsoft.PowerShell.Core/About/about_Splatting.md#splatting-with-arrays).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Command</maml:name> <maml:Description> <maml:para>Specifies a command that is being processed during the trace.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Debugger</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends the trace output to the debugger. You can view the output in any user-mode or kernel mode debugger or in Visual Studio. This parameter also selects the default trace listener.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Expression</maml:name> <maml:Description> <maml:para>Specifies the expression that is being processed during the trace. Enclose the expression in braces (`{}`).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ScriptBlock</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ScriptBlock</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="PSPath"> <maml:name>FilePath</maml:name> <maml:Description> <maml:para>Specifies a file that the cmdlet sends the trace output to. This parameter also selects the file trace listener.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Forces the command to run without asking for user confirmation. Used with the FilePath parameter. Even using the Force parameter, the cmdlet cannot override security restrictions.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies input to the expression that is being processed during the trace. You can enter a variable that represents the input that the expression accepts, or pass an object through the pipeline.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ListenerOption</maml:name> <maml:Description> <maml:para>Specifies optional data to the prefix of each trace message in the output. The acceptable values for this parameter are:</maml:para> <maml:para>- None</maml:para> <maml:para>- LogicalOperationStack</maml:para> <maml:para>- DateTime</maml:para> <maml:para>- Timestamp</maml:para> <maml:para>- ProcessId</maml:para> <maml:para>- ThreadId</maml:para> <maml:para>- Callstack None is the default.</maml:para> <maml:para>To specify multiple options, separate them with commas, but with no spaces, and enclose them in quotation marks, such as "ProcessID,ThreadID".</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Diagnostics.TraceOptions</command:parameterValue> <dev:type> <maml:name>System.Diagnostics.TraceOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:Description> <maml:para>Specifies an array of PowerShell components that are traced. Enter the name of the trace source of each component. Wildcards are permitted. To find the trace sources on your computer, type `Get-TraceSource`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none"> <maml:name>Option</maml:name> <maml:Description> <maml:para>Determines the type of events that are traced. The acceptable values for this parameter are:</maml:para> <maml:para>- None</maml:para> <maml:para>- Constructor</maml:para> <maml:para>- Dispose</maml:para> <maml:para>- Finalizer</maml:para> <maml:para>- Method</maml:para> <maml:para>- Property</maml:para> <maml:para>- Delegates</maml:para> <maml:para>- Events</maml:para> <maml:para>- Exception</maml:para> <maml:para>- Lock</maml:para> <maml:para>- Error</maml:para> <maml:para>- Errors</maml:para> <maml:para>- Warning</maml:para> <maml:para>- Verbose</maml:para> <maml:para>- WriteLine</maml:para> <maml:para>- Data</maml:para> <maml:para>- Scope</maml:para> <maml:para>- ExecutionFlow</maml:para> <maml:para>- Assert</maml:para> <maml:para>- All</maml:para> <maml:para></maml:para> <maml:para>All is the default.</maml:para> <maml:para>The following values are combinations of other values:</maml:para> <maml:para>- ExecutionFlow: (Constructor, Dispose, Finalizer, Method, Delegates, Events, and Scope)</maml:para> <maml:para>- Data: (Constructor, Dispose, Finalizer, Property, Verbose, and WriteLine)</maml:para> <maml:para>- Errors: (Error and Exception).</maml:para> <maml:para></maml:para> <maml:para>To specify multiple options, separate them with commas, but with no spaces, and enclose them in quotation marks, such as "Constructor,Dispose".</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSTraceSourceOptions</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSTraceSourceOptions</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PSHost</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet sends the trace output to the PowerShell host. This parameter also selects the PSHost trace listener.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe objects that represent input to the expression to `Trace-Command`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>Returns the command trace in the debug stream.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>- Tracing is a method that developers use to debug and refine programs. When tracing, the program generates detailed messages about each step in its internal processing.</maml:para> <maml:para>- The PowerShell tracing cmdlets are designed to help PowerShell developers, but they are available to all users. They let you monitor nearly every aspect of the functionality of the shell.</maml:para> <maml:para>- To find the PowerShell components that are enabled for tracing, type `Get-Help Get-TraceSource`.</maml:para> <maml:para> A trace source is the part of each PowerShell component that manages tracing and generates trace messages for the component. To trace a component, you identify its trace source.</maml:para> <maml:para> A trace listener receives the output of the trace and displays it to the user. You can elect to send the trace data to a user-mode or kernel-mode debugger, to the host or console, to a file, or to a custom listener derived from the System.Diagnostics.TraceListener class.</maml:para> <maml:para>- When you use the commandSet parameter set, PowerShell processes the command just as it would be processed in a pipeline. For example, command discovery is not repeated for each incoming object.</maml:para> <maml:para>- The names of the Name , Expression , Option , and Command parameters are optional. If you omit the parameter names, the unnamed parameter values must appear in this order: Name , Expression , Option or Name , Command , Option . If you include the parameter names, the parameters can appear in any order.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>Example 1: Trace metadata processing, parameter binding, and an expression</maml:title> <dev:code>Trace-Command -Name metadata,parameterbinding,cmdlet -Expression {Get-Process Notepad} -PSHost</dev:code> <dev:remarks> <maml:para>It uses the Name parameter to specify the trace sources, the Expression parameter to specify the command, and the PSHost parameter to send the output to the console. Because it does not specify any tracing options or listener options, the command uses the defaults:</maml:para> <maml:para>- All for the tracing options</maml:para> <maml:para>- None for the listener options</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>- Example 2: Trace the actions of ParameterBinding operations -</maml:title> <dev:code>$A = "i*" Trace-Command ParameterBinding {Get-Alias $Input} -PSHost -InputObject $A</dev:code> <dev:remarks> <maml:para>In `Trace-Command`, the InputObject parameter passes an object to the expression that is being processed during the trace.</maml:para> <maml:para>The first command stores the string `i*` in the `$A` variable. The second command uses the `Trace-Command` cmdlet with the ParameterBinding trace source. The PSHost parameter sends the output to the console.</maml:para> <maml:para>The expression being processed is `Get-Alias $Input`, where the `$Input` variable is associated with the InputObject parameter. The InputObject parameter passes the variable `$A` to the expression. In effect, the command being processed during the trace is `Get-Alias -InputObject $A" or "$A | Get-Alias`.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/trace-command?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-TraceSource</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Measure-Command</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-TraceSource</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Show-Command</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Unblock-File</command:name> <command:verb>Unblock</command:verb> <command:noun>File</command:noun> <maml:description> <maml:para>Unblocks files that were downloaded from the Internet.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Unblock-File cmdlet lets you open files that were downloaded from the Internet. It unblocks PowerShell script files that were downloaded from the Internet so you can run them, even when the PowerShell execution policy is RemoteSigned . By default, these files are blocked to protect the computer from untrusted files.</maml:para> <maml:para>Before using the Unblock-File cmdlet, review the file and its source and verify that it is safe to open.</maml:para> <maml:para>Internally, the Unblock-File cmdlet removes the Zone.Identifier alternate data stream, which has a value of "3" to indicate that it was downloaded from the Internet.</maml:para> <maml:para>For more information about PowerShell execution policies, see about_Execution_Policies (../Microsoft.PowerShell.Core/about/about_Execution_Policies.md).</maml:para> <maml:para>This cmdlet was introduced in Windows PowerShell 3.0.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Unblock-File</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the files to unblock. Unlike Path , the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Unblock-File</maml:name> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the files to unblock. Wildcard characters are supported.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:Description> <maml:para>Specifies the files to unblock. Unlike Path , the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="False" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:Description> <maml:para>Specifies the files to unblock. Wildcard characters are supported.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a file path to Unblock-File .</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>This cmdlet does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>The Unblock-File * cmdlet works only in file system drives. Unblock-File performs the same operation as the Unblock button on the Properties * dialog box in File Explorer. If you use the Unblock-File * cmdlet on a file that is not blocked, the command has no effect on the unblocked file and the cmdlet does not generate errors.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------------ Example 1: Unblock a file ------------------</maml:title> <dev:code>PS C:\> Unblock-File -Path C:\Users\User01\Documents\Downloads\PowerShellTips.chm</dev:code> <dev:remarks> <maml:para>This command unblocks the PowerShellTips.chm file.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------------- Example 2: Unblock multiple files --------------</maml:title> <dev:code>PS C:\> dir C:\Downloads\*PowerShell* | Unblock-File</dev:code> <dev:remarks> <maml:para>This command unblocks all of the files in the C:\Downloads directory whose names include "PowerShell". Do not run a command like this one until you have verified that all files are safe.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------- Example 3: Find and unblock scripts -------------</maml:title> <dev:code>The first command uses the *Stream* parameter of the Get-Item cmdlet get files with the Zone.Identifier stream.Although you could pipe the output directly to the **Unblock-File** cmdlet (Get-Item * -Stream "Zone.Identifier" -ErrorAction SilentlyContinue | ForEach {Unblock-File $_.FileName}), it is prudent to review the file and confirm that it is safe before unblocking. PS C:\> Get-Item * -Stream "Zone.Identifier" -ErrorAction SilentlyContinue FileName: C:\ps-test\Start-ActivityTracker.ps1 Stream Length ------ ------ Zone.Identifier 26 The second command shows what happens when you run a blocked script in a PowerShell session in which the execution policy is **RemoteSigned**. The RemoteSigned policy prevents you from running scripts that are downloaded from the Internet unless they are digitally signed. PS C:\> C:\ps-test\Start-ActivityTracker.ps1 c:\ps-test\Start-ActivityTracker.ps1 : File c:\ps-test\Start-ActivityTracker.ps1 cannot be loaded. The file c:\ps-test\Start-ActivityTracker.ps1 is not digitally signed. The script will not execute on the system. For more information, see about_Execution_Policies. At line:1 char:1 + c:\ps-test\Start-ActivityTracker.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess The third command uses the **Unblock-File** cmdlet to unblock the script so it can run in the session. PS C:\> Get-Item C:\ps-test\Start-ActivityTracker.ps1 | Unblock-File</dev:code> <dev:remarks> <maml:para>This command shows how to find and unblock PowerShell scripts.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/unblock-file?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Execution_Policies</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Item</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-File</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>FileSystem Provider</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Unregister-Event</command:name> <command:verb>Unregister</command:verb> <command:noun>Event</command:noun> <maml:description> <maml:para>Cancels an event subscription.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Unregister-Event cmdlet cancels an event subscription that was created by using the Register-EngineEvent, Register-ObjectEvent, or Register-WmiEvent cmdlet.</maml:para> <maml:para>When an event subscription is canceled, the event subscriber is deleted from the session and the subscribed events are no longer added to the event queue. When you cancel a subscription to an event created by using the New-Event cmdlet, the new event is also deleted from the session. Unregister-Event does not delete events from the event queue. To delete events, use the Remove-Event cmdlet.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Unregister-Event</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>SourceIdentifier</maml:name> <maml:Description> <maml:para>Specifies a source identifier that this cmdlet cancels event subscriptions.</maml:para> <maml:para>A SourceIdentifier or SubscriptionId parameter must be included in every command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Cancels all event subscriptions, including subscriptions that were hidden by using the SupportEvent parameter of Register-ObjectEvent , Register-WmiEvent , and Register-EngineEvent .</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Unregister-Event</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>SubscriptionId</maml:name> <maml:Description> <maml:para>Specifies a source identifier ID that this cmdlet cancels event subscriptions.</maml:para> <maml:para>A SourceIdentifier or SubscriptionId parameter must be included in every command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Cancels all event subscriptions, including subscriptions that were hidden by using the SupportEvent parameter of Register-ObjectEvent , Register-WmiEvent , and Register-EngineEvent .</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Cancels all event subscriptions, including subscriptions that were hidden by using the SupportEvent parameter of Register-ObjectEvent , Register-WmiEvent , and Register-EngineEvent .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>SourceIdentifier</maml:name> <maml:Description> <maml:para>Specifies a source identifier that this cmdlet cancels event subscriptions.</maml:para> <maml:para>A SourceIdentifier or SubscriptionId parameter must be included in every command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>SubscriptionId</maml:name> <maml:Description> <maml:para>Specifies a source identifier ID that this cmdlet cancels event subscriptions.</maml:para> <maml:para>A SourceIdentifier or SubscriptionId parameter must be included in every command.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSEventSubscriber</maml:name> </dev:type> <maml:description> <maml:para>You can pipe the output from Get-EventSubscriber to Unregister-Event .</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>This cmdlet does not return any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>* Events, event subscriptions, and the event queue exist only in the current session. If you close the current session, the event queue is discarded and the event subscription is canceled. Unregister-Event cannot delete events created by using the New-Event cmdlet unless you have subscribed to the event by using the Register-EngineEvent cmdlet. To delete a custom event from the session, you must remove it programmatically or close the session.</maml:para> <maml:para>*</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>- Example 1: Cancel an event subscription by source identifier -</maml:title> <dev:code>PS C:\> Unregister-Event -SourceIdentifier "ProcessStarted"</dev:code> <dev:remarks> <maml:para>This command cancels the event subscription that has a source identifier of ProcessStarted.</maml:para> <maml:para>To find the source identifier of an event, use the Get-Event cmdlet. To find the source identifier of an event subscription, use the Get-EventSubscriber cmdlet.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 2: Cancel an event subscription by subscription identifier</maml:title> <dev:code>PS C:\> Unregister-Event -SubscriptionId 2</dev:code> <dev:remarks> <maml:para>This command cancels the event subscription that has a subscription identifier of 2.</maml:para> <maml:para>To find the subscription identifier of an event subscription, use the Get-EventSubscriber cmdlet.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 3: Cancel all event subscriptions ----------</maml:title> <dev:code>PS C:\> Get-EventSubscriber -Force | Unregister-Event -Force</dev:code> <dev:remarks> <maml:para>This command cancels all event subscriptions in the session.</maml:para> <maml:para>The command uses the Get-EventSubscriber cmdlet to get all event subscriber objects in the session, including the subscribers that are hidden by using the SupportEvent parameter of the event registration cmdlets.</maml:para> <maml:para>It uses a pipeline operator (|) to send the subscriber objects to Unregister-Event , which deletes them from the session. To complete the task, the Force parameter is also required on Unregister-Event .</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/unregister-event?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-EventSubscriber</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-EngineEvent</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-ObjectEvent</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Unregister-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Wait-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Update-FormatData</command:name> <command:verb>Update</command:verb> <command:noun>FormatData</command:noun> <maml:description> <maml:para>Updates the formatting data in the current session.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Update-FormatData` cmdlet reloads the formatting data from formatting files into the current session. This cmdlet lets you update the formatting data without restarting PowerShell.</maml:para> <maml:para>Without parameters, `Update-FormatData` reloads the formatting files that it loaded previously. You can use the parameters of `Update-FormatData` to add new formatting files to the session.</maml:para> <maml:para>Formatting files are text files in XML format with the `format.ps1xml` file name extension. The formatting data in the files defines the display of Microsoft .NET Framework objects in the session.</maml:para> <maml:para>When Windows PowerShell starts, it loads the format data from the formatting files in the PowerShell installation directory (`$pshome`) into the session. You can use `Update-FormatData` to reload the formatting data into the current session without restarting PowerShell. This is useful when you have added or changed a formatting file, but do not want to interrupt the session.</maml:para> <maml:para>For more information about formatting files in PowerShell, see about_Format.ps1xml (../Microsoft.PowerShell.Core/About/about_Format.ps1xml.md).</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Update-FormatData</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="PSPath, Path"> <maml:name>AppendPath</maml:name> <maml:Description> <maml:para>Specifies formatting files that this cmdlet adds to the session. The files are loaded after PowerShell loads the built-in formatting files.</maml:para> <maml:para>When formatting .NET objects,Windows PowerShell uses the first formatting definition that it finds for each .NET type. If you use the AppendPath parameter, Windows PowerShell searches the data from the built-in files before it encounters the formatting data that you are adding.</maml:para> <maml:para>Use this parameter to add a file that formats a .NET object that is not referenced in the built-in formatting files.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PrependPath</maml:name> <maml:Description> <maml:para>Specifies formatting files that this cmdlet adds to the session. The files are loaded before PowerShell loads the built-in formatting files.</maml:para> <maml:para>When formatting .NET objects, Windows PowerShell uses the first formatting definition that it finds for each .NET type. If you use the PrependPath parameter, Windows PowerShell searches the data from the files that you are adding before it encounters the formatting data from the built-in files.</maml:para> <maml:para>Use this parameter to add a file that formats a .NET object that is also referenced in the built-in formatting files.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="PSPath, Path"> <maml:name>AppendPath</maml:name> <maml:Description> <maml:para>Specifies formatting files that this cmdlet adds to the session. The files are loaded after PowerShell loads the built-in formatting files.</maml:para> <maml:para>When formatting .NET objects,Windows PowerShell uses the first formatting definition that it finds for each .NET type. If you use the AppendPath parameter, Windows PowerShell searches the data from the built-in files before it encounters the formatting data that you are adding.</maml:para> <maml:para>Use this parameter to add a file that formats a .NET object that is not referenced in the built-in formatting files.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PrependPath</maml:name> <maml:Description> <maml:para>Specifies formatting files that this cmdlet adds to the session. The files are loaded before PowerShell loads the built-in formatting files.</maml:para> <maml:para>When formatting .NET objects, Windows PowerShell uses the first formatting definition that it finds for each .NET type. If you use the PrependPath parameter, Windows PowerShell searches the data from the files that you are adding before it encounters the formatting data from the built-in files.</maml:para> <maml:para>Use this parameter to add a file that formats a .NET object that is also referenced in the built-in formatting files.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a string that contains the append path to `Update-FormatData`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>The cmdlet does not return any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>- `Update-FormatData` also updates the formatting data for commands in the session that were imported from modules. If the formatting file for a module changes, you can run an `Update-FormatData` command to update the formatting data for imported commands. You do not need to import the module again.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>----- Example 1: Reload previously loaded formatting files -----</maml:title> <dev:code>Update-FormatData</dev:code> <dev:remarks> <maml:para>This command reloads the formatting files that it loaded previously.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 2: Reload formatting files and trace and log formatting files</maml:title> <dev:code>Update-FormatData -AppendPath "trace.format.ps1xml, log.format.ps1xml"</dev:code> <dev:remarks> <maml:para>This command reloads the formatting files into the session, including two new files, Trace.format.ps1xml and Log.format.ps1xml.</maml:para> <maml:para>Because the command uses the AppendPath parameter, the formatting data in the new files is loaded after the formatting data from the built-in files.</maml:para> <maml:para>The AppendPath parameter is used because the new files contain formatting data for objects that are not referenced in the built-in files.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 3: Edit a formatting file and reload it -------</maml:title> <dev:code>Update-FormatData -PrependPath "c:\test\NewFiles.format.ps1xml" # Edit the NewFiles.format.ps1 file. Update-FormatData</dev:code> <dev:remarks> <maml:para>This example shows how to reload a formatting file after you have edited it.</maml:para> <maml:para>The first command adds the NewFiles.format.ps1xml file to the session. It uses the PrependPath parameter because the file contains formatting data for objects that are referenced in the built-in files.</maml:para> <maml:para>After adding the NewFiles.format.ps1xml file and testing it in these sessions, the author edits the file.</maml:para> <maml:para>The second command uses the `Update-FormatData` cmdlet to reload the formatting files. Because the NewFiles.format.ps1xml file was previously loaded, `Update-FormatData` automatically reloads it without using parameters.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/update-formatdata?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-FormatData</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Export-FormatData</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Update-List</command:name> <command:verb>Update</command:verb> <command:noun>List</command:noun> <maml:description> <maml:para>Adds items to and removes items from a property value that contains a collection of objects.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Update-List` cmdlet adds, removes, or replaces items in a property value of an object and returns the updated object. This cmdlet is designed for properties that contain collections of objects.</maml:para> <maml:para>The Add and Remove parameters add individual items to and remove them from the collection. The Replace parameter replaces the entire collection.</maml:para> <maml:para>If you do not specify a property in the command, `Update-List` returns an object that describes the update instead of updating the object. You can submit the update object to cmdlets that change objects, such as `Set` cmdlets.</maml:para> <maml:para>This cmdlet works only when the property that is being updated supports the IList interface that `Update-List` uses. Also, any `Set` cmdlets that accept an update must support the IList interface.</maml:para> <maml:para>The core cmdlets that are installed with PowerShell do not support this interface. To determine whether a cmdlet supports `Update-List`, see the cmdlet Help topic.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Update-List</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the property that contains the collection that is being updated. If you omit this parameter, `Update-List` returns an object that represents the change instead of changing the object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Add</maml:name> <maml:Description> <maml:para>Specifies the property values to be added to the collection. Enter the values in the order that they should appear in the collection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be updated. You can also pipe the object to be updated to `Update-List`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Remove</maml:name> <maml:Description> <maml:para>Specifies the property values to be removed from the collection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Update-List</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the property that contains the collection that is being updated. If you omit this parameter, `Update-List` returns an object that represents the change instead of changing the object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be updated. You can also pipe the object to be updated to `Update-List`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Replace</maml:name> <maml:Description> <maml:para>Specifies a new collection. This parameter replaces all items in the original collection with the items specified by this parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Add</maml:name> <maml:Description> <maml:para>Specifies the property values to be added to the collection. Enter the values in the order that they should appear in the collection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to be updated. You can also pipe the object to be updated to `Update-List`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Property</maml:name> <maml:Description> <maml:para>Specifies the property that contains the collection that is being updated. If you omit this parameter, `Update-List` returns an object that represents the change instead of changing the object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Remove</maml:name> <maml:Description> <maml:para>Specifies the property values to be removed from the collection.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Replace</maml:name> <maml:Description> <maml:para>Specifies a new collection. This parameter replaces all items in the original collection with the items specified by this parameter.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object[]</command:parameterValue> <dev:type> <maml:name>System.Object[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe the objects to be updated to `Update-List`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Objects or System.Management.Automation.PSListModifier</maml:name> </dev:type> <maml:description> <maml:para>`Update-List` returns the updated object, or it returns an object that represents the update action.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>----------- Example 1: Add items to a property value -----------</maml:title> <dev:code>class Cards { [System.Collections.Generic.List[string]]$cards [string]$name Cards([string]$_name) { $this.name = $_name $this.cards = [System.Collections.Generic.List[string]]::new() } NewDeck() { $_suits = [char]0x2663,[char]0x2666,[char]0x2665,[char]0x2660 $_values = 'A',2,3,4,5,6,7,8,9,10,'J','Q','K' $_deck = foreach ($s in $_suits){ foreach ($v in $_values){ "$v$s"} } $this | Update-List -Property cards -Add $_deck | Out-Null } Show() { Write-Host Write-Host $this.name ": " $this.cards[0..12] if ($this.cards.count -gt 13) { Write-Host (' ' * ($this.name.length+3)) $this.cards[13..25] } if ($this.cards.count -gt 26) { Write-Host (' ' * ($this.name.length+3)) $this.cards[26..38] } if ($this.cards.count -gt 39) { Write-Host (' ' * ($this.name.length+3)) $this.cards[39..51] } } Shuffle() { $this.cards = Get-Random -InputObject $this.cards -Count 52 } Sort() { $this.cards.Sort() } }</dev:code> <dev:remarks> <maml:para>> [!NOTE] > The `Update-List` cmdlet outputs the updated object to the pipeline. We pipe the output to > `Out-Null` to suppress the unwanted display.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--- Example 2: Add and remove items of a collection property ---</maml:title> <dev:code>$player1 = [Cards]::new('Player 1') $player2 = [Cards]::new('Player 2') $deck = [Cards]::new('Deck') $deck.NewDeck() $deck.Shuffle() $deck.Show() # Deal two hands $player1 | Update-List -Property cards -Add $deck.cards[0,2,4,6,8] | Out-Null $player2 | Update-List -Property cards -Add $deck.cards[1,3,5,7,9] | Out-Null $deck | Update-List -Property cards -Remove $player1.cards | Out-Null $deck | Update-List -Property cards -Remove $player2.cards | Out-Null $player1.Show() $player2.Show() $deck.Show() Deck : 4♦ 7♥ J♦ 5♣ A♣ 8♦ J♣ Q♥ 6♦ 3♦ 9♦ 6♣ 2♣ K♥ 4♠ 10♥ 8♠ 10♦ 9♠ 6♠ K♦ 7♣ 3♣ Q♣ A♥ Q♠ 3♥ 5♥ 2♦ 5♠ J♥ J♠ 10♣ 4♥ Q♦ 10♠ 4♣ 2♠ 2♥ 6♥ 7♦ A♠ 5♦ 8♣ 9♥ K♠ 7♠ 3♠ 9♣ A♦ K♣ 8♥ Player 1 : 4♦ J♦ A♣ J♣ 6♦ Player 2 : 7♥ 5♣ 8♦ Q♥ 3♦ Deck : 9♦ 6♣ 2♣ K♥ 4♠ 10♥ 8♠ 10♦ 9♠ 6♠ K♦ 7♣ 3♣ Q♣ A♥ Q♠ 3♥ 5♥ 2♦ 5♠ J♥ J♠ 10♣ 4♥ Q♦ 10♠ 4♣ 2♠ 2♥ 6♥ 7♦ A♠ 5♦ 8♣ 9♥ K♠ 7♠ 3♠ 9♣ A♦ K♣ 8♥</dev:code> <dev:remarks> <maml:para>The output shows the state of the deck before the cards were dealt to the players. You can see that each player received five cards from the deck. The final output shows the state of the deck after dealing the cards to the players. `Update-List` was used to select the cards from the deck and add them to the players' collection. Then the players' cards were removed from the deck using `Update-List`.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 3: Add and remove items in a single command -----</maml:title> <dev:code># Player 1 wants two new cards - remove 2 cards & add 2 cards $player1 | Update-List -Property cards -Remove $player1.cards[0,4] -Add $deck.cards[0..1] | Out-Null $player1.Show() # remove dealt cards from deck $deck | Update-List -Property cards -Remove $deck.cards[0..1] | Out-Null $deck.Show() Player 1 : J♦ A♣ J♣ 9♦ 6♣ Deck : 2♣ K♥ 4♠ 10♥ 8♠ 10♦ 9♠ 6♠ K♦ 7♣ 3♣ Q♣ A♥ Q♠ 3♥ 5♥ 2♦ 5♠ J♥ J♠ 10♣ 4♥ Q♦ 10♠ 4♣ 2♠ 2♥ 6♥ 7♦ A♠ 5♦ 8♣ 9♥ K♠ 7♠ 3♠ 9♣ A♦ K♣ 8♥</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/update-list?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Format-List</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Select-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Update-TypeData</command:name> <command:verb>Update</command:verb> <command:noun>TypeData</command:noun> <maml:description> <maml:para>Updates the extended type data in the session.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Update-TypeData` cmdlet updates the extended type data in the session by reloading the `Types.ps1xml` files into memory and adding new extended type data.</maml:para> <maml:para>By default, PowerShell loads extended type data as it is needed. Without parameters, `Update-TypeData` reloads all of the `Types.ps1xml` files that it has loaded in the session, including any type files that you added. You can use the parameters of `Update-TypeData` to add new type files and add and replace extended type data.</maml:para> <maml:para>The `Update-TypeData` cmdlet can be used to preload all type data. This feature is particularly useful when you are developing types and want to load those new types for testing purposes.</maml:para> <maml:para>Beginning in Windows PowerShell 3.0, you can use `Update-TypeData` to add and replace extended type data in the session without using a `Types.ps1xml` file. Type data that is added dynamically, that is, without a file, is added only to the current session. To add the type data to all sessions, add an `Update-TypeData` command to your PowerShell profile. For more information, see about_Profiles (../Microsoft.PowerShell.Core/About/about_Profiles.md).</maml:para> <maml:para>Also, beginning in Windows PowerShell 3.0, you can use the `Get-TypeData` cmdlet to get the extended types in the current session and the `Remove-TypeData` cmdlet to delete extended types from the current session.</maml:para> <maml:para>Exceptions that occur in properties, or from adding properties to an `Update-TypeData` command, do not report errors. This is to suppress exceptions that would occur in many common types during formatting and outputting. If you are getting .NET properties, you can work around the suppression of exceptions by using method syntax instead, as shown in the following example:</maml:para> <maml:para>`"hello".get_Length()`</maml:para> <maml:para>Note that method syntax can only be used with .NET properties. Properties that are added by running the `Update-TypeData` cmdlet cannot use method syntax.</maml:para> <maml:para>For more information about the `Types.ps1xml` files in PowerShell, see about_Types.ps1xml (../Microsoft.PowerShell.Core/About/about_Types.ps1xml.md).</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Update-TypeData</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="PSPath, Path"> <maml:name>AppendPath</maml:name> <maml:Description> <maml:para>Specifies the path to optional `.ps1xml` files. The specified files are loaded in the order that they are listed after the built-in files are loaded. You can also pipe an AppendPath value to `Update-TypeData`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PrependPath</maml:name> <maml:Description> <maml:para>Specifies the path to the optional `.ps1xml` files. The specified files are loaded in the order that they are listed before the built-in files are loaded.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Update-TypeData</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DefaultDisplayProperty</maml:name> <maml:Description> <maml:para>Specifies the property of the type that is displayed by the `Format-Wide` cmdlet when no other properties are specified.</maml:para> <maml:para>Type the name of a standard or extended property of the type. The value of this parameter can be the name of a type that is added in the same command.</maml:para> <maml:para>This value is effective only when there are no wide views defined for the type in a `Format.ps1xml` file.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DefaultDisplayPropertySet</maml:name> <maml:Description> <maml:para>Specifies one or more properties of the type. These properties are displayed by the `Format-List` cmdlet when no other properties are specified.</maml:para> <maml:para>Type the names of standard or extended properties of the type. The value of this parameter can be the names of types that are added in the same command.</maml:para> <maml:para>This value is effective only when there are no list views defined for the type in a `Format.ps1xml` file.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DefaultKeyPropertySet</maml:name> <maml:Description> <maml:para>Specifies one or more properties of the type. These properties are used by the `Group-Object` and `Sort-Object` cmdlets when no other properties are specified.</maml:para> <maml:para>Type the names of standard or extended properties of the type. The value of this parameter can be the names of types that are added in the same command.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet uses the specified type data, even if type data has already been specified for that type.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>InheritPropertySerializationSet</maml:name> <maml:Description> <maml:para>Indicates whether the set of properties that are serialized is inherited. The default value is `$Null`. The acceptable values for this parameter are:</maml:para> <maml:para>- `$True`. The property set is inherited.</maml:para> <maml:para>- `$False`. The property set is not inherited.</maml:para> <maml:para>- `$Null`. Inheritance is not defined.</maml:para> <maml:para></maml:para> <maml:para>This parameter is valid only when the value of the SerializationMethod parameter is `SpecificProperties`. When the value of this parameter is `$False`, the PropertySerializationSet parameter is required.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Nullable`1[System.Boolean]</command:parameterValue> <dev:type> <maml:name>System.Nullable`1[System.Boolean]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>MemberName</maml:name> <maml:Description> <maml:para>Specifies the name of a property or method.</maml:para> <maml:para>Use this parameter with the TypeName , MemberType , Value and SecondValue parameters to add or change a property or method of a type.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>MemberType</maml:name> <maml:Description> <maml:para>Specifies the type of the member to add or change.</maml:para> <maml:para>Use this parameter with the TypeName , MemberType , Value and SecondValue parameters to add or change a property or method of a type. The acceptable values for this parameter are:</maml:para> <maml:para>- AliasProperty</maml:para> <maml:para>- CodeMethod</maml:para> <maml:para>- CodeProperty</maml:para> <maml:para>- Noteproperty</maml:para> <maml:para>- ScriptMethod</maml:para> <maml:para>- ScriptProperty</maml:para> <maml:para></maml:para> <maml:para>For information about these values, see PSMemberTypes Enumeration (/dotnet/api/system.management.automation.psmembertypes).</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">NoteProperty</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">AliasProperty</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ScriptProperty</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">CodeProperty</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ScriptMethod</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">CodeMethod</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSMemberTypes</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSMemberTypes</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PropertySerializationSet</maml:name> <maml:Description> <maml:para>Specifies the names of properties that are serialized. Use this parameter when the value of the SerializationMethod parameter is SpecificProperties .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SecondValue</maml:name> <maml:Description> <maml:para>Specifies additional values for AliasProperty , ScriptProperty , CodeProperty , or CodeMethod members.</maml:para> <maml:para>Use this parameter with the TypeName , MemberType , Value , and SecondValue parameters to add or change a property or method of a type.</maml:para> <maml:para>When the value of the MemberType parameter is `AliasProperty`, the value of the SecondValue parameter must be a data type. PowerShell converts (that is, casts) the value of the alias property to the specified type. For example, if you add an alias property that provides an alternate name for a string property, you can also specify a SecondValue of System.Int32 to convert the aliased string value to an integer.</maml:para> <maml:para>When the value of the MemberType parameter is `ScriptProperty`, you can use the SecondValue parameter to specify an additional script block. The script block in the value of the Value parameter gets the value of a variable. The script block in the value of the SecondValue parameter set the value of the variable.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SerializationDepth</maml:name> <maml:Description> <maml:para>Specifies how many levels of type objects are serialized as strings. The default value `1` serializes the object and its properties. A value of `0` serializes the object, but not its properties. A value of `2` serializes the object, its properties, and any objects in property values.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>1</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SerializationMethod</maml:name> <maml:Description> <maml:para>Specifies a serialization method for the type. A serialization method determines which properties of the type are serialized and the technique that is used to serialize them. The acceptable values for this parameter are:</maml:para> <maml:para>- `AllPublicProperties`. Serialize all public properties of the type. You can use the SerializationDepth parameter to determine whether child properties are serialized. - `String`. Serialize the type as a string. You can use the StringSerializationSource to specify a property of the type to use as the serialization result. Otherwise, the type is serialized by using the ToString method of the object. - `SpecificProperties`. Serialize only the specified properties of this type. Use the PropertySerializationSet parameter to specify the properties of the type that are serialized. You can also use the InheritPropertySerializationSet parameter to determine whether the property set is inherited and the SerializationDepth parameter to determine whether child properties are serialized.</maml:para> <maml:para>In PowerShell, serialization methods are stored in PSStandardMembers internal objects.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>StringSerializationSource</maml:name> <maml:Description> <maml:para>Specifies the name of a property of the type. The value of specified property is used as the serialization result. This parameter is valid only when the value of the SerializationMethod parameter is String.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TargetTypeForDeserialization</maml:name> <maml:Description> <maml:para>Specifies the type to which object of this type are converted when they are deserialized.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Type</command:parameterValue> <dev:type> <maml:name>System.Type</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TypeAdapter</maml:name> <maml:Description> <maml:para>Specifies the type of a type adapter, such as Microsoft.PowerShell.Cim.CimInstanceAdapter . A type adapter enables PowerShell to get the members of a type.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Type</command:parameterValue> <dev:type> <maml:name>System.Type</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TypeConverter</maml:name> <maml:Description> <maml:para>Specifies a type converter to convert values between different types. If a type converter is defined for a type, an instance of the type converter is used for the conversion.</maml:para> <maml:para>Enter a System.Type value that is derived from the System.ComponentModel.TypeConverter or System.Management.Automation.PSTypeConverter classes.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Type</command:parameterValue> <dev:type> <maml:name>System.Type</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>TypeName</maml:name> <maml:Description> <maml:para>Specifies the name of the type to extend.</maml:para> <maml:para>For types in the System namespace, enter the short name. Otherwise, the full type name is required. Wildcards are not supported.</maml:para> <maml:para>You can pipe type names to `Update-TypeData`. When you pipe an object to `Update-TypeData`, `Update-TypeData` gets the type name of the object and type data to the object type.</maml:para> <maml:para>Use this parameter with the MemberName , MemberType , Value and SecondValue parameters to add or change a property or method of a type.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Value</maml:name> <maml:Description> <maml:para>Specifies the value of the property or method.</maml:para> <maml:para>If you add an `AliasProperty`, `CodeProperty`, `ScriptProperty`, or `CodeMethod` member, you can use the SecondValue parameter to add additional information.</maml:para> <maml:para>Use this parameter with the MemberName , MemberType , Value and SecondValue parameters to add or change a property or method of a type.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Update-TypeData</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>TypeData</maml:name> <maml:Description> <maml:para>Specifies an array of type data that this cmdlet adds to the session. Enter a variable that contains a TypeData object or a command that gets a TypeData object, such as a `Get-TypeData` command. You can also pipe a TypeData object to `Update-TypeData`.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Runspaces.TypeData[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.TypeData[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet uses the specified type data, even if type data has already been specified for that type.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="PSPath, Path"> <maml:name>AppendPath</maml:name> <maml:Description> <maml:para>Specifies the path to optional `.ps1xml` files. The specified files are loaded in the order that they are listed after the built-in files are loaded. You can also pipe an AppendPath value to `Update-TypeData`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DefaultDisplayProperty</maml:name> <maml:Description> <maml:para>Specifies the property of the type that is displayed by the `Format-Wide` cmdlet when no other properties are specified.</maml:para> <maml:para>Type the name of a standard or extended property of the type. The value of this parameter can be the name of a type that is added in the same command.</maml:para> <maml:para>This value is effective only when there are no wide views defined for the type in a `Format.ps1xml` file.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DefaultDisplayPropertySet</maml:name> <maml:Description> <maml:para>Specifies one or more properties of the type. These properties are displayed by the `Format-List` cmdlet when no other properties are specified.</maml:para> <maml:para>Type the names of standard or extended properties of the type. The value of this parameter can be the names of types that are added in the same command.</maml:para> <maml:para>This value is effective only when there are no list views defined for the type in a `Format.ps1xml` file.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>DefaultKeyPropertySet</maml:name> <maml:Description> <maml:para>Specifies one or more properties of the type. These properties are used by the `Group-Object` and `Sort-Object` cmdlets when no other properties are specified.</maml:para> <maml:para>Type the names of standard or extended properties of the type. The value of this parameter can be the names of types that are added in the same command.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:Description> <maml:para>Indicates that the cmdlet uses the specified type data, even if type data has already been specified for that type.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>InheritPropertySerializationSet</maml:name> <maml:Description> <maml:para>Indicates whether the set of properties that are serialized is inherited. The default value is `$Null`. The acceptable values for this parameter are:</maml:para> <maml:para>- `$True`. The property set is inherited.</maml:para> <maml:para>- `$False`. The property set is not inherited.</maml:para> <maml:para>- `$Null`. Inheritance is not defined.</maml:para> <maml:para></maml:para> <maml:para>This parameter is valid only when the value of the SerializationMethod parameter is `SpecificProperties`. When the value of this parameter is `$False`, the PropertySerializationSet parameter is required.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Nullable`1[System.Boolean]</command:parameterValue> <dev:type> <maml:name>System.Nullable`1[System.Boolean]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>MemberName</maml:name> <maml:Description> <maml:para>Specifies the name of a property or method.</maml:para> <maml:para>Use this parameter with the TypeName , MemberType , Value and SecondValue parameters to add or change a property or method of a type.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>MemberType</maml:name> <maml:Description> <maml:para>Specifies the type of the member to add or change.</maml:para> <maml:para>Use this parameter with the TypeName , MemberType , Value and SecondValue parameters to add or change a property or method of a type. The acceptable values for this parameter are:</maml:para> <maml:para>- AliasProperty</maml:para> <maml:para>- CodeMethod</maml:para> <maml:para>- CodeProperty</maml:para> <maml:para>- Noteproperty</maml:para> <maml:para>- ScriptMethod</maml:para> <maml:para>- ScriptProperty</maml:para> <maml:para></maml:para> <maml:para>For information about these values, see PSMemberTypes Enumeration (/dotnet/api/system.management.automation.psmembertypes).</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSMemberTypes</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSMemberTypes</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PrependPath</maml:name> <maml:Description> <maml:para>Specifies the path to the optional `.ps1xml` files. The specified files are loaded in the order that they are listed before the built-in files are loaded.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PropertySerializationSet</maml:name> <maml:Description> <maml:para>Specifies the names of properties that are serialized. Use this parameter when the value of the SerializationMethod parameter is SpecificProperties .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SecondValue</maml:name> <maml:Description> <maml:para>Specifies additional values for AliasProperty , ScriptProperty , CodeProperty , or CodeMethod members.</maml:para> <maml:para>Use this parameter with the TypeName , MemberType , Value , and SecondValue parameters to add or change a property or method of a type.</maml:para> <maml:para>When the value of the MemberType parameter is `AliasProperty`, the value of the SecondValue parameter must be a data type. PowerShell converts (that is, casts) the value of the alias property to the specified type. For example, if you add an alias property that provides an alternate name for a string property, you can also specify a SecondValue of System.Int32 to convert the aliased string value to an integer.</maml:para> <maml:para>When the value of the MemberType parameter is `ScriptProperty`, you can use the SecondValue parameter to specify an additional script block. The script block in the value of the Value parameter gets the value of a variable. The script block in the value of the SecondValue parameter set the value of the variable.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SerializationDepth</maml:name> <maml:Description> <maml:para>Specifies how many levels of type objects are serialized as strings. The default value `1` serializes the object and its properties. A value of `0` serializes the object, but not its properties. A value of `2` serializes the object, its properties, and any objects in property values.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>1</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SerializationMethod</maml:name> <maml:Description> <maml:para>Specifies a serialization method for the type. A serialization method determines which properties of the type are serialized and the technique that is used to serialize them. The acceptable values for this parameter are:</maml:para> <maml:para>- `AllPublicProperties`. Serialize all public properties of the type. You can use the SerializationDepth parameter to determine whether child properties are serialized. - `String`. Serialize the type as a string. You can use the StringSerializationSource to specify a property of the type to use as the serialization result. Otherwise, the type is serialized by using the ToString method of the object. - `SpecificProperties`. Serialize only the specified properties of this type. Use the PropertySerializationSet parameter to specify the properties of the type that are serialized. You can also use the InheritPropertySerializationSet parameter to determine whether the property set is inherited and the SerializationDepth parameter to determine whether child properties are serialized.</maml:para> <maml:para>In PowerShell, serialization methods are stored in PSStandardMembers internal objects.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>StringSerializationSource</maml:name> <maml:Description> <maml:para>Specifies the name of a property of the type. The value of specified property is used as the serialization result. This parameter is valid only when the value of the SerializationMethod parameter is String.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TargetTypeForDeserialization</maml:name> <maml:Description> <maml:para>Specifies the type to which object of this type are converted when they are deserialized.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Type</command:parameterValue> <dev:type> <maml:name>System.Type</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TypeAdapter</maml:name> <maml:Description> <maml:para>Specifies the type of a type adapter, such as Microsoft.PowerShell.Cim.CimInstanceAdapter . A type adapter enables PowerShell to get the members of a type.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Type</command:parameterValue> <dev:type> <maml:name>System.Type</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TypeConverter</maml:name> <maml:Description> <maml:para>Specifies a type converter to convert values between different types. If a type converter is defined for a type, an instance of the type converter is used for the conversion.</maml:para> <maml:para>Enter a System.Type value that is derived from the System.ComponentModel.TypeConverter or System.Management.Automation.PSTypeConverter classes.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Type</command:parameterValue> <dev:type> <maml:name>System.Type</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none"> <maml:name>TypeData</maml:name> <maml:Description> <maml:para>Specifies an array of type data that this cmdlet adds to the session. Enter a variable that contains a TypeData object or a command that gets a TypeData object, such as a `Get-TypeData` command. You can also pipe a TypeData object to `Update-TypeData`.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.Runspaces.TypeData[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.Runspaces.TypeData[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>TypeName</maml:name> <maml:Description> <maml:para>Specifies the name of the type to extend.</maml:para> <maml:para>For types in the System namespace, enter the short name. Otherwise, the full type name is required. Wildcards are not supported.</maml:para> <maml:para>You can pipe type names to `Update-TypeData`. When you pipe an object to `Update-TypeData`, `Update-TypeData` gets the type name of the object and type data to the object type.</maml:para> <maml:para>Use this parameter with the MemberName , MemberType , Value and SecondValue parameters to add or change a property or method of a type.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Value</maml:name> <maml:Description> <maml:para>Specifies the value of the property or method.</maml:para> <maml:para>If you add an `AliasProperty`, `CodeProperty`, `ScriptProperty`, or `CodeMethod` member, you can use the SecondValue parameter to add additional information.</maml:para> <maml:para>Use this parameter with the MemberName , MemberType , Value and SecondValue parameters to add or change a property or method of a type.</maml:para> <maml:para>This parameter was introduced in Windows PowerShell 3.0.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"> <maml:name>Confirm</maml:name> <maml:Description> <maml:para>Prompts you for confirmation before running the cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <maml:name>WhatIf</maml:name> <maml:Description> <maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a string that contains the values of the AppendPath , TypeName , or TypeData parameters to `Update-TypeData`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>This cmdlet does not return any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------------- Example 1: Update extended types ---------------</maml:title> <dev:code>Update-TypeData</dev:code> <dev:remarks> <maml:para>This command updates the extended type configuration from the `Types.ps1xml` files that have already been used in the session.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------ Example 2: Update types multiple times ------------</maml:title> <dev:code>Update-TypeData -PrependPath TypesA.types.ps1xml, TypesB.types.ps1xml Update-TypeData -PrependPath TypesA.types.ps1xml</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 3: Add a script property to DateTime objects -----</maml:title> <dev:code>Update-TypeData -TypeName "System.DateTime" -MemberType ScriptProperty -MemberName "Quarter" -Value { if ($this.Month -in @(1,2,3)) {"Q1"} elseif ($this.Month -in @(4,5,6)) {"Q2"} elseif ($this.Month -in @(7,8,9)) {"Q3"} else {"Q4"} } (Get-Date).Quarter Q1</dev:code> <dev:remarks> <maml:para>The `Update-TypeData` command uses the TypeName parameter to specify the System.DateTime type, the MemberName parameter to specify a name for the new property, the MemberType property to specify the ScriptProperty type, and the Value parameter to specify the script that determines the annual quarter.</maml:para> <maml:para>The value of the Value property is a script that calculates the current annual quarter. The script block uses the `$this` automatic variable to represent the current instance of the object and the In operator to determine whether the month value appears in each integer array. For more information about the `-in` operator, see about_Comparison_Operators (../Microsoft.PowerShell.Core/about/about_Comparison_Operators.md).</maml:para> <maml:para>The second command gets the new Quarter property of the current date.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 4: Update a type that displays in lists by default --</maml:title> <dev:code>Update-TypeData -TypeName "System.DateTime" -DefaultDisplayPropertySet "DateTime, DayOfYear, Quarter" Get-Date | Format-List Thursday, March 15, 2012 12:00:00 AM DayOfYear : 75 Quarter : Q1</dev:code> <dev:remarks> <maml:para>The first command uses the `Update-TypeData` cmdlet to set the default list properties for the System.DateTime type. The command uses the TypeName parameter to specify the type and the DefaultDisplayPropertySet parameter to specify the default properties for a list. The selected properties include the new Quarter script property that was added in a previous example.</maml:para> <maml:para>The second command uses the `Get-Date` cmdlet to get a System.DateTime object that represents the current date. The command uses a pipeline operator (`|`) to send the DateTime object to the `Format-List` cmdlet. Because the `Format-List` command does not specify the properties to display in the list, PowerShell uses the default values that were established by the `Update-TypeData` command.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 5: Update type data for a piped object --------</maml:title> <dev:code>Get-Module | Update-TypeData -MemberType ScriptProperty -MemberName "SupportsUpdatableHelp" -Value { if ($this.HelpInfoUri) {$True} else {$False} } Get-Module -ListAvailable | Format-Table Name, SupportsUpdatableHelp Name SupportsUpdatableHelp ---- --------------------- Microsoft.PowerShell.Diagnostics True Microsoft.PowerShell.Host True Microsoft.PowerShell.Management True Microsoft.PowerShell.Security True Microsoft.PowerShell.Utility True Microsoft.WSMan.Management True PSDiagnostics False PSScheduledJob True PSWorkflow True ServerManager True TroubleshootingPack False</dev:code> <dev:remarks> <maml:para>This example demonstrates that when you pipe an object to `Update-TypeData`, `Update-TypeData` adds extended type data for the object type.</maml:para> <maml:para>This technique is quicker than using the `Get-Member` cmdlet or the `Get-Type` method to get the object type. However, if you pipe a collection of objects to `Update-TypeData`, it updates the type data of the first object type and then returns an error for all other objects in the collection because the member is already defined on the type.</maml:para> <maml:para>The first command uses the `Get-Module` cmdlet to get the PSScheduledJob module. The command pipes the module object to the `Update-TypeData` cmdlet, which updates the type data for the System.Management.Automation.PSModuleInfo type and the types derived from it, such as the ModuleInfoGrouping type that `Get-Module` returns when you use the ListAvailable parameter in the command.</maml:para> <maml:para>The `Update-TypeData` commands adds the SupportsUpdatableHelp script property to all imported modules. The value of the Value parameter is a script that returns `$True` if the HelpInfoUri property of the module is populated and `$False` otherwise.</maml:para> <maml:para>The second command pipes the module objects from `Get-Module` to the `Format-Table` cmdlet, which displays the Name and SupportsUpdatableHelp properties of all modules in a list.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/update-typedata?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Types.ps1xml</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-TypeData</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-TypeData</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Wait-Debugger</command:name> <command:verb>Wait</command:verb> <command:noun>Debugger</command:noun> <maml:description> <maml:para>Stops a script in the debugger before running the next statement in the script.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>Stops the PowerShell script execution engine at the point immediately after the `Wait-Debugger` cmdlet and waits for a debugger to be attached. This is similar to using `Enable-RunspaceDebug -BreakAll` in a DSC resource but breaks at a specific point in the script.</maml:para> <maml:para>> [!CAUTION] > Make sure you remove the `Wait-Debugger` lines after you are done. A running script appears to be > hung when it is stopped at a `Wait-Debugger`.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Wait-Debugger</maml:name> </command:syntaxItem> </command:syntax> <command:parameters /> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para></maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para></maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>---------- Example 1: Insert breakpoint for debugging ----------</maml:title> <dev:code>[DscResource()] class FileResource { [DscProperty(Key)] [string] $Path [DscProperty(Mandatory)] [Ensure] $Ensure [DscProperty(Mandatory)] [string] $SourcePath [DscProperty(NotConfigurable)] [Nullable[datetime]] $CreationTime [void] Set() { $fileExists = $this.TestFilePath($this.Path) if ($this.ensure -eq [Ensure]::Present) { if (! $fileExists) { $this.CopyFile() } } else { if ($fileExists) { Write-Verbose -Message "Deleting the file $($this.Path)" Remove-Item -LiteralPath $this.Path -Force } } } [bool] Test() { $present = Test-Path -LiteralPath $this.Path if ($this.Ensure -eq [Ensure]::Present) { return $present } else { return (! $present) } } [FileResource] Get() { $present = Test-Path -Path $this.Path if ($present) { $file = Get-ChildItem -LiteralPath $this.Path $this.CreationTime = $file.CreationTime $this.Ensure = [Ensure]::Present } else { $this.CreationTime = $null $this.Ensure = [Ensure]::Absent } return $this } [void] CopyFile() { # Testing only - Remove before deployment! Wait-Debugger if (! (Test-Path -LiteralPath $this.SourcePath)) { throw "SourcePath $($this.SourcePath) is not found." } if (Test-Path -LiteralPath $this.Path -PathType Container) { throw "Path $($this.Path) is a directory path" } Write-Verbose "Copying $($this.SourcePath) to $($this.Path)" Copy-Item -LiteralPath $this.SourcePath -Destination $this.Path -Force } }</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/wait-debugger?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Enable-DscDebug</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Wait-Event</command:name> <command:verb>Wait</command:verb> <command:noun>Event</command:noun> <maml:description> <maml:para>Waits until a particular event is raised before continuing to run.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Wait-Event` cmdlet suspends execution of a script or function until a particular event is raised. Execution resumes when the event is detected. To cancel the wait, press <kbd>CTRL</kbd>+<kbd>C</kbd>.</maml:para> <maml:para>This feature provides an alternative to polling for an event. It also allows you to determine the response to an event in two different ways:</maml:para> <maml:para>- using the Action parameter of the event subscription - waiting for an event to return and then respond with an action</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Wait-Event</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>SourceIdentifier</maml:name> <maml:Description> <maml:para>Specifies the source identifier that this cmdlet waits for events. By default, `Wait-Event` waits for any event.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="TimeoutSec"> <maml:name>Timeout</maml:name> <maml:Description> <maml:para>Specifies the maximum time, in seconds, that `Wait-Event` waits for the event to occur. The default, -1, waits indefinitely. The timing starts when you submit the `Wait-Event` command.</maml:para> <maml:para>If the specified time is exceeded, the wait ends and the command prompt returns, even if the event has not been raised. No error message is displayed.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>-1</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="0" aliases="none"> <maml:name>SourceIdentifier</maml:name> <maml:Description> <maml:para>Specifies the source identifier that this cmdlet waits for events. By default, `Wait-Event` waits for any event.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="TimeoutSec"> <maml:name>Timeout</maml:name> <maml:Description> <maml:para>Specifies the maximum time, in seconds, that `Wait-Event` waits for the event to occur. The default, -1, waits indefinitely. The timing starts when you submit the `Wait-Event` command.</maml:para> <maml:para>If the specified time is exceeded, the wait ends and the command prompt returns, even if the event has not been raised. No error message is displayed.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>-1</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para></maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.PSEventArgs</maml:name> </dev:type> <maml:description> <maml:para></maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>Events, event subscriptions, and the event queue exist only in the current session. If you close the current session, the event queue is discarded and the event subscription is canceled.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------- Example 1: Wait for the next event --------------</maml:title> <dev:code>Wait-Event</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 2: Wait for an event with a specified source identifier</maml:title> <dev:code>Wait-Event -SourceIdentifier "ProcessStarted"</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 3: Wait for a timer elapsed event ----------</maml:title> <dev:code>$Timer = New-Object Timers.Timer $objectEventArgs = @{ InputObject = $Timer EventName = 'Elapsed' SourceIdentifier = 'Timer.Elapsed' } Register-ObjectEvent @objectEventArgs $Timer.Interval = 2000 $Timer.Autoreset = $False $Timer.Enabled = $True Wait-Event Timer.Elapsed ComputerName : RunspaceId : bb560b14-ff43-48d4-b801-5adc31bbc6fb EventIdentifier : 1 Sender : System.Timers.Timer SourceEventArgs : System.Timers.ElapsedEventArgs SourceArgs : {System.Timers.Timer, System.Timers.ElapsedEventArgs} SourceIdentifier : Timer.Elapsed TimeGenerated : 4/23/2020 2:30:37 PM MessageData :</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 4: Wait for an event after a specified timeout ----</maml:title> <dev:code>Wait-Event -SourceIdentifier "ProcessStarted" -Timeout 90</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/wait-event?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-EventSubscriber</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-EngineEvent</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-ObjectEvent</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Unregister-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Wait-Event</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Write-Debug</command:name> <command:verb>Write</command:verb> <command:noun>Debug</command:noun> <maml:description> <maml:para>Writes a debug message to the console.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Write-Debug` cmdlet writes debug messages to the console from a script or command.</maml:para> <maml:para>By default, debug messages are not displayed in the console, but you can display them by using the Debug parameter or the `$DebugPreference` variable.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Write-Debug</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="Msg"> <maml:name>Message</maml:name> <maml:Description> <maml:para>Specifies the debug message to send to the console.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="Msg"> <maml:name>Message</maml:name> <maml:Description> <maml:para>Specifies the debug message to send to the console.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a string that contains a debug message to `Write-Debug`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>`Write-Debug` only writes to the debug stream. It does not return any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------------ Example 1: Understand $DebugPreference ------------</maml:title> <dev:code>Write-Debug "Cannot open file."</dev:code> <dev:remarks> <maml:para>The default value of `$DebugPreference` is SilentlyContinue . Therefore, the message is not displayed in the console.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 2: Change the value of $DebugPreference -------</maml:title> <dev:code>PS> $DebugPreference SilentlyContinue PS> Write-Debug "Cannot open file." PS> PS> $DebugPreference = "Continue" PS> Write-Debug "Cannot open file." DEBUG: Cannot open file.</dev:code> <dev:remarks> <maml:para>For more information about `$DebugPreference`, see about_Preference_Variables (../Microsoft.PowerShell.Core/About/about_Preference_Variables.md).</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 3: Use the Debug parameter to override $DebugPreference</maml:title> <dev:code>function Test-Debug { [CmdletBinding()] param() Write-Debug ('$DebugPreference is ' + $DebugPreference) Write-Host ('$DebugPreference is ' + $DebugPreference) } PS> Test-Debug $DebugPreference is SilentlyContinue PS> Test-Debug -Debug DEBUG: $DebugPreference is Inquire Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [?] Help (default is "Y"): $DebugPreference is Inquire PS> $DebugPreference SilentlyContinue</dev:code> <dev:remarks> <maml:para>Notice that the value of `$DebugPreference` changes when you use the Debug parameter. This change only affects the scope of the function. The value is not affected outside the function.</maml:para> <maml:para>> [!NOTE] > When the value of `$DebugPreference` is Inquire , PowerShell halts execution to ask if > execution should continue.</maml:para> <maml:para>For more information about the Debug common parameter, see about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/write-debug?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Error</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Output</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Progress</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Verbose</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Warning</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Write-Error</command:name> <command:verb>Write</command:verb> <command:noun>Error</command:noun> <maml:description> <maml:para>Writes an object to the error stream.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Write-Error` cmdlet declares a non-terminating error. By default, errors are sent in the error stream to the host program to be displayed, along with output.</maml:para> <maml:para>To write a non-terminating error, enter an error message string, an ErrorRecord object, or an Exception object. Use the other parameters of `Write-Error` to populate the error record.</maml:para> <maml:para>Non-terminating errors write an error to the error stream, but they do not stop command processing. If a non-terminating error is declared on one item in a collection of input items, the command continues to process the other items in the collection.</maml:para> <maml:para>To declare a terminating error, use the `Throw` keyword. For more information, see about_Throw (../Microsoft.PowerShell.Core/About/about_Throw.md).</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Write-Error</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="Msg"> <maml:name>Message</maml:name> <maml:Description> <maml:para>Specifies the message text of the error. If the text includes spaces or special characters, enclose it in quotation marks. You can also pipe a message string to `Write-Error`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Category</maml:name> <maml:Description> <maml:para>Specifies the category of the error. The default value is NotSpecified . The acceptable values for this parameter are:</maml:para> <maml:para>- NotSpecified</maml:para> <maml:para>- OpenError</maml:para> <maml:para>- CloseError</maml:para> <maml:para>- DeviceError</maml:para> <maml:para>- DeadlockDetected</maml:para> <maml:para>- InvalidArgument</maml:para> <maml:para>- InvalidData</maml:para> <maml:para>- InvalidOperation</maml:para> <maml:para>- InvalidResult</maml:para> <maml:para>- InvalidType</maml:para> <maml:para>- MetadataError</maml:para> <maml:para>- NotImplemented</maml:para> <maml:para>- NotInstalled</maml:para> <maml:para>- ObjectNotFound</maml:para> <maml:para>- OperationStopped</maml:para> <maml:para>- OperationTimeout</maml:para> <maml:para>- SyntaxError</maml:para> <maml:para>- ParserError</maml:para> <maml:para>- PermissionDenied</maml:para> <maml:para>- ResourceBusy</maml:para> <maml:para>- ResourceExists</maml:para> <maml:para>- ResourceUnavailable</maml:para> <maml:para>- ReadError</maml:para> <maml:para>- WriteError</maml:para> <maml:para>- FromStdErr</maml:para> <maml:para>- SecurityError</maml:para> <maml:para>- ProtocolError</maml:para> <maml:para>- ConnectionError</maml:para> <maml:para>- AuthenticationError</maml:para> <maml:para>- LimitsExceeded</maml:para> <maml:para>- QuotaExceeded</maml:para> <maml:para>- NotEnabled</maml:para> <maml:para></maml:para> <maml:para>For information about the error categories, see ErrorCategory Enumeration (https://go.microsoft.com/fwlink/?LinkId=143600).</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">NotSpecified</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OpenError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">CloseError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DeviceError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DeadlockDetected</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">InvalidArgument</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">InvalidData</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">InvalidOperation</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">InvalidResult</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">InvalidType</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">MetadataError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">NotImplemented</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">NotInstalled</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ObjectNotFound</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OperationStopped</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OperationTimeout</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">SyntaxError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ParserError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">PermissionDenied</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ResourceBusy</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ResourceExists</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ResourceUnavailable</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ReadError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">WriteError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">FromStdErr</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">SecurityError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ProtocolError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ConnectionError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">AuthenticationError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">LimitsExceeded</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">QuotaExceeded</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">NotEnabled</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ErrorCategory</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ErrorCategory</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>NotSpecified</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Activity"> <maml:name>CategoryActivity</maml:name> <maml:Description> <maml:para>Specifies the action that caused the error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Reason"> <maml:name>CategoryReason</maml:name> <maml:Description> <maml:para>Specifies how or why the activity caused the error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="TargetName"> <maml:name>CategoryTargetName</maml:name> <maml:Description> <maml:para>Specifies the name of the object that was being processed when the error occurred.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="TargetType"> <maml:name>CategoryTargetType</maml:name> <maml:Description> <maml:para>Specifies the type of the object that was being processed when the error occurred.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ErrorId</maml:name> <maml:Description> <maml:para>Specifies an ID string to identify the error. The string should be unique to the error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>RecommendedAction</maml:name> <maml:Description> <maml:para>Specifies the action that the user should take to resolve or prevent the error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TargetObject</maml:name> <maml:Description> <maml:para>Specifies the object that was being processed when the error occurred. Enter the object, a variable that contains the object, or a command that gets the object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Write-Error</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="Msg"> <maml:name>Message</maml:name> <maml:Description> <maml:para>Specifies the message text of the error. If the text includes spaces or special characters, enclose it in quotation marks. You can also pipe a message string to `Write-Error`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Category</maml:name> <maml:Description> <maml:para>Specifies the category of the error. The default value is NotSpecified . The acceptable values for this parameter are:</maml:para> <maml:para>- NotSpecified</maml:para> <maml:para>- OpenError</maml:para> <maml:para>- CloseError</maml:para> <maml:para>- DeviceError</maml:para> <maml:para>- DeadlockDetected</maml:para> <maml:para>- InvalidArgument</maml:para> <maml:para>- InvalidData</maml:para> <maml:para>- InvalidOperation</maml:para> <maml:para>- InvalidResult</maml:para> <maml:para>- InvalidType</maml:para> <maml:para>- MetadataError</maml:para> <maml:para>- NotImplemented</maml:para> <maml:para>- NotInstalled</maml:para> <maml:para>- ObjectNotFound</maml:para> <maml:para>- OperationStopped</maml:para> <maml:para>- OperationTimeout</maml:para> <maml:para>- SyntaxError</maml:para> <maml:para>- ParserError</maml:para> <maml:para>- PermissionDenied</maml:para> <maml:para>- ResourceBusy</maml:para> <maml:para>- ResourceExists</maml:para> <maml:para>- ResourceUnavailable</maml:para> <maml:para>- ReadError</maml:para> <maml:para>- WriteError</maml:para> <maml:para>- FromStdErr</maml:para> <maml:para>- SecurityError</maml:para> <maml:para>- ProtocolError</maml:para> <maml:para>- ConnectionError</maml:para> <maml:para>- AuthenticationError</maml:para> <maml:para>- LimitsExceeded</maml:para> <maml:para>- QuotaExceeded</maml:para> <maml:para>- NotEnabled</maml:para> <maml:para></maml:para> <maml:para>For information about the error categories, see ErrorCategory Enumeration (https://go.microsoft.com/fwlink/?LinkId=143600).</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">NotSpecified</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OpenError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">CloseError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DeviceError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DeadlockDetected</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">InvalidArgument</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">InvalidData</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">InvalidOperation</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">InvalidResult</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">InvalidType</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">MetadataError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">NotImplemented</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">NotInstalled</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ObjectNotFound</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OperationStopped</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">OperationTimeout</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">SyntaxError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ParserError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">PermissionDenied</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ResourceBusy</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ResourceExists</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ResourceUnavailable</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ReadError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">WriteError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">FromStdErr</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">SecurityError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ProtocolError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">ConnectionError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">AuthenticationError</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">LimitsExceeded</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">QuotaExceeded</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">NotEnabled</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ErrorCategory</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ErrorCategory</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>NotSpecified</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Activity"> <maml:name>CategoryActivity</maml:name> <maml:Description> <maml:para>Specifies the action that caused the error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Reason"> <maml:name>CategoryReason</maml:name> <maml:Description> <maml:para>Specifies how or why the activity caused the error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="TargetName"> <maml:name>CategoryTargetName</maml:name> <maml:Description> <maml:para>Specifies the name of the object that was being processed when the error occurred.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="TargetType"> <maml:name>CategoryTargetType</maml:name> <maml:Description> <maml:para>Specifies the type of the object that was being processed when the error occurred.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ErrorId</maml:name> <maml:Description> <maml:para>Specifies an ID string to identify the error. The string should be unique to the error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Exception</maml:name> <maml:Description> <maml:para>Specifies an exception object that represents the error. Use the properties of the object to describe the error.</maml:para> <maml:para>To create an exception object, use a hash table or use the `New-Object` cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Exception</command:parameterValue> <dev:type> <maml:name>System.Exception</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>RecommendedAction</maml:name> <maml:Description> <maml:para>Specifies the action that the user should take to resolve or prevent the error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TargetObject</maml:name> <maml:Description> <maml:para>Specifies the object that was being processed when the error occurred. Enter the object, a variable that contains the object, or a command that gets the object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Write-Error</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Activity"> <maml:name>CategoryActivity</maml:name> <maml:Description> <maml:para>Specifies the action that caused the error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Reason"> <maml:name>CategoryReason</maml:name> <maml:Description> <maml:para>Specifies how or why the activity caused the error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="TargetName"> <maml:name>CategoryTargetName</maml:name> <maml:Description> <maml:para>Specifies the name of the object that was being processed when the error occurred.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="TargetType"> <maml:name>CategoryTargetType</maml:name> <maml:Description> <maml:para>Specifies the type of the object that was being processed when the error occurred.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ErrorRecord</maml:name> <maml:Description> <maml:para>Specifies an error record object that represents the error. Use the properties of the object to describe the error.</maml:para> <maml:para>To create an error record object, use the `New-Object` cmdlet or get an error record object from the array in the `$Error` automatic variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ErrorRecord</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ErrorRecord</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>RecommendedAction</maml:name> <maml:Description> <maml:para>Specifies the action that the user should take to resolve or prevent the error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Category</maml:name> <maml:Description> <maml:para>Specifies the category of the error. The default value is NotSpecified . The acceptable values for this parameter are:</maml:para> <maml:para>- NotSpecified</maml:para> <maml:para>- OpenError</maml:para> <maml:para>- CloseError</maml:para> <maml:para>- DeviceError</maml:para> <maml:para>- DeadlockDetected</maml:para> <maml:para>- InvalidArgument</maml:para> <maml:para>- InvalidData</maml:para> <maml:para>- InvalidOperation</maml:para> <maml:para>- InvalidResult</maml:para> <maml:para>- InvalidType</maml:para> <maml:para>- MetadataError</maml:para> <maml:para>- NotImplemented</maml:para> <maml:para>- NotInstalled</maml:para> <maml:para>- ObjectNotFound</maml:para> <maml:para>- OperationStopped</maml:para> <maml:para>- OperationTimeout</maml:para> <maml:para>- SyntaxError</maml:para> <maml:para>- ParserError</maml:para> <maml:para>- PermissionDenied</maml:para> <maml:para>- ResourceBusy</maml:para> <maml:para>- ResourceExists</maml:para> <maml:para>- ResourceUnavailable</maml:para> <maml:para>- ReadError</maml:para> <maml:para>- WriteError</maml:para> <maml:para>- FromStdErr</maml:para> <maml:para>- SecurityError</maml:para> <maml:para>- ProtocolError</maml:para> <maml:para>- ConnectionError</maml:para> <maml:para>- AuthenticationError</maml:para> <maml:para>- LimitsExceeded</maml:para> <maml:para>- QuotaExceeded</maml:para> <maml:para>- NotEnabled</maml:para> <maml:para></maml:para> <maml:para>For information about the error categories, see ErrorCategory Enumeration (https://go.microsoft.com/fwlink/?LinkId=143600).</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ErrorCategory</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ErrorCategory</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>NotSpecified</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Activity"> <maml:name>CategoryActivity</maml:name> <maml:Description> <maml:para>Specifies the action that caused the error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Reason"> <maml:name>CategoryReason</maml:name> <maml:Description> <maml:para>Specifies how or why the activity caused the error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="TargetName"> <maml:name>CategoryTargetName</maml:name> <maml:Description> <maml:para>Specifies the name of the object that was being processed when the error occurred.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="TargetType"> <maml:name>CategoryTargetType</maml:name> <maml:Description> <maml:para>Specifies the type of the object that was being processed when the error occurred.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ErrorId</maml:name> <maml:Description> <maml:para>Specifies an ID string to identify the error. The string should be unique to the error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ErrorRecord</maml:name> <maml:Description> <maml:para>Specifies an error record object that represents the error. Use the properties of the object to describe the error.</maml:para> <maml:para>To create an error record object, use the `New-Object` cmdlet or get an error record object from the array in the `$Error` automatic variable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.ErrorRecord</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.ErrorRecord</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Exception</maml:name> <maml:Description> <maml:para>Specifies an exception object that represents the error. Use the properties of the object to describe the error.</maml:para> <maml:para>To create an exception object, use a hash table or use the `New-Object` cmdlet.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Exception</command:parameterValue> <dev:type> <maml:name>System.Exception</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="Msg"> <maml:name>Message</maml:name> <maml:Description> <maml:para>Specifies the message text of the error. If the text includes spaces or special characters, enclose it in quotation marks. You can also pipe a message string to `Write-Error`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>RecommendedAction</maml:name> <maml:Description> <maml:para>Specifies the action that the user should take to resolve or prevent the error.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>TargetObject</maml:name> <maml:Description> <maml:para>Specifies the object that was being processed when the error occurred. Enter the object, a variable that contains the object, or a command that gets the object.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a string that contains an error message to `Write-Error`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Error object</maml:name> </dev:type> <maml:description> <maml:para>`Write-Error` writes only to the error stream. It does not return any objects.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>`Write-Error` does not change the value of the `$?` automatic variable, therefore it does not signal a terminating error condition. To signal a terminating error, use the $PSCmdlet.WriteError() (/dotnet/api/system.management.automation.cmdlet.writeerror)method.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>------- Example 1: Write an error for RegistryKey object -------</maml:title> <dev:code>Get-ChildItem | ForEach-Object { if ($_.GetType().ToString() -eq "Microsoft.Win32.RegistryKey") { Write-Error "Invalid object" -ErrorId B1 -TargetObject $_ } else { $_ } }</dev:code> <dev:remarks> <maml:para>This command declares a non-terminating error when the `Get-ChildItem` cmdlet returns a `Microsoft.Win32.RegistryKey` object, such as the objects in the `HKLM:` or `HKCU:` drives of the PowerShell Registry provider.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 2: Write an error message to the console -------</maml:title> <dev:code>Write-Error "Access denied."</dev:code> <dev:remarks> <maml:para>This command declares a non-terminating error and writes an "Access denied" error. The command uses the Message parameter to specify the message, but omits the optional Message parameter name.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 3: Write an error to the console and specify the category</maml:title> <dev:code>Write-Error -Message "Error: Too many input values." -Category InvalidArgument</dev:code> <dev:remarks> <maml:para>This command declares a non-terminating error and specifies an error category.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 4: Write an error using an Exception object -----</maml:title> <dev:code>$E = [System.Exception]@{Source="Get-ParameterNames.ps1";HelpLink="https://go.microsoft.com/fwlink/?LinkID=113425"} Write-Error -Exception $E -Message "Files not found. The $Files location does not contain any XML files."</dev:code> <dev:remarks> <maml:para>This command uses an Exception object to declare a non-terminating error.</maml:para> <maml:para>The first command uses a hash table to create the System.Exception object. It saves the exception object in the `$E` variable. You can use a hash table to create any object of a type that has a null constructor.</maml:para> <maml:para>The second command uses the `Write-Error` cmdlet to declare a non-terminating error. The value of the Exception parameter is the Exception object in the `$E` variable.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/write-error?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Automatic_Variables</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Debug</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Output</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Progress</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Verbose</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Warning</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Write-Host</command:name> <command:verb>Write</command:verb> <command:noun>Host</command:noun> <maml:description> <maml:para>Writes customized output to a host.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Write-Host` cmdlet customizes output. You can specify the color of text by using the `ForegroundColor` parameter, and you can specify the background color by using the `BackgroundColor` parameter. The Separator parameter lets you specify a string to use to separate displayed objects. The particular result depends on the program that is hosting PowerShell.</maml:para> <maml:para>> [!NOTE] > Starting in Windows PowerShell 5.0, `Write-Host` is a wrapper for `Write-Information` > This allows you to use `Write-Host` to emit output to the information stream. > This enables the capture or suppression of data written using `Write-Host` while preserving backwards compatibility. > > The `$InformationPreference` preference variable and `InformationAction` common parameter do not affect `Write-Host` messages. > The exception to this rule is `-InformationAction Ignore`, which effectively suppresses `Write-Host` output. (see "Example 5")</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Write-Host</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Object</maml:name> <maml:Description> <maml:para>Objects to display in the host.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>BackgroundColor</maml:name> <maml:Description> <maml:para>Specifies the background color. There is no default. The acceptable values for this parameter are:</maml:para> <maml:para>- Black</maml:para> <maml:para>- DarkBlue</maml:para> <maml:para>- DarkGreen</maml:para> <maml:para>- DarkCyan</maml:para> <maml:para>- DarkRed</maml:para> <maml:para>- DarkMagenta</maml:para> <maml:para>- DarkYellow</maml:para> <maml:para>- Gray</maml:para> <maml:para>- DarkGray</maml:para> <maml:para>- Blue</maml:para> <maml:para>- Green</maml:para> <maml:para>- Cyan</maml:para> <maml:para>- Red</maml:para> <maml:para>- Magenta</maml:para> <maml:para>- Yellow</maml:para> <maml:para>- White</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Black</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DarkBlue</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DarkGreen</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DarkCyan</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DarkRed</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DarkMagenta</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DarkYellow</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Gray</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DarkGray</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Blue</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Green</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Cyan</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Red</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Magenta</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Yellow</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">White</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.ConsoleColor</command:parameterValue> <dev:type> <maml:name>System.ConsoleColor</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ForegroundColor</maml:name> <maml:Description> <maml:para>Specifies the text color. There is no default. The acceptable values for this parameter are:</maml:para> <maml:para>- Black</maml:para> <maml:para>- DarkBlue</maml:para> <maml:para>- DarkGreen</maml:para> <maml:para>- DarkCyan</maml:para> <maml:para>- DarkRed</maml:para> <maml:para>- DarkMagenta</maml:para> <maml:para>- DarkYellow</maml:para> <maml:para>- Gray</maml:para> <maml:para>- DarkGray</maml:para> <maml:para>- Blue</maml:para> <maml:para>- Green</maml:para> <maml:para>- Cyan</maml:para> <maml:para>- Red</maml:para> <maml:para>- Magenta</maml:para> <maml:para>- Yellow</maml:para> <maml:para>- White</maml:para> </maml:Description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Black</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DarkBlue</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DarkGreen</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DarkCyan</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DarkRed</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DarkMagenta</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DarkYellow</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Gray</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">DarkGray</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Blue</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Green</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Cyan</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Red</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Magenta</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Yellow</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">White</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">System.ConsoleColor</command:parameterValue> <dev:type> <maml:name>System.ConsoleColor</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NoNewline</maml:name> <maml:Description> <maml:para>The string representations of the input objects are concatenated to form the output. No spaces or newlines are inserted between the output strings. No newline is added after the last output string.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Separator</maml:name> <maml:Description> <maml:para>Specifies a separator string to insert between objects displayed by the host.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>BackgroundColor</maml:name> <maml:Description> <maml:para>Specifies the background color. There is no default. The acceptable values for this parameter are:</maml:para> <maml:para>- Black</maml:para> <maml:para>- DarkBlue</maml:para> <maml:para>- DarkGreen</maml:para> <maml:para>- DarkCyan</maml:para> <maml:para>- DarkRed</maml:para> <maml:para>- DarkMagenta</maml:para> <maml:para>- DarkYellow</maml:para> <maml:para>- Gray</maml:para> <maml:para>- DarkGray</maml:para> <maml:para>- Blue</maml:para> <maml:para>- Green</maml:para> <maml:para>- Cyan</maml:para> <maml:para>- Red</maml:para> <maml:para>- Magenta</maml:para> <maml:para>- Yellow</maml:para> <maml:para>- White</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.ConsoleColor</command:parameterValue> <dev:type> <maml:name>System.ConsoleColor</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ForegroundColor</maml:name> <maml:Description> <maml:para>Specifies the text color. There is no default. The acceptable values for this parameter are:</maml:para> <maml:para>- Black</maml:para> <maml:para>- DarkBlue</maml:para> <maml:para>- DarkGreen</maml:para> <maml:para>- DarkCyan</maml:para> <maml:para>- DarkRed</maml:para> <maml:para>- DarkMagenta</maml:para> <maml:para>- DarkYellow</maml:para> <maml:para>- Gray</maml:para> <maml:para>- DarkGray</maml:para> <maml:para>- Blue</maml:para> <maml:para>- Green</maml:para> <maml:para>- Cyan</maml:para> <maml:para>- Red</maml:para> <maml:para>- Magenta</maml:para> <maml:para>- Yellow</maml:para> <maml:para>- White</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.ConsoleColor</command:parameterValue> <dev:type> <maml:name>System.ConsoleColor</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NoNewline</maml:name> <maml:Description> <maml:para>The string representations of the input objects are concatenated to form the output. No spaces or newlines are inserted between the output strings. No newline is added after the last output string.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Object</maml:name> <maml:Description> <maml:para>Objects to display in the host.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Separator</maml:name> <maml:Description> <maml:para>Specifies a separator string to insert between objects displayed by the host.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Object</maml:name> </dev:type> <maml:description> <maml:para>You can pipe objects to be written to the host.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>`Write-Host` sends the objects to the host. It does not return any objects. However, the host might display the objects that `Write-Host` sends to it.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-- Example 1: Write to the console without adding a new line --</maml:title> <dev:code>Write-Host "no newline test " -NoNewline Write-Host "second string" no newline test second string</dev:code> <dev:remarks> <maml:para>This command displays the string 'no newline test' with the `NoNewline` parameter.</maml:para> <maml:para>A second string is written, but it ends up on the same line as the first due to the absence of a newline separating the strings.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--- Example 2: Write to the console and include a separator ---</maml:title> <dev:code>Write-Host (2,4,6,8,10,12) -Separator ", +2= " 2, +2= 4, +2= 6, +2= 8, +2= 10, +2= 12</dev:code> <dev:remarks> <maml:para>This command displays the even numbers from two through twelve. The Separator parameter is used to add the string `, +2= (comma, space, +, 2, =, space)`.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 3: Write with different text and background colors --</maml:title> <dev:code>Write-Host (2,4,6,8,10,12) -Separator ", -> " -ForegroundColor DarkGreen -BackgroundColor White 2, -> 4, -> 6, -> 8, -> 10, -> 12</dev:code> <dev:remarks> <maml:para>This command displays the even numbers from two through twelve. It uses the `ForegroundColor` parameter to output 'dark green' text and the `BackgroundColor` parameter to display a 'white' background.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-- Example 4: Write with different text and background colors --</maml:title> <dev:code>Write-Host "Red on white text." -ForegroundColor red -BackgroundColor white Red on white text.</dev:code> <dev:remarks> <maml:para>This command displays the string "Red on white text." The text is 'red', as defined by the `ForegroundColor` parameter. The background is 'white', as defined by the `BackgroundColor` parameter.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 5: Suppress output from Write-Host ----------</maml:title> <dev:code># The following two statements can be used to effectively suppress output from Write-Host Write-Host "I won't print" -InformationAction Ignore Write-Host "I won't print" 6>$null </dev:code> <dev:remarks> <maml:para>These commands effectively suppress output of the Write-Host cmdlet. The first one uses the InformationAction parameter with the Ignore Value to suppress output to the information stream. The second example redirects the information stream of the command to the $null variable and thereby suppresses it.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/write-host?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Clear-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Out-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Debug</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Error</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Output</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Progress</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Verbose</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Warning</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Write-Information</command:name> <command:verb>Write</command:verb> <command:noun>Information</command:noun> <maml:description> <maml:para>Specifies how Windows PowerShell handles information stream data for a command.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Write-Information` cmdlet specifies how Windows PowerShell handles information stream data for a command.</maml:para> <maml:para>Windows PowerShell 5.0 introduces a new, structured information stream (number 6 in Windows PowerShell streams) that you can use to transmit structured data between a script and its callers (or hosting environment). `Write-Information` lets you add an informational message to the stream, and specify how Windows PowerShell handles information stream data for a command. Information streams also work for `PowerShell.Streams`, jobs, scheduled jobs, and workflows.</maml:para> <maml:para>> [!NOTE] > The information stream does not follow the standard convention of prefixing its messages with "[Stream Name]:". This was intended for brevity and visual cleanliness.</maml:para> <maml:para>The `$InformationPreference` preference variable value determines whether the message you provide to `Write-Information` is displayed at the expected point in a script's operation. Because the default value of this variable is `SilentlyContinue`, by default, informational messages are not shown. If you don't want to change the value of `$InformationPreference`, you can override its value by adding the `InformationAction` common parameter to your command. For more information, see about_Preference_Variables (../Microsoft.PowerShell.Core/About/about_Preference_Variables.md) and [about_CommonParameters](../Microsoft.PowerShell.Core/About/about_CommonParameters.md).</maml:para> <maml:para>> [!NOTE] > Starting in Windows PowerShell 5.0, `Write-Host` is a wrapper for `Write-Information` > This allows you to use `Write-Host` to emit output to the information stream. > This enables the capture or suppression of data written using `Write-Host` while preserving backwards compatibility. > for more information see Write-Host (Write-Host.md)`Write-Information` is also a supported workflow activity.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Write-Information</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="Msg"> <maml:name>MessageData</maml:name> <maml:Description> <maml:para>Specifies an informational message that you want to display to users as they run a script or command. For best results, enclose the informational message in quotation marks. An example is "Test complete."</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Tags</maml:name> <maml:Description> <maml:para>Specifies a simple string that you can use to sort and filter messages that you have added to the information stream with `Write-Information`. This parameter works similarly to the Tags parameter in `New-ModuleManifest`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="Msg"> <maml:name>MessageData</maml:name> <maml:Description> <maml:para>Specifies an informational message that you want to display to users as they run a script or command. For best results, enclose the informational message in quotation marks. An example is "Test complete."</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Object</command:parameterValue> <dev:type> <maml:name>System.Object</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Tags</maml:name> <maml:Description> <maml:para>Specifies a simple string that you can use to sort and filter messages that you have added to the information stream with `Write-Information`. This parameter works similarly to the Tags parameter in `New-ModuleManifest`.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> <dev:type> <maml:name>System.String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>`Write-Information` does not accept piped input.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.InformationRecord</maml:name> </dev:type> <maml:description> <maml:para></maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------- Example 1: Write information for Get- results --------</maml:title> <dev:code>Get-WindowsFeature -Name p*; Write-Information -MessageData "Got your features!" -InformationAction Continue Display Name Name Install State ------------ ---- ------------- [ ] Print and Document Services Print-Services Available [ ] Print Server Print-Server Available [ ] Distributed Scan Server Print-Scan-Server Available [ ] Internet Printing Print-Internet Available [ ] LPD Service Print-LPD-Service Available [ ] Peer Name Resolution Protocol PNRP Available [X] Windows PowerShell PowerShellRoot Installed [X] Windows PowerShell 5.0 PowerShell Installed [ ] Windows PowerShell 2.0 Engine PowerShell-V2 Removed [X] Windows PowerShell ISE PowerShell-ISE Installed Got your features!</dev:code> <dev:remarks> <maml:para>In this example, you show an informational message, "Got your features!", after running the `Get-WindowsFeature` command to find all features that have a Name value that starts with 'p'. Because the `$InformationPreference` variable is still set to its default, `SilentlyContinue`, you add the `InformationAction` parameter to override the `$InformationPreference` value, and show the message. The `InformationAction` value is Continue, which means that your message is shown, but the script or command continues, if it is not yet finished.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 2: Write information and tag it -----------</maml:title> <dev:code>Get-WindowsFeature -Name p*; Write-Information -MessageData "To filter your results for PowerShell, pipe your results to the Where-Object cmdlet." -Tags "Instructions" -InformationAction Continue Display Name Name Install State ------------ ---- ------------- [ ] Print and Document Services Print-Services Available [ ] Print Server Print-Server Available [ ] Distributed Scan Server Print-Scan-Server Available [ ] Internet Printing Print-Internet Available [ ] LPD Service Print-LPD-Service Available [ ] Peer Name Resolution Protocol PNRP Available [X] Windows PowerShell PowerShellRoot Installed [X] Windows PowerShell 5.0 PowerShell Installed [ ] Windows PowerShell 2.0 Engine PowerShell-V2 Removed [X] Windows PowerShell ISE PowerShell-ISE Installed To filter your results for PowerShell, pipe your results to the Where-Object cmdlet.</dev:code> <dev:remarks> <maml:para>In this example, you use `Write-Information` to let users know they'll need to run another command after they're done running the current command. The example adds the tag Instructions to the informational message. After running this command, if you search the information stream for messages tagged Instructions, the message specified here would be among the results.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------------ Example 3: Write information to a file ------------</maml:title> <dev:code>function Test-Info { Get-Process P* Write-Information "Here you go" } Test-Info 6> Info.txt</dev:code> <dev:remarks> <maml:para>In this example, you redirect the information stream in the function to a file, Info.txt, by using the code 6>. When you open the Info.txt file, you see the text, "Here you go."</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/write-information?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_CommonParameters</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Preference_Variables</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Redirection</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Debug</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Information</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Progress</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Verbose</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Warning</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Output</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Write-Output</command:name> <command:verb>Write</command:verb> <command:noun>Output</command:noun> <maml:description> <maml:para>Sends the specified objects to the next command in the pipeline. If the command is the last command in the pipeline, the objects are displayed in the console.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Write-Output` cmdlet sends the specified object down the pipeline to the next command. If the command is the last command in the pipeline, the object is displayed in the console.</maml:para> <maml:para>`Write-Output` sends objects down the primary pipeline, also known as the "output stream" or the "success pipeline." To send error objects down the error pipeline, use Write-Error.</maml:para> <maml:para>This cmdlet is typically used in scripts to display strings and other objects on the console. However, because the default behavior is to display the objects at the end of a pipeline, it is generally not necessary to use the cmdlet. For instance, `Get-Process | Write-Output` is equivalent to `Get-Process`.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Write-Output</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to send down the pipeline. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NoEnumerate</maml:name> <maml:Description> <maml:para>By default, the `Write-Output` cmdlet always enumerates its output. The NoEnumerate parameter suppresses the default behavior, and prevents `Write-Output` from enumerating output. The NoEnumerate parameter has no effect on collections that were created by wrapping commands in parentheses, because the parentheses force enumeration.</maml:para> <maml:para>> [!IMPORTANT] > There is an issue with this switch in Windows PowerShell that is fixed in PowerShell 6.2 and above. > When using NoEnumerate and explicitly using the InputObject parameter, the command will > still enumerate. The workaround is to positionally define the InputObject parameter and the > enumeration will be suppressed.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:Description> <maml:para>Specifies the objects to send down the pipeline. Enter a variable that contains the objects, or type a command or expression that gets the objects.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.PSObject[]</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.PSObject[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NoEnumerate</maml:name> <maml:Description> <maml:para>By default, the `Write-Output` cmdlet always enumerates its output. The NoEnumerate parameter suppresses the default behavior, and prevents `Write-Output` from enumerating output. The NoEnumerate parameter has no effect on collections that were created by wrapping commands in parentheses, because the parentheses force enumeration.</maml:para> <maml:para>> [!IMPORTANT] > There is an issue with this switch in Windows PowerShell that is fixed in PowerShell 6.2 and above. > When using NoEnumerate and explicitly using the InputObject parameter, the command will > still enumerate. The workaround is to positionally define the InputObject parameter and the > enumeration will be suppressed.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>You can pipe objects to `Write-Output`.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.PSObject</maml:name> </dev:type> <maml:description> <maml:para>`Write-Output` returns the objects that are submitted as input.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>----- Example 1: Get objects and write them to the console -----</maml:title> <dev:code>$P = Get-Process Write-Output $P</dev:code> <dev:remarks> <maml:para>The first command gets processes running on the computer and stores them in the $P variable.</maml:para> <maml:para>The second and third commands display the process objects in $P on the console.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----------- Example 2: Pass output to another cmdlet -----------</maml:title> <dev:code>Write-Output "test output" | Get-Member</dev:code> <dev:remarks> <maml:para>This command pipes the "test output" string to the `Get-Member` cmdlet, which displays the members of the System.String class, demonstrating that the string was passed along the pipeline.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 3: Suppress enumeration in output ----------</maml:title> <dev:code>Write-Output @(1,2,3) | Measure-Object Count : 3 ... Write-Output @(1,2,3) -NoEnumerate | Measure-Object Count : 1 ...</dev:code> <dev:remarks> <maml:para>This command adds the NoEnumerate parameter to treat a collection or array as a single object through the pipeline.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/write-output?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Tee-Object</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Debug</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Error</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Information</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Progress</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Verbose</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Warning</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Write-Progress</command:name> <command:verb>Write</command:verb> <command:noun>Progress</command:noun> <maml:description> <maml:para>Displays a progress bar within a PowerShell command window.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Write-Progress` cmdlet displays a progress bar in a Windows PowerShell command window that depicts the status of a running command or script. You can select the indicators that the bar reflects and the text that appears above and below the progress bar.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Write-Progress</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Activity</maml:name> <maml:Description> <maml:para>Specifies the first line of text in the heading above the status bar. This text describes the activity whose progress is being reported.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Status</maml:name> <maml:Description> <maml:para>Specifies the second line of text in the heading above the status bar. This text describes current state of the activity.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none"> <maml:name>Id</maml:name> <maml:Description> <maml:para>Specifies an ID that distinguishes each progress bar from the others. Use this parameter when you are creating more than one progress bar in a single command. If the progress bars do not have different IDs, they are superimposed instead of being displayed in a series.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Completed</maml:name> <maml:Description> <maml:para>Indicates whether the progress bar is visible. If this parameter is omitted, `Write-Progress` displays progress information.</maml:para> </maml:Description> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CurrentOperation</maml:name> <maml:Description> <maml:para>Specifies the line of text below the progress bar. This text describes the operation that is currently taking place.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ParentId</maml:name> <maml:Description> <maml:para>Specifies the parent activity of the current activity. Use the value -1 if the current activity has no parent activity.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PercentComplete</maml:name> <maml:Description> <maml:para>Specifies the percentage of the activity that is completed. Use the value -1 if the percentage complete is unknown or not applicable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SecondsRemaining</maml:name> <maml:Description> <maml:para>Specifies the projected number of seconds remaining until the activity is completed. Use the value -1 if the number of seconds remaining is unknown or not applicable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SourceId</maml:name> <maml:Description> <maml:para>Specifies the source of the record. You can use this in place of Id but cannot be used with other parameters like ParentId .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none"> <maml:name>Activity</maml:name> <maml:Description> <maml:para>Specifies the first line of text in the heading above the status bar. This text describes the activity whose progress is being reported.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Completed</maml:name> <maml:Description> <maml:para>Indicates whether the progress bar is visible. If this parameter is omitted, `Write-Progress` displays progress information.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Management.Automation.SwitchParameter</command:parameterValue> <dev:type> <maml:name>System.Management.Automation.SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CurrentOperation</maml:name> <maml:Description> <maml:para>Specifies the line of text below the progress bar. This text describes the operation that is currently taking place.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none"> <maml:name>Id</maml:name> <maml:Description> <maml:para>Specifies an ID that distinguishes each progress bar from the others. Use this parameter when you are creating more than one progress bar in a single command. If the progress bars do not have different IDs, they are superimposed instead of being displayed in a series.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ParentId</maml:name> <maml:Description> <maml:para>Specifies the parent activity of the current activity. Use the value -1 if the current activity has no parent activity.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PercentComplete</maml:name> <maml:Description> <maml:para>Specifies the percentage of the activity that is completed. Use the value -1 if the percentage complete is unknown or not applicable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SecondsRemaining</maml:name> <maml:Description> <maml:para>Specifies the projected number of seconds remaining until the activity is completed. Use the value -1 if the number of seconds remaining is unknown or not applicable.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SourceId</maml:name> <maml:Description> <maml:para>Specifies the source of the record. You can use this in place of Id but cannot be used with other parameters like ParentId .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.Int32</command:parameterValue> <dev:type> <maml:name>System.Int32</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <maml:name>Status</maml:name> <maml:Description> <maml:para>Specifies the second line of text in the heading above the status bar. This text describes current state of the activity.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>You cannot pipe input to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>`Write-Progress` does not generate any output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>If the progress bar does not appear, check the value of the `$ProgressPreference` variable. If the value is set to SilentlyContinue, the progress bar is not displayed. For more information about Windows PowerShell preferences, see about_Preference_Variables (../Microsoft.PowerShell.Core/About/about_Preference_Variables.md).</maml:para> <maml:para>The parameters of the cmdlet correspond to the properties of the System.Management.Automation.ProgressRecord class. For more information, see ProgressRecord Class (/dotnet/api/system.management.automation.progressrecord)in the MSDN library.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------- Example 1: Display the progress of a For loop --------</maml:title> <dev:code>for ($i = 1; $i -le 100; $i++ ) { Write-Progress -Activity "Search in Progress" -Status "$i% Complete:" -PercentComplete $i; }</dev:code> <dev:remarks> <maml:para>This command displays the progress of a For loop that counts from 1 to 100.</maml:para> <maml:para>The `Write-Progress` cmdlet includes a status bar heading `Activity`, a status line, and the variable `$i` (the counter in the For loop), which indicates the relative completeness of the task.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>----- Example 2: Display the progress of nested For loops -----</maml:title> <dev:code>for($I = 1; $I -lt 101; $I++ ) { Write-Progress -Activity Updating -Status 'Progress->' -PercentComplete $I -CurrentOperation OuterLoop for($j = 1; $j -lt 101; $j++ ) { Write-Progress -Id 1 -Activity Updating -Status 'Progress' -PercentComplete $j -CurrentOperation InnerLoop } } Updating Progress -> [ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo] OuterLoop Updating Progress [oooooooooooooooooo ] InnerLoop</dev:code> <dev:remarks> <maml:para>This example displays the progress of two nested For loops, each of which is represented by a progress bar.</maml:para> <maml:para>The `Write-Progress` command for the second progress bar includes the Id parameter that distinguishes it from the first progress bar.</maml:para> <maml:para>Without the Id parameter, the progress bars would be superimposed on each other instead of being displayed one below the other.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>- Example 3: Display the progress while searching for a string -</maml:title> <dev:code># Use Get-EventLog to get the events in the System log and store them in the $Events variable. $Events = Get-EventLog -LogName system # Pipe the events to the ForEach-Object cmdlet. $Events | ForEach-Object -Begin { # In the Begin block, use Clear-Host to clear the screen. Clear-Host # Set the $i counter variable to zero. $i = 0 # Set the $out variable to a empty string. $out = "" } -Process { # In the Process script block search the message property of each incoming object for "bios". if($_.message -like "*bios*") { # Append the matching message to the out variable. $out=$out + $_.Message } # Increment the $i counter variable which is used to create the progress bar. $i = $i+1 # Use Write-Progress to output a progress bar. # The Activity and Status parameters create the first and second lines of the progress bar heading, respectively. Write-Progress -Activity "Searching Events" -Status "Progress:" -PercentComplete ($i/$Events.count*100) } -End { # Display the matching messages using the out variable. $out }</dev:code> <dev:remarks> <maml:para>This command displays the progress of a command to find the string "bios" in the System event log.</maml:para> <maml:para>The PercentComplete parameter value is calculated by dividing the number of events that have been processed `$I` by the total number of events retrieved `$Events.count` and then multiplying that result by 100.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 4: Display progress for each level of a nested process</maml:title> <dev:code>foreach ( $i in 1..10 ) { Write-Progress -Id 0 "Step $i" foreach ( $j in 1..10 ) { Write-Progress -Id 1 -ParentId 0 "Step $i - Substep $j" foreach ( $k in 1..10 ) { Write-Progress -Id 2 -ParentId 1 "Step $i - Substep $j - iteration $k"; start-sleep -m 150 } } } Step 1 Processing Step 1 - Substep 2 Processing Step 1 - Substep 2 - Iteration 3 Processing</dev:code> <dev:remarks> <maml:para>In this example you can use the ParentId parameter to have indented output to show parent/child relationships in the progress of each step.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/write-progress?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Debug</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Error</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Output</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Progress</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Verbose</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Warning</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Write-Verbose</command:name> <command:verb>Write</command:verb> <command:noun>Verbose</command:noun> <maml:description> <maml:para>Writes text to the verbose message stream.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Write-Verbose cmdlet writes text to the verbose message stream in Windows PowerShell. Typically, the verbose message stream is used to deliver information about command processing that is used for debugging a command.</maml:para> <maml:para>By default, the verbose message stream is not displayed, but you can display it by changing the value of the $VerbosePreference variable or using the Verbose common parameter in any command.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Write-Verbose</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="Msg"> <maml:name>Message</maml:name> <maml:Description> <maml:para>Specifies the message to display. This parameter is required. You can also pipe a message string to Write-Verbose .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="Msg"> <maml:name>Message</maml:name> <maml:Description> <maml:para>Specifies the message to display. This parameter is required. You can also pipe a message string to Write-Verbose .</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a string that contains the message to Write-Verbose .</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>Write-Verbose writes only to the verbose message stream.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>Verbose messages are returned only when the command uses the Verbose * common parameter. For more information, see about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216). In Windows PowerShell background jobs and remote commands, the $VerbosePreference variable in the job session and remote session determine whether the verbose message is displayed by default. For more information about the $VerbosePreference * variable, see about_Preference_Variables (../Microsoft.PowerShell.Core/About/about_Preference_Variables.md).</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------- Example 1: Write a status message --------------</maml:title> <dev:code>PS C:\> Write-Verbose -Message "Searching the Application Event Log." PS C:\> Write-Verbose -Message "Searching the Application Event Log." -Verbose</dev:code> <dev:remarks> <maml:para>These commands use the Write-Verbose cmdlet to display a status message. By default, the message is not displayed.</maml:para> <maml:para>The second command uses the Verbose common parameter, which displays any verbose messages, regardless of the value of the $VerbosePreference variable.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>- Example 2: Set $VerbosePreference and write a status message -</maml:title> <dev:code>PS C:\> $VerbosePreference = "Continue" PS C:\> Write-Verbose "Copying file $filename"</dev:code> <dev:remarks> <maml:para>These commands use the Write-Verbose cmdlet to display a status message. By default, the message is not displayed.</maml:para> <maml:para>The first command assigns a value of Continue to the $VerbosePreference preference variable. The default value, SilentlyContinue, suppresses verbose messages. The second command writes a verbose message.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/write-verbose?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Debug</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Error</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Information</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Output</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Progress</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Warning</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Write-Warning</command:name> <command:verb>Write</command:verb> <command:noun>Warning</command:noun> <maml:description> <maml:para>Writes a warning message.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The Write-Warning cmdlet writes a warning message to the Windows PowerShell host. The response to the warning depends on the value of the user's $WarningPreference variable and the use of the WarningAction common parameter.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Write-Warning</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="Msg"> <maml:name>Message</maml:name> <maml:Description> <maml:para>Specifies the warning message.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="Msg"> <maml:name>Message</maml:name> <maml:Description> <maml:para>Specifies the warning message.</maml:para> </maml:Description> <command:parameterValue required="true" variableLength="false">System.String</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a string that contains the warning to Write-Warning .</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>Write-Warning writes only to the warning stream. It does not generate any other output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>* The default value for the $WarningPreference variable is Continue, which displays the warning and then continues executing the command. To determine valid values for a preference variable such as $WarningPreference, set it to a string of random characters, such as "abc". The resulting error message will list the valid values.</maml:para> <maml:para>*</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------- Example 1: Write a warning message --------------</maml:title> <dev:code>PS C:\> Write-Warning "This is only a test warning."</dev:code> <dev:remarks> <maml:para>This command displays the message "WARNING: This is only a test warning."</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- Example 2: Pass a string to Write-Warning ----------</maml:title> <dev:code>PS C:\> $w = "This is only a test warning." PS C:\> $w | Write-Warning</dev:code> <dev:remarks> <maml:para>This command shows that you can use a pipeline operator (|) to send a string to Write-Warning . You can save the string in a variable, as shown in this command, or pipe the string directly to Write-Warning .</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 3: Set the $WarningPreference variable and write a warning</maml:title> <dev:code>PS C:\> $warningpreference Continue PS C:\> Write-Warning "This is only a test warning." This is only a test warning. PS C:\> $warningpreference = "SilentlyContinue" PS C:\> Write-Warning "This is only a test warning." PS C:\> PS C:\> $warningpreference = "Stop" PS C:\> Write-Warning "This is only a test warning." WARNING: This is only a test message. Write-Warning : Command execution stopped because the shell variable "WarningPreference" is set to Stop. At line:1 char:14 + Write-Warning <<<< "This is only a test message."</dev:code> <dev:remarks> <maml:para>This example shows the effect of the value of the $WarningPreference variable on a Write-Warning command.</maml:para> <maml:para>The first command displays the default value of the $WarningPreference variable, which is Continue. As a result, when you write a warning, the warning message is displayed and execution continues.</maml:para> <maml:para>When you change the value of the $WarningPreference variable, the effect of the Write-Warning command changes again. A value of SilentlyContinue suppresses the warning. A value of Stop displays the warning and then stops execution of the command.</maml:para> <maml:para>For more information about the $WarningPreference variable, see about_Preference_Variables.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 4: Set the WarningAction parameter and write a warning</maml:title> <dev:code>PS C:\> Write-Warning "This is only a test warning." -WarningAction Inquire WARNING: This is only a test warning. Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"):</dev:code> <dev:remarks> <maml:para>This example shows the effect of the WarningAction common parameter on a Write-Warning command. You can use the WarningAction common parameter with any cmdlet to determine how Windows PowerShell responds to warnings resulting from that command. The WarningAction common parameter overrides the value of the $WarningPreference only for that particular command.</maml:para> <maml:para>This command uses the Write-Warning cmdlet to display a warning. The WarningAction common parameter with a value of Inquire directs the system to prompt the user when the command displays a warning.</maml:para> <maml:para>For more information about the WarningAction common parameter, see about_CommonParameters.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/write-warning?view=powershell-5.1&WT.mc_id=ps-gethelp</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Debug</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Error</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Host</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Information</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Output</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Progress</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Write-Verbose</maml:linkText> <maml:uri></maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> </helpItems>