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.
needs more information We don’t understand the issue and need additional details.
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.
  • Hot ideas
  • Top ideas
  • New ideas
  • My feedback
  1. [Bug] Castle's DynamicProxy breaks property indexers

    This blog post explains the issue is greater detail - https://matt.kotsenas.com/posts/powershell-dynamicproxy-indexers

    Setup:
    1. Create a C# class with an interface
    2. On that interface add a property indexer (and implement it in the class)
    3. Use Castle's DynamicProxy generator to create a proxy for that object

    Expected Results:
    - The proxy behaves like the regular object and the indexer works (e.g. $myObject['foo']

    Actual Results:
    - The proxy's indexer does not exist (e.g. $myObject['foo'] returns null)
    - The underlying getItem() method exists and works (e.g. $myObject.getItem('foo) returns the expected value)

    Here's a full implementation with sample code:

    ```
    $assemblies…

    3 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  2. Code completion pollutes $Error

    PowerShell v5

    Start a clean session:
    PowerShell -NoProfile

    Type the following characters:
    [cmd=

    and press Tab. The code is not completed, this is fine.

    But the global error collection $Error contains an error:
    The specified wildcard character pattern is not valid: [cmd=*

    Code completion should avoid such noise errors. They distract and may make an
    illusion that some user code produces them. Time may be lost on finding the
    actual culprit.

    4 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  3. Treat empty arrays as constants

    PowerShell's constant expression analyzer should recognize empty arrays as constants. i.e. these two should work:

    { param([ValidateSet(@())]$a) }

    Set-Variable -Option Constant emptyArray @()
    { param([ValidateSet($emptyArray)]$a) }

    Rather than complaining that empty arrays aren't constants.

    And the following should be much faster:

    @() should be equivalent to the constant Array.Empty<object>()

    Measure-Command { foreach ($null in 0..10000000) { $null = @() } }

    [int[]]@() should be equivalent to the constant Array.Empty<int>()

    Measure-Command { foreach ($null in 0..10000000) { $null = [int[]]@() } }

    1 vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  4. Document two types of terminating errors

    PowerShell help describes errors as non-terminating and terminating.
    But it does not tell that there are two types of terminating errors.

    For example, "true terminating errors" are produced by throw in scripts.
    They terminate the current script AND the calling script.

    Other terminating errors terminate only the current pipeline and DO NOT
    terminate the calling script unless its $ErrorActionPreference='Stop'
    or there is try/catch/finally or trap somewhere in the call stack.

    Just one example. A missing command is such a semi-terminating error (help about_trap).
    More: https://github.com/nightroman/PowerShellTraps/tree/master/Basic/Errors-of-unusual-type

    In the following command Get-Date is invoked after the error and the exit code is…

    2 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  5. Add Format method to all output streams

    When returning strings to the host, for example by using throw or inputting a standard string into code such as: $var = 'Hello world'
    We're able to use the format method to insert variables like so:

    $var1 = 'World'
    'Hello {0}' -f $var1

    To keep this style of formatting consistent across PowerShell itself (and also C#) can the format method be added to other output streams such as Write-Verbose, Information , Output etc.

    This would provide an easier learning curve for anyone with experience in other languages and would also be a lot nicer to look at as opposed to…

    10 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    2 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  6. SupportsShouldProcess adds help for cmdlets, but not functions

    When you add the SupportsShouldProcess property (CmdletCommonMetadata) to a C# cmdlet, it adds the WhatIf/Confirm parameters and their standard help descriptions.

    But, when you use the SupportsShouldProcess parameter of the
    CmdletBinding attribute in an advanced function, it adds the WhatIf and Confirm parameters, but it doesn't add the standard help descriptions for these parameters, as designed.

    Unless function authors add the help explicitly it doesn't exist, and then authors write their own help, so we end up with a multiplicity of descriptions of the same thing, which can be confusing to users. That's why we created the standard help.

    And,…

    1 vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  7. Suggestion: Allow explicit hexadecimal casts to [UInt32]

    I find it frustrating that there is no simple method of casting a 32-bit number with its high order bit set. For example consider the following number - 0x80000001:

    [UInt32] 0x80000001 <- throws an exception because it is implicitly converted to an Int32 which then cannot be converted to a UInt32.

    Various workarounds:
    * [UInt32] '0x80000001' <- String conversion. This operation is unnecessarily expensive.
    * [UInt32] 0x80000001L <- Downcast an Int64 to a UInt32.
    * [UInt32] 0x80000001 -band [UInt32]::MaxValue <- Perform bit math to force the conversion while preserving the bits.

    Proposed fix:

    As Jason Shirk suggested, it would probably…

    7 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  3 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  8. [Bug] New-PSSession returns null when executed from a non-console session

    Hi,

    We're seeing an issue where New-PSSession returns null when executed from a non-console session. Specifically, we have a top-level script that gets executed from Cake (http://cakebuild.net/) and Cake.Powershell (https://github.com/SharpeRAD/Cake.Powershell) within a TeamCity build agent.

    The top-level script is structured similar to:
    Set-StrictMode -Version Latest

    $Error.Clear()
    $ErrorActionPreference = "Stop"

    try
    {

    $remoteSession = New-PSSession `
    
    -ComputerName $FullyQualifiedDNSName `
    -UseSSL `
    -SessionOption (New-PsSessionOption -SkipCACheck -SkipCNCheck) `
    -Port 5986 `
    -Credential $credentials `
    -WarningAction Continue

    }
    catch
    {

    Write-Warning -Message ($_ | ConvertTo-CakeFormattedError)
    
    throw

    }

    When executed from Cake/Cake.Powershell via TeamCity, $remoteSession ends up being null. However, a…

    1 vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  1 comment  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  9. Evaluate target enumeration names to distinguish ambiguous overloads when implicitly casting parameters

    This line works, because PowerShell correctly guesses that I want to use the constructor which takes a String, a FileMode enum, a FileAccess enum, and a FileShare enum, and implicitly casts the last three strings to the appropriate enumeration.

    $Input = New-Object System.IO.FileStream $GZFilePath, 'Open', 'Read', 'Read'

    This line fails, because PowerShell does not know if I want the constructor which takes a String and a CompressionLevel enum, or a String and a CompressionMode enum.

    $Stream = New-Object System.IO.Compression.GzipStream $Input, 'Decompress'

    But PowerShell could distinguish between the two by checking if the string is a valid name in one and…

    3 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  10. 6 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  11. BUG: Windows Server 2012 R2 Change in Parameter Evaluation Timing

    I think I have found what I believe is a bug in Windows Server 2012 R2. The exact same PowerShell script and function call works in multiple versions of Windows and Windows Server but fails in 2012 R2. I opened a support case (REG:116050214117070) and they ended up telling me it's expected behavior. I have an extremely hard time believing this. :-)

    In short, I have a custom function for use with the SharePoint Online client-side object model (CSOM). Its purpose is to accept the object which needs to be loaded (like a list object) and then do the steps…

    2 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  1 comment  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  12. Cmdlet for getting list of Installed Software via Registry instead of win32_product.

    Would be great to have a builtin Cmdlet for getting list of Installed Software via Registry instead of win32_product.

    Why win32product is bad:
    https://sdmsoftware.com/group-policy-blog/wmi/why-win32
    product-is-bad-news/

    It would be faster, and would not trigger validation of all installed packages.

    Would use the following regkeys to return list of software (name, version, installDate) on local or remote machine (requires Remote Registry to be enabled on remote machine).

    HKLM:\Software\microsoft\windows\currentVersion\Uninstall
    HKLM:\Software\wow6432node\microsoft\windows\currentVersion\Uninstall

    6 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    1 comment  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →

    Will watch for folks to add their voices to this.
    In the meantime, if there is someone who wants to publish a user-contributed item to the PowerShell Gallery that does this, it would certainly be welcomed.

  13. ctrl-c should immediately stop the running command

    I have run into many occasions where I hit ctrl-c (or press the red stop button in the ISE) and PowerShell waits for several seconds before giving me back control of the prompt.

    This is especially true when there are network communication issues. For instance, perform a get-wmiobject against a computer whose network interface is disabled, and immediately break the operation. It will be in a "stopping" state for 5 to 15 seconds, then finally give you back control.

    3 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  14. $MyInvocation.ExpectingInput doesn't work in DynamicParam blocks

    PowerShell always evaluates $MyInvocation.ExpectingInput to $false in the DynamicParam block:

    function test([Parameter(ValueFromPipeline)]$Dummy) {

    dynamicparam { $r = @(); $r += $MyInvocation.ExpectingInput }
    
    begin { $r += $MyInvocation.ExpectingInput }
    process { $r += $MyInvocation.ExpectingInput }
    end { $r += $MyInvocation.ExpectingInput; $r -join &#39; &#39; }

    }

    1 | test

    False True True True

    #

    this should be:

    #

    True True True True

    3 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  1 comment  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  15. Treat string/integer literals to enum conversion as constants


    1. PowerShell should treat integer/string constants converted to an enum type as if it were an enum constant, e.g.:

    & { param([ValidateSet([System.Text.RegularExpressions.RegexOptions]::Multiline)]$a) } Multiline

    currently works

    & { param([ValidateSet([System.Text.RegularExpressions.RegexOptions]'Multiline')]$a) } Multiline

    should work but doesn't

    & { param([ValidateSet([System.Text.RegularExpressions.RegexOptions]2)]$a) } Multiline

    should work but doesn't


    1. PowerShell should make integer/string constant to enum conversions all the same speed, e.g.:

    Measure-Command { foreach ($null in 0..100000) { [System.Text.RegularExpressions.RegexOptions]::Multiline } }

    takes 20 ms on my machine

    Measure-Command { foreach ($null in 0..100000) { [System.Text.RegularExpressions.RegexOptions]2 } }

    takes 90 ms on my machine

    Measure-Command { foreach ($null in 0..100000) { [System.Text.RegularExpressions.RegexOptions]'Multiline' } }

    takes 130

    1 vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  16. The parameters grammar allows too many strange things


    1. PowerShell should modify the parameter-list grammar to disallow nonsensical stuff like specifying the scope and/or strange variable names:

    param($:foo)
    param($variable:foo)
    param($local:foo)
    param($env:foo)
    param($script:foo)
    param($private:foo)
    param($using:foo)
    param($global:foo)

    scopes should be disallowed

    param($$)
    param($^)
    param($0thefirstcharactercantbea_number)
    param(${-})
    param(${.30})
    param(${a<b})
    param(${a<#b})
    param(${foo`nasdf})

    funny character names should be disallowed

    Basically, if you can't do:

    cmdlet -foo

    then param($foo) should be treated as a syntax error.


    1. The parameter grammar in the PowerShell language specification is way too permissive, e.g. it allows for crazy things like:

    foo -a#b -a$b -x>b -a=3 -a<3 -a-3 -a*>> -a+3 -a<<3 -a<#3 -a`

    The grammar should…

    1 vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  17. Provide Intellisense/Template for Manifests

    When creating a Manifest (.psd1), it would be handy to have Intellisense or at least a Template available.

    4 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  18. DynamicParam should promote regular functions to advanced functions

    PowerShell promotes functions with [Parameter()] attributes to advanced functions, e.g.:

    function foo {

    param([Parameter()]$a)
    

    }

    gcm foo |% CmdletBinding

    True

    PowerShell should do a similar thing for functions with DynamicParam blocks since that construct only makes sense on cmdlets/advanced functions:

    function foo {

    dynamicparam { }
    

    }

    gcm foo |% CmdletBinding

    False, should be True

    1 vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  19. Start-Transcript Does Not Generate an Error on an Invalid Path

    On Windows Server 2012 R2, PSVersion 4.0, passing an invalid path to the Start-Transcript command does not generate an error. The cmdlet behaves as if the path exists, even producing the "Transcript started, output file is C:\fake\notreal.log" notification, while not actually generating any transcript file. Additionally, in my experience, performance slows considerably after this situation is encountered.

    On a Windows 7 system, Start-Transcript -path C:\notreal\no.log generates an error. On a Windows 10 system with PSV5 the nonexistant file will actually be created. Both of these are reasonable behaviors. Is there something I'm missing with PSV4 on WS2012R2 to get it…

    1 vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  20. Add PowerShell accelerator for SuppressMessageAttribute

    Filed by rkeithhill on GitHub: https://github.com/PowerShell/PSScriptAnalyzer/issues/514

    "It is well within the norm for PowerShell to define accelerators for common types to make it easier for PowerShell scripters to specify an attribute like ValidateSet or ValidateNotNull and not have to remember the full typename System.Management.Automation.ValidateSetAttribute.

    Ditto for System.Diagnostics.CodeAnalysis.SuppressMessageAttribute. Please consider asking the PowerShell team to add the accelerator SuppressMessage for this type. It will make PowerShell scripts that need to use this attribute easier to write and read."

    1 vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →

    From the GitHub Issue:

    “I agree that it might be useful super forward-looking, but today this will only help in the case where:

    You’re running PS 5.1+, the module you’re running is using a SuppressMessageAttribute, and you don’t have Script Analyzer installed
    Given all that, this is firmly within the realm of “nice to have” for me, and I’m not sure anything nice to have can make it in PS 5.1 right now. I’m going to place it on UserVoice, though, as something we might want to do in the future for PowerShell."

  • Don't see your idea?

Feedback and Knowledge Base