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. Problem with scope in PowerShell

    If you run following snippet of code in PowerShell, variable $i and $l will be accessible in the global scope after the loop has exited.
    for($i=1; $i -le 3; $i++){$l = $i}

    Typically in programming languages, neither variable should be visible in global scope, only in the loop scope. There has been many instances where I have forgotten this is a thing in PowerShell and it has bitten me in the face in the form of runtime errors.

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

    We’ll send you updates on this idea

    survey  ·  2 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  2. pipelinevariable vs outputvariable processing bug

    PS C:\Users\Administrator\Downloads\Lync\Lync> $outputtest = $null

    PS C:\Users\Administrator\Downloads\Lync\Lync> get-process -PipelineVariable pipelinetest -OutVariable outputtest | ? {$outputtest.name -like "vmwp"}

    Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName


    617      31    48096      27688   170   371.03    328 vmwp                                                                                                                                                
    
    535 57 39700 17712 135 251.22 2124 vmwp
    541 57 9584 18932 135 234.36 2644 vmwp
    85 7 760 3736 20 0.05 592 wininit
    161 8 1488 6564 66 0.25 624 winlogon
    227 11 10744 14144 56 2.45 1200 WmiPrvSE
    238 15 6072 11876 70 0.64 3592 WmiPrvSE

    PS C:\Users\Administrator\Downloads\Lync\Lync> get-process -PipelineVariable pipelinetest -OutVariable outputtest | ? {$pipelinetest.name -like "vmwp"}

    Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id…

    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 →
  3. Use the type of variables in the same way as OutputTypeAttribute when doing tab completion

    Use the type of variables in the same way as OutputTypeAttribute

    Get-Process | % <tab> #completes members of [Diagnostics.Process].

    [Diagnostics.Process[]] $proc = Get-Process

    $proc | % <tab> # does not complete members of [Diagnostics.Process] although the type is known.

    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  ·  ISE and tooling  ·  Flag idea as inappropriate…  ·  Admin →
  4. PowerShellGet and redirected MyDocs

    When using -Scope CurrentUser with the Install-* cmdlets from PowerShellGet it looks at [Environment]::GetFolderPath("MyDocuments") to determine where to install the modules/scripts/etc.
    If using Folder Redirection for My Documents, this is likely to be a network path which causes some issues such as performance (kills tab completion), as well as some potential issues with binary modules.

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

    We’ll send you updates on this idea

    4 comments  ·  Package Management  ·  Flag idea as inappropriate…  ·  Admin →

    Understand the problem now, which is based on loading the DLL from a redirected share.
    Moving to a Survey item to gauge priority.

    Thank you -

  5. ps5.0bug:please remove count length property from number object!

    ps5.0bug:please remove count length property from number object!

    Normal logic:
    There is no "count" and "length" attribute in the numeric type.

    【Cause of the bug】
    in my guess:
    powershell 1.0 developer:
    wrong add property "count" and "length" to number object,then make them equal to null.

    powershell 3.0 developer:
    then make them equal to 1.

    Joey Aiello [MSFT] (Program Manager, Windows Server):
    In PowerShell v3 the "Length" property was added to ALL objects. This was wrong.
    https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/11087970-ps3-length-property-added-to-all-objects-should-be

    【bug with powershell version】
    powershell 5.0 in win10 10586.494: yes,tested.

    【test code in win10】
    $a = 1234777
    $a.gettype().fullname #system.int32
    $a.length #return 1
    $a.lengtha #return…

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

    We’ll send you updates on this idea

    survey  ·  6 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  6. Limiting the new User PSDrive in JEA in WMF 5.1

    Now that you can set a user PSdrive in JEA to to allow copying files, would be nice to have the ability to include to exclude files allows to be copied to the drive and from the drive as part of the configuration script to create the endpoints

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

    We’ll send you updates on this idea

    survey  ·  4 comments  ·  Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
  7. Get-ComputerInfo should have remoting capabilities

    Get-ComputerInfo was introduced in PowerShell Desktop 5.1.14361.0 and provides the ability to return various information about the local computer. It would be very useful if this cmdlet could also query remote computers, without relying on PowerShell Remoting.
    For example:
    Get-ComputerInfo -ComputerName SRV01

    19 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  ·  Microsoft.PowerShell.* Modules  ·  Flag idea as inappropriate…  ·  Admin →
  8. Badges for PowerShell Gallery counts to be used on a GitHub page

    GitHub and npm have badges that can be placed on your repo or elsewhere that can display stats about aspects of your project.

    It'd be great to be able to put a badge on a repo showing stats about the published item to PowerShell Gallery, like, number of downloads.

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

    We’ll send you updates on this idea

    4 comments  ·  PowerShell Gallery  ·  Flag idea as inappropriate…  ·  Admin →

    Interesting concept. If you could do us a favor and send a pointer to a specific example, it would be helpful for us.

  9. Bug: Workflow -> InlineScript -> Function -> Function -> Write-Verbose throws an uncatchable and fatal exception

    I've blogged about this with full examples here: https://www.codykonior.com/2016/08/31/if-you-dont-mind-me-saying-powershell-workflows-are-awfully-broken/


    1. If you have a workflow and call it with -Verbose

    2. If that workflow has an InlineScript which calls a function

    3. And that function calls another function which does a Write-Verbose

    A terminating, uncatchable exception is thrown:

    Object reference not set to an instance of an object.

    + CategoryInfo          : ResourceUnavailable: (:) [], ParentContainsErrorRecordException
    
    + FullyQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStructureException
    + PSComputerName : [localhost]

    It seems to be with how Write-Verbose gets overridden in workflows to prefix output with the computer name it's running on. Creating a Write-Verbose wrapper around itself alleviates the issue.

    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 →
  10. [BUG] Group-Object with -AsHashTable and custom expressions

    There seems to be a bug in Group-Object when using the -AsHashTable switch and where any custom expression that returns a string is used. The hashtable is created, can be enumerated, but trying to get an entry from it using the indexer doesn't work. This seems to be the case exclusively when the expression returns a string.

    Consider the following:

    PS C:\Windows&gt; $Items = Get-ChildItem | Group-Object -Property Extension -AsHashTable
    
    PS C:\Windows&gt; $Items

    Name Value
    ---- -----
    .DMP {MEMORY.DMP}
    .bin {mib.bin}
    .xml {Enterprise.xml, Starter.xml}
    .NET {Microsoft.NET}
    .INI {HPMProp.INI, init.ini, msdfmap.ini, SMSCFG.INI...}
    .dat {bootstat.dat, ConnectionProfiles.dat}
    .dll {ISMIF32.dll, twain.dll, twain_32.dll}
    .exe {bfsvc.exe,…

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

    We’ll send you updates on this idea

    survey  ·  4 comments  ·  Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
  11. Get-Help cmdlet should skip error and continue updating help doc.

    I know that there are many cmdlets help documentation not completed yet. But, it's a pain when trying to use the "Update-help" cmdlet and see it error-out due to an unfinished module help.

    I think it should be a good idea to display the error and continue (or try) update the rest of our installed module(s).

    In my case, I'm getting an error update the help on the new SQLServer module. But this is now completing the update for the rest of my existing module.

    If this update is done alphabetically then the update is stopping at the SQLServer module…

    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  ·  Documentation  ·  Flag idea as inappropriate…  ·  Admin →
  12. ValidateSet doesn't accept constants like it says it does

    When running the below script on Windows 10 PowerShell 5.0.10586.494, it crashes with an error stating that the argument isn't a constant even though it is:

    Set-Variable -Option Constant ConstantVariable 'c'
    Set-Variable -Option Constant ConstantArrayVariable @('c')

    function Test-ValidateSet {

    param(
    
    [ValidateSet($ConstantVariable)]
    $p1,

    [ValidateSet($ConstantArrayVariable)]
    $p2
    )

    }

    At C:\tmp\Test-ValidateSet.ps1:7 char:22
    + [ValidateSet($ConstantVariable)]
    + ~~~~~~~~~~~~~~~~~
    Attribute argument must be a constant or a script block.
    At C:\tmp\Test-ValidateSet.ps1:10 char:22
    + [ValidateSet($ConstantArrayVariable)]
    + ~~~~~~~~~~~~~~~~~~~~~~
    Attribute argument must be a constant or a script block.

    + CategoryInfo          : ParserError: (:) [], ParseException
    
    + FullyQualifiedErrorId : ParameterAttributeArgumentNeedsToBeConstantOrScriptBlock

    This is an important feature for me because I…

    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 →
  13. Allow using Select, Sort, Group, and Measure without a pipeple

    It should be possible to use Select-Object, Sort-Object, Group-Object, and Measure-Object without a pipeline.

    In those circumstances where a script needs to be optimized for speed, one of the first things to do is to eliminate pipelines because of the huge overhead they incur. Because of these four commands, eliminating all pipelines is sometimes impossible or requires coming up with complex alternatives to them.

    I would expect these two commands (or some variation of the second one) to produce the same result:

    2, 1, 3 | Sort-Object
    Sort-Object -InputObject 2, 1, 3

    Currently, the second line treats the array in…

    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  ·  Microsoft.PowerShell.* Modules  ·  Flag idea as inappropriate…  ·  Admin →
  14. Workflow: activities in nested workflows invoked from ForEach -Parallel execute on wrong machines

    Consider a workflow which is given a list of servers. The workflow contains a ForEach -Parallel block, which invokes a nested workflow tor each server from the list (using -PSComputerName). In this scenario, activities from some of the nested workflow instances sometimes execute on different servers than they should.

    Repro:
    workflow Reproduce-ForEachParallelRemotingBugChild
    {

    Param ([string] $s)
    
    Write-Verbose &quot;(s=$s) PSComputerName $PSComputerName&quot;
    Write-Verbose &quot;(s=$s) sleeping&quot;
    Start-Sleep -Seconds 1
    Write-Verbose &quot;(s=$s) getting item&quot;
    $x = Get-Item -Path C:\
    Write-Verbose &quot;(s=$s) $($x.Name) $($x.PSComputerName)&quot;
    Write-Verbose &quot;(s=$s) PSComputerName $PSComputerName&quot; # this is OK (PSComputerName does not get corrupted)
    if ($x.PSComputerName -ne $s)
    {
    Write-Error &quot;BUG! This
    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  ·  Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
  15. Negation operator isn't IEEE floating point compliant

    $a = 0.0 ; $b = -$a ; $c = -1.0*$a

    1.0 / $b

    should produce [double]::NegativeInfinity but produces [double]::PositiveInfinity instead

    1.0 / $c

    this correctly produces [double]::NegativeInfinity

    It looks like PowerShell implements "-$a" as "0 - $a" which is incorrect for floating point types.

    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 →
  16. [type] should use type completion rather than directory completion

    It's strange that this uses type completion:

    New-Object -TypeName l

    <tab> completes to "long"

    but this uses directory completion:

    Update-TypeData -TypeConverter l

    <tab> completes to ".\Links&quot;

    Even though the former takes a [string] and the latter takes a [type]

    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  ·  ISE and tooling  ·  Flag idea as inappropriate…  ·  Admin →
  17. "Select-Object -Unique" and "Group-Object" should not have quadratic runtime

    De-duplicating a collection, or aggregating similar items in a collection, can be done in linear time via hash sets or hash tables, respectively.

    "Select-Object -unique" and "Group-Object", however, both use O(n^2) algorithms that rely only on equality, never leveraging hashing. It's literally faster (by a lot) to use "Sort-Object -Unique", which additionally does sorting.

    Blog post at http://latkin.org/blog/2016/08/02/curious-behavior-when-de-duplicating-a-collection-in-powershell/ has more explanation.

    It was suggested by Bruce P on Twitter that I open this bug: https://twitter.com/BrucePayette/status/760532657293832192

    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  ·  Microsoft.PowerShell.* Modules  ·  Flag idea as inappropriate…  ·  Admin →
  18. RunspacePool handle and memory leaks (no leaks in v2)

    Invoke the below script. In the infinite loop it creates runspace pools and
    uses them for invoking jobs. In the end of each iteration script outputs
    the process handle count and private memory size.

    In PS v5.1 the handle count and memory size constantly increase.
    In PS v2.0 these leaks are not observed.

    -----8<-----

    $sw = [System.Diagnostics.Stopwatch]::StartNew()
    
    $count = 0
    for() {
    $pool = [RunspaceFactory]::CreateRunspacePool(1, 2)
    $pool.Open()

    $ps1 = [PowerShell]::Create()
    $ps1.RunspacePool = $pool
    $job1 = $ps1.AddScript(&#39;&quot;job1 $(Get-Date)&quot;&#39;).BeginInvoke()

    $null = $job1.AsyncWaitHandle.WaitOne()
    $ps1.EndInvoke($job1)

    $ps1.Dispose()
    $pool.Close()

    ++$count
    $p = Get-Process -Id $PID
    &quot;$($p.HandleCount) $($p.PrivateMemorySize64 / 1mb) $($count / $sw.Elapsed.TotalSeconds)&quot;
    }

    -----8<-----

    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 →
  19. Make Cmdlets pick up app.config, especially binding redirects

    I can't believe this hasn't been resolved already.

    Surely adding assemblies to the GAC and mofiying machine.config is not a great solution.

    http://stackoverflow.com/questions/18542812/powershell-cmdlet-missing-assembly-google-api

    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  ·  Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
  20. [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 →
  • Don't see your idea?

Feedback and Knowledge Base