Updates from: 04/20/2021 03:13:40
Service Microsoft Docs article Related commit history on GitHub Change details
Microsoft.PowerShell.Management Get Item (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Management/Get-Item.md
--- external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 03/27/2020 Last updated : 04/19/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-item?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-Item
This example gets the current directory of the `C:` drive. The object that is re
only the directory, not its contents. ```powershell
-Get-Item C:\
+Get-Item C:
``` ### Example 4: Get items in the specified drive
Accept wildcard characters: True
### -Filter
-Specifies a filter to qualify the **Path** parameter. The [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md)
-provider is the only installed PowerShell provider that supports filters. Filters are more efficient
-than other parameters. The provider applies filter when the cmdlet gets the objects rather than
-having PowerShell filter the objects after they're retrieved. The filter string is passed to the
-.NET API to enumerate files. The API only supports `*` and `?` wildcards.
+Specifies a filter to qualify the **Path** parameter. The
+[FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider is the only
+installed PowerShell provider that supports filters. Filters are more efficient than other
+parameters. The provider applies filter when the cmdlet gets the objects rather than having
+PowerShell filter the objects after they're retrieved. The filter string is passed to the .NET API
+to enumerate files. The API only supports `*` and `?` wildcards.
```yaml Type: System.String
Accept wildcard characters: True
### -UseTransaction
-Includes the command in the active transaction.
-This parameter is valid only when a transaction is in progress.
-For more information, see [about_Transactions](../Microsoft.PowerShell.Core/About/about_Transactions.md).
+Includes the command in the active transaction. This parameter is valid only when a transaction is
+in progress. For more information, see
+[about_Transactions](../Microsoft.PowerShell.Core/About/about_Transactions.md).
```yaml Type: System.Management.Automation.SwitchParameter
Accept wildcard characters: False
### CommonParameters
-This cmdlet supports the common parameters: `-Debug`, `-ErrorAction`, `-ErrorVariable`,
-`-InformationAction`, `-InformationVariable`, `-OutVariable`, `-OutBuffer`, `-PipelineVariable`,
-`-Verbose`, `-WarningAction`, and `-WarningVariable`. For more information, see
-[about_CommonParameters](../Microsoft.PowerShell.Core/About/about_CommonParameters.md).
+This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
+-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
+-WarningAction, and -WarningVariable. For more information, see
+[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Microsoft.PowerShell.Utility Convertto Json (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Utility/ConvertTo-Json.md
--- external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Utility Last updated 06/09/2017
ConvertTo-Json [-InputObject] <Object> [-Depth <Int32>] [-Compress]
## DESCRIPTION
-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.
+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.
You can then use the `ConvertFrom-Json` cmdlet to convert a JSON-formatted string to a JSON object, which is easily managed in PowerShell.
Accept wildcard characters: False
### -Depth
-Specifies how many levels of contained objects are included in the JSON representation. The default
-value is 2.
+Specifies how many levels of contained objects are included in the JSON representation. The value
+can be any number from `1` to `[Int]::MaxValue`. The default value is `2`. `ConvertTo-Json` emits a
+warning if the number of levels in an input object exceeds this number.
```yaml Type: System.Int32
Microsoft.PowerShell.Management Get Item (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Management/Get-Item.md
--- external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 12/18/2020 Last updated : 04/19/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-item?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-Item
This example gets the current directory of the `C:` drive. The object that is re
only the directory, not its contents. ```powershell
-Get-Item C:\
+Get-Item C:
``` ### Example 4: Get items in the specified drive
Accept wildcard characters: True
### CommonParameters
-This cmdlet supports the common parameters: `-Debug`, `-ErrorAction`, `-ErrorVariable`,
-`-InformationAction`, `-InformationVariable`, `-OutVariable`, `-OutBuffer`, `-PipelineVariable`,
-`-Verbose`, `-WarningAction`, and `-WarningVariable`. For more information, see
-[about_CommonParameters](../Microsoft.PowerShell.Core/About/about_CommonParameters.md).
+This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
+-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
+-WarningAction, and -WarningVariable. For more information, see
+[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Microsoft.PowerShell.Utility Convertto Json (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Utility/ConvertTo-Json.md
--- external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 06/09/2017 Last updated : 04/19/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/convertto-json?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: ConvertTo-Json
ConvertTo-Json [-InputObject] <Object> [-Depth <Int32>] [-Compress]
## DESCRIPTION
-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.
+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.
You can then use the `ConvertFrom-Json` cmdlet to convert a JSON-formatted string to a JSON object, which is easily managed in PowerShell.
Accept wildcard characters: False
### -Depth
-Specifies how many levels of contained objects are included in the JSON representation. The default
-value is 2.
+Specifies how many levels of contained objects are included in the JSON representation. The value
+can be any number from `1` to `[Int]::MaxValue`. The default value is `2`. `ConvertTo-Json` emits a
+warning if the number of levels in an input object exceeds this number.
```yaml Type: System.Int32
Microsoft.PowerShell.Management Get Item (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Management/Get-Item.md
--- external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 12/18/2020 Last updated : 04/19/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-item?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-Item
This example gets the current directory of the `C:` drive. The object that is re
only the directory, not its contents. ```powershell
-Get-Item C:\
+Get-Item C:
``` ### Example 4: Get items in the specified drive
Accept wildcard characters: True
### CommonParameters
-This cmdlet supports the common parameters: `-Debug`, `-ErrorAction`, `-ErrorVariable`,
-`-InformationAction`, `-InformationVariable`, `-OutVariable`, `-OutBuffer`, `-PipelineVariable`,
-`-Verbose`, `-WarningAction`, and `-WarningVariable`. For more information, see
-[about_CommonParameters](../Microsoft.PowerShell.Core/About/about_CommonParameters.md).
+This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
+-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
+-WarningAction, and -WarningVariable. For more information, see
+[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Microsoft.PowerShell.Utility Convertto Json (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Utility/ConvertTo-Json.md
--- external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 06/09/2017 Last updated : 04/19/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/convertto-json?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: ConvertTo-Json
ConvertTo-Json [-InputObject] <Object> [-Depth <Int32>] [-Compress]
## DESCRIPTION
-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.
+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.
You can then use the `ConvertFrom-Json` cmdlet to convert a JSON-formatted string to a JSON object, which is easily managed in PowerShell.
object, which is easily managed in PowerShell.
Many web sites use JSON instead of XML to serialize data for communication between servers and web-based apps.
+As of PowerShell 7.1, `ConvertTo-Json` emits a warning if the depth of the input object exceeds
+the depth specified for the command. This prevents unwanted data loss when converting objects.
+ This cmdlet was introduced in Windows PowerShell 3.0. ## EXAMPLES
Accept wildcard characters: False
### -Depth
-Specifies how many levels of contained objects are included in the JSON representation. The default
-value is 2.
+Specifies how many levels of contained objects are included in the JSON representation. The value
+can be any number from `1` to `[Int]::MaxValue`. The default value is `2`. `ConvertTo-Json` emits a
+warning if the number of levels in an input object exceeds this number.
```yaml Type: System.Int32
Microsoft.PowerShell.Management Get Item (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Management/Get-Item.md
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 12/18/2020 Last updated : 04/19/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-item?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-Item
This example gets the current directory of the `C:` drive. The object that is re
only the directory, not its contents. ```powershell
-Get-Item C:\
+Get-Item C:
``` ### Example 4: Get items in the specified drive
available in your session, type `Get-PsProvider`. For more information, see
[Get-PSProvider](Get-PSProvider.md) [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md)-
Microsoft.PowerShell.Utility Convertto Json (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Utility/ConvertTo-Json.md
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 06/09/2017 Last updated : 04/19/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/convertto-json?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: ConvertTo-Json
object, which is easily managed in PowerShell.
Many web sites use JSON instead of XML to serialize data for communication between servers and web-based apps.
-As of PowerShell 7.2, `ConvertTo-Json` emits a warning if the depth of the input object exceeds
+As of PowerShell 7.1, `ConvertTo-Json` emits a warning if the depth of the input object exceeds
the depth specified for the command. This prevents unwanted data loss when converting objects. This cmdlet was introduced in Windows PowerShell 3.0.
Accept wildcard characters: False
### -Depth
-Specifies how many levels of contained objects are included in the JSON representation. The default
-value is 2. As of PowerShell 7.2, `ConvertTo-Json` emits a warning if the number of levels in an
-input object exceeds this number.
+Specifies how many levels of contained objects are included in the JSON representation. The value
+can be any number from `0` to `[Int]::MaxValue`. The default value is `2`. `ConvertTo-Json` emits a
+warning if the number of levels in an input object exceeds this number.
```yaml Type: System.Int32
developer Modifying The Psmodulepath Installation Path https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/developer/module/modifying-the-psmodulepath-installation-path.md
--- Previously updated : 03/12/2021 Last updated : 04/19/2021 Title: Modifying the PSModulePath Installation Path description: Modifying the PSModulePath Installation Path
To add paths to this variable, use one of the following methods:
- To add a persistent variable to the registry, create a new user environment variable called `PSModulePath` using the Environment Variables Editor in the **System Properties** dialog box. -- To add a persistent variable by using a script, use the .Net method
+- To add a persistent variable using a script, use the .NET method
[SetEnvironmentVariable](/dotnet/api/system.environment.setenvironmentvariable) on the [System.Environment](/dotnet/api/system.environment) class. For example, the following script adds the `C:\Program Files\Fabrikam\Module` path to the value of the `PSModulePath` environment
To add paths to this variable, use one of the following methods:
```powershell $CurrentValue = [Environment]::GetEnvironmentVariable("PSModulePath", "Machine") [Environment]::SetEnvironmentVariable("PSModulePath", $CurrentValue + [System.IO.Path]::PathSeparator + "C:\Program Files\Fabrikam\Modules", "Machine")- ``` You may also set the `PSModulePath` values in the `powershell.config.json` configuration file. For
more information, see
## To remove locations from the PSModulePath
-You can remove paths from the variable using similar methods: for example,
-`$env:PSModulePath = $env:PSModulePath -replace "$([System.IO.Path]::PathSeparator)c:\\ModulePath"`
-will remove the **c:\ModulePath** path from the current session.
+You can remove paths from the variable using similar methods. The following example removes the
+`C:\ModulePath` path from the current session.
+
+```powershell
+$env:PSModulePath = $env:PSModulePath -replace "$([System.IO.Path]::PathSeparator)c:\\ModulePath"`
+```
+
+To make this change persistent for all PowerShell sessions, use the .NET method as explained
+previously.
+
+```powershell
+[Environment]::SetEnvironmentVariable("PSModulePath", $env:PSModulePath, "Machine")
+```
## See Also
learn Everything About Shouldprocess https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/learn/deep-dives/everything-about-shouldprocess.md
done instead of making changes. it's a good way to test out the impact of a comm
before you do something destructive. ```powershell
+PS C:\temp> Get-ChildItem
+ Directory: C:\temp
+Mode LastWriteTime Length Name
+---- ------------- ------ ----
+-a---- 4/19/2021 8:59 AM 0 importantfile.txt
+-a---- 4/19/2021 8:58 AM 0 myfile1.txt
+-a---- 4/19/2021 8:59 AM 0 myfile2.txt
+ PS C:\temp> Remove-Item -Path .\myfile1.txt -WhatIf What if: Performing the operation "Remove File" on target "C:\Temp\myfile1.txt". ```
learn Experimental Features https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/learn/experimental-features.md
--- Previously updated : 12/14/2020 Last updated : 04/19/2021 Title: Using Experimental Features in PowerShell description: Lists the currently available experimental features and how to use them. ---
This article describes the experimental features that are available and how to u
| PSSubsystemPluginModel | | | &check; | &check; | | PSAnsiProgress | | | | &check; | | PSAnsiRendering | | | | &check; |
+| PSNativeCommandArgumentPassing | | | | &check; |
## Microsoft.PowerShell.Utility.PSManageBreakpointsInRunspace
The experimental feature includes a new cmdlet,
[Get-PSSubsystem](xref:Microsoft.PowerShell.Core.Get-PSSubsystem). This cmdlet is only available when the feature is enabled. This cmdlet returns information about the subsystems that are available on the system.+
+## PSNativeCommandArgumentPassing
+
+When this experimental feature is enabled PowerShell uses the `ArgumentList` property of the
+`StartProcessInfo` object rather than our current mechanism of reconstructing a string when invoking
+a native executable.
+
+This feature adds a new automatic variable `$PSNativeCommandArgumentPassing` that allows you to
+select the behavior at runtime. The valid values are `Legacy` and `Standard`. `Legacy` is the
+historic behavior. The default when the experimental feature is enabled is the new `Standard`
+behavior.
+
+> [!CAUTION]
+> The new behavior is a **breaking change** from current behavior. This may break scripts and
+> automation that work-around the various issues when invoking native applications. Historically,
+> quotes must be escaped and it is not possible to provide empty arguments to a native application.
+
+New behaviors made available by this change:
+
+- Literal or expandable strings with embedded quotes the quotes are now preserved:
+
+ ```powershell
+ PS > $a = 'a" "b'
+ PS > $PSNativeCommandArgumentPassing = "Legacy"
+ PS > testexe -echoargs $a 'a" "b' a" "b
+ Arg 0 is <a b>
+ Arg 1 is <a b>
+ Arg 2 is <a b>
+ PS > $PSNativeCommandArgumentPassing = "Standard"
+ PS > testexe -echoargs $a 'a" "b' a" "b
+ Arg 0 is <a" "b>
+ Arg 1 is <a" "b>
+ Arg 2 is <a b>
+ ```
+
+- Empty strings as arguments are now preserved:
+
+ ```powershell
+ PS> $PSNativeCommandArgumentPassing = "Legacy"
+ PS> testexe -echoargs '' a b ''
+ Arg 0 is <a>
+ Arg 1 is <b>
+ PS> $PSNativeCommandArgumentPassing = "Standard"
+ PS> testexe -echoargs '' a b ''
+ Arg 0 is <>
+ Arg 1 is <a>
+ Arg 2 is <b>
+ Arg 3 is <>
+ ```
+
+The new behavior does not change invocations that look like this:
+
+```powershell
+PS> $PSNativeCommandArgumentPassing = "Legacy"
+PS> testexe -echoargs -k com:port=\\devbox\pipe\debug,pipe,resets=0,reconnect
+Arg 0 is <-k>
+Arg 1 is <com:port=\\devbox\pipe\debug,pipe,resets=0,reconnect>
+PS> $PSNativeCommandArgumentPassing = "Standard"
+PS> testexe -echoargs -k com:port=\\devbox\pipe\debug,pipe,resets=0,reconnect
+Arg 0 is <-k>
+Arg 1 is <com:port=\\devbox\pipe\debug,pipe,resets=0,reconnect>
+```
+
+Additionally, parameter tracing is now provided so `Trace-Command` will provide useful information
+for debugging.
+
+```powershell
+PS> $PSNativeCommandArgumentPassing = "Legacy"
+PS> trace-command -PSHOST -Name ParameterBinding { testexe -echoargs $a 'a" "b' a" "b }
+DEBUG: 2021-02-01 17:19:53.6438 ParameterBinding Information: 0 : BIND NAMED native application line args [/Users/james/src/github/forks/jameswtruher/PowerShell-1/test/tools/TestExe/bin/testexe]
+DEBUG: 2021-02-01 17:19:53.6440 ParameterBinding Information: 0 : BIND argument [-echoargs a" "b a" "b "a b"]
+DEBUG: 2021-02-01 17:19:53.6522 ParameterBinding Information: 0 : CALLING BeginProcessing
+Arg 0 is <a b>
+Arg 1 is <a b>
+Arg 2 is <a b>
+PS> $PSNativeCommandArgumentPassing = "Standard"
+PS> trace-command -PSHOST -Name ParameterBinding { testexe -echoargs $a 'a" "b' a" "b }
+DEBUG: 2021-02-01 17:20:01.9829 ParameterBinding Information: 0 : BIND NAMED native application line args [/Users/james/src/github/forks/jameswtruher/PowerShell-1/test/tools/TestExe/bin/testexe]
+DEBUG: 2021-02-01 17:20:01.9829 ParameterBinding Information: 0 : BIND cmd line arg [-echoargs] to position [0]
+DEBUG: 2021-02-01 17:20:01.9830 ParameterBinding Information: 0 : BIND cmd line arg [a" "b] to position [1]
+DEBUG: 2021-02-01 17:20:01.9830 ParameterBinding Information: 0 : BIND cmd line arg [a" "b] to position [2]
+DEBUG: 2021-02-01 17:20:01.9831 ParameterBinding Information: 0 : BIND cmd line arg [a b] to position [3]
+DEBUG: 2021-02-01 17:20:01.9908 ParameterBinding Information: 0 : CALLING BeginProcessing
+Arg 0 is <a" "b>
+Arg 1 is <a" "b>
+Arg 2 is <a b>
+```