# PowerShell

The PowerShell forum accepts bug reports as well as feedback and suggestions. For more information, check out the PowerShell Homepage

The following is a list of the states we use to track items.

status meaning
survey We saw this and we are considering it. Please upvote if it’s important to you.
investigating We are looking at this internally to understand things like: scenario, reproduction of issue, costing, or other technical details.
in queue The issue is understood and in our unprioritized backlog. Your votes will be used to drive prioritization of this work.

## Please feel free to provide feedback or file bugs here.

(thinking…)

Enter your idea and we'll search to see if someone has already suggested it.

If a similar idea already exists, you can support and comment on it.

If it doesn't exist, you can post your idea so others can support it.

Enter your idea and we'll search to see if someone has already suggested it.

• Hot ideas
• Top ideas
• New ideas
• My feedback
1. ## using module <Module> does not work as expected

Script is just two lines as following:

(I tried the respective registry entry and "$ie = new-object -Com InternetExplorer.ApplicationMedium", no better.) (This input box is too small.) After some script statements to log in and navigate to the incoming tickets monitor, I do a$newcalls = $ie.Document.getElementsByName("callid") (This input box is too small.) That's working perfectly fine in PowerShell version 4, but in v5 I get Exception from HRESULT: 0x800A138A At <path>.ps1:89 char:5 +$newcalls = $ie.Document.getElementsByName("callid") + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo… 1 vote Sign in Check! (thinking…) Reset or sign in with I agree to the terms of service Signed in as (Sign out) We’ll send you updates on this idea • ## Catch illegal syntax in array definition Today I had an issue where getting an element at a certain index in a typed array failed. As I was troubleshooting this issue I found that it was simply because I had used a '.' (dot) instead of a ',' (comma) to separate the elements when I defined the typed array variable. Okay, that is a clear mistake on my part. However, as I thought about it I would have loved to be alerted by the Powershell engine . -- Experienced on v5.1.14409.1012 of PowerShell -- Win7 x64 OS TO REPRODUCE: open vscode create ps1 file$array = "hej",…

1 vote
Check!
(thinking…)
Reset
Signed in as (Sign out)

We’ll send you updates on this idea

• ## [BUG] Drag and drop to scripts shortcuts split paths containing spaces

Drag and dropping any file to a script shortcut split this path before passing the splitted strings as multiple parameters. Here's my detailed Issue Report :

Steps to reproduce
------------------

1 - Get any script, for example :
[samplescript.psd1] :

param([string]$path) Write-Host($path)
pause

or a simpler one-line sample: Write-Host($args);pause 2 - Create a shortcut that runs the script : [Shortcut Target ] : PowerShell "path\to\our\samplescript.psd1" 3- Drag and drop a file containing spaces in its name to the shortcut [sample file ] : C:\Some file with spaces.txt Expected behavior ----------------- Drag and dropping the file should pass its… 2 votes Sign in Check! (thinking…) Reset or sign in with I agree to the terms of service Signed in as (Sign out) We’ll send you updates on this idea • ## Can you add some stuff to Get-ClipBoard? I would have liked the default behaviour to be that an array of newline-split strings was returned from Get-ClipBoard. 97 % of the time I end up writing (Get-ClipBoard) -split "\r?\n" | ...... often filtering out empty elements - and that's just boring. In my own version I used -Raw for a string and nothing for an array/list. Of course you can't change that now in the 5.x version (or later, sigh, will this be our doom in some distant future), but can you maybe add at least -AsArray or similar? Make it so it can only be used with… 3 votes Sign in Check! (thinking…) Reset or sign in with I agree to the terms of service Signed in as (Sign out) We’ll send you updates on this idea • ## Fix .NET date formatting bug in .ToString() PS D:\> gcim win32_operatingsystem | % caption Microsoft Windows Server 2016 Standard PS D:\>$PSVersionTable.PSVersion

Major Minor Build Revision
----- ----- ----- --------
5 1 14393 1358

PS D:\> [DateTime]::Now.ToString('yyyy-MM-dd HH:mm:ss')
2017-07-27 12.29.37

Check!
(thinking…)
Reset
Signed in as (Sign out)

We’ll send you updates on this idea

• ## Remote Powershell Session "-ErrorAction Stop" give Non-Terminating Error

Script with Remote Powershell that are using Try/Catch and (of course) Terminating error, but for some reason under PSv5.1 Shell now those "-ErrorAction Stop" aren’t producing Terminating Error.

I need to force $ErrorActionPreference = “Stop” to have my Try/Catch to work. 1 vote Sign in Check! (thinking…) Reset or sign in with I agree to the terms of service Signed in as (Sign out) We’ll send you updates on this idea • ## Powershell does not interpret set variables Powershell has (optionally) replaced cmd as a standard shell in Windows 10. However it is a pity that Powershell is not able to interpret commands that rely on usage of variables that are defined in "set" like %computername%, %windir%, %userprofile%, %appdata% etc etc Please respect your own system variables in use for decades Microsoft. Thank you a lot. There must be way without breaking this. try issuing a simple cd %appdata% in powershell (often used in KB articles), good luck and have fun (or not). Imho while I could understand limitations this is pretty odd. 2 votes Sign in Check! (thinking…) Reset or sign in with I agree to the terms of service Signed in as (Sign out) We’ll send you updates on this idea • ## Command line parsing bug: spaces and trailing slash There appears to be a bug parsing arguments to EXEs. If you pass a properly-quoted path that has spaces and a trailing slash, the rest of the command is lumped into the same argument. This also happens if you use a PowerShell variable to hold the path string. To repro, first, install EchoArgs.exe (if using chocolatey: cinst -y echoargs). It demonstrates what arguments would get passed to any exe. Then run: PS> & EchoArgs "C:\spaces and trailing slash\" more args Echo args shows that it all got lumped into one argument: Arg 0 is <C:\spaces and trailing slash" more args> 6 votes Sign in Check! (thinking…) Reset or sign in with I agree to the terms of service Signed in as (Sign out) We’ll send you updates on this idea • ## Make the Continue statement work in ForEach-Object Within in ForEach-Object script block, "continue" behaves like "break", and one should use "return" to simulate "continue". But, from my perspective, it would make sense to give "continue" foreach-object awareness 3 votes Sign in Check! (thinking…) Reset or sign in with I agree to the terms of service Signed in as (Sign out) We’ll send you updates on this idea • ## Bug: New-PSDrive mounts locally scoped, even though it is supposed to be across a powershell Session. Confirmed that PSDrive is only scope locally in the class method is was called in: Test Setup: Mount(): HKU, HKCC, HKCUHKLM in class method. Display PSDrive mounts. Call Test() within that Mount(), which mounts HKCR; Display PSDrive in method call. Display PSDrive mounts on Test() return Display PSDrive mounts on Mount() return Call Test() method from main, Display PSDrive mounts. Display PSDrive mounts on Test() return VERBOSE: Mounting registry drives for use ... VERBOSE: HKU VERBOSE: HKCC VERBOSE: HKCU VERBOSE: HKLM Alias C Cert Env Function HKCC HKCU HKLM HKU Variable WSMan (Scope: Mount()) Alias C Cert Env Function HKCC… 1 vote Sign in Check! (thinking…) Reset or sign in with I agree to the terms of service Signed in as (Sign out) We’ll send you updates on this idea • ## Slow "." hash lookups Slow "." hash lookups (more than 100 times slower than []) from PowerShell Version 2 to Version 5.1 This could be either a documentation problem or a bug. The documentation never says that the "." hash lookup can be much slower than the [] lookup. I hope it is a bug (one less thing to remember). They both worked at the same speed in PS Version 2.0 and diverged sometime after that. Two script files. The first calls the second forcing versions 1 thru 5 of PowerShell. The "." hash lookups in PS Version 2.0 take .028 seconds. The "."… 1 vote Sign in Check! (thinking…) Reset or sign in with I agree to the terms of service Signed in as (Sign out) We’ll send you updates on this idea • ## Provide a native ternary operator It would be very nice and convenient if PowerShell had a native ternary operator like C# does (https://msdn.microsoft.com/en-us/library/zakwfxx4(v=vs.100).aspx). Basically it would allow you to write a short-hand if-else statement, so instead of having to write: if ($someBoolCondition)
{
$x =$y.Property1
}
else
{
$x =$y.Property2
}

you could just write:

$x =$someBoolCondition ? $y.Property1 :$y.Property2

This operator is fairly standard in many programming languages, so it would be awesome if PowerShell could come up to speed with it as well. Thanks.

Check!
(thinking…)
Reset
Signed in as (Sign out)

We’ll send you updates on this idea

• ## Do not require starting brace to be on same line as cmdlet

It is very annoying and confusing that some cmdlets require the starting brace to be on the same line as the cmdlet, while others do not.

For example, this is valid:

... | ForEach-Object {
$sourcefile =$_.Name
}

but this is not:

... | ForEach-Object
{
$sourcefile =$_.Name
}

yet using this is valid:

foreach ($x in$y)
{
$sourcefile =$_.Name
}

I know that you can use the backtick to make it valid, like this:

... | ForEach-Object 
{
$sourcefile =$_.Name
}

but that's still not intuitive and requires you to remember to do…

1 vote
Check!
(thinking…)
Reset
Signed in as (Sign out)

We’ll send you updates on this idea

• ## Foreach Does Not Run If Statements For Array Elements

Copy and run with -Debug. You'll see...

function Get-ArrayDups([array]$ArrayCheck,$IOI) {
$indices = @() For($i=0;$i -le$ArrayCheck.Length; $i++) {If ($IOI -eq $ArrayCheck[$i]) {$indices +=$i}}
"Variable $indices = " +$indices
"$ArrayCheck[0] = " +$ArrayCheck[0]
"$ArrayCheck[9] = " +$ArrayCheck[9]
}

Function Get-ArrayDups {
[cmdletbinding()]
Param(
[Parameter(ValueFromPipeline = $true)] [Array]$ArrayContent,

[int]
$IOI ) BEGIN { [array]$indices = @()
$Len =$ArrayContent.Count
$i = 0 Write-Debug "Initial Value: $Len = $Len" Write-Debug "Initial Value: $ArrayContent[$Len] =$($ArrayContent[$Len-1])"
Write-Debug "Initial Value: IOI is $IOI" Write-Debug "Initial Value: The full passed in array is$ArrayContent"
Write-Debug "Initial Value: Length of \$indices…

1 vote
Check!
(thinking…)
Reset
Signed in as (Sign out)

We’ll send you updates on this idea

• ## ExecutionPolicyOverride-Problem with GPO in place on Server 2016

I'm preparing some "Windows Server 2016" machines. While testing I stumbled across some issues with PowerShell.
I invested some time and narrowed it down a bit.

I also posted the issue on Microsoft Technet Forum and got the recommendation to file a Bug/Request here. Other users were also able to reproduce it quite easily:
(see: https://social.technet.microsoft.com/Forums/en-US/842c2cc2-c7f6-41b7-9561-31b2c65262b0/executionpolicyoverrideproblem-with-gpo-in-place-?forum=winserverpowershell)

Steps to reproduce:

I create a new VM, insert the Server 2016 ISO, boot up and install. After first start I change the network-settings for my environment and join the domain. I move the new computer-object to an OU where the group policy…

Check!
(thinking…)
Reset