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. Add a "Compile" verb

    PowerShell needs a Compile verb, especially in a world of DevOps. Looking at the approved verb list, there are mediocre subtitutes that could be used in its place (Start-Compilation, Invoke-Compile, etc.), but these all use an inappropriate verb with the a variant of the verb in the noun. When the verb is finding its way into the noun, it's time for a new verb. Please add Compile to the list of approved verbs in an upcoming release.

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

    We’ll send you updates on this idea

    8 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
    survey  ·  Zachary Alexander responded

    Thank you for your input. Based on its current ranking compared to other feedback items and product schedule, work on this item is pending (and will be driven by) further customer input.

  2. Allow splatting without an intermediate variable.

    instead of
    $splat = @{name = "value"}
    verb-noun @splat

    Allow verb-noun @{name = "value"}

    This would make for a much cleaner and more natural look to parameters. Letting them be in the usual place of after and below the function.

    There is a stackoverflow question relating to this, that should explain it more - http://stackoverflow.com/questions/35188172/why-do-i-need-to-splat-to-a-variable-first

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

    We’ll send you updates on this idea

    16 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
    survey  ·  Zachary Alexander responded

    Thank you for your input. Based on its current ranking compared to other feedback items and product schedule, work on this item is pending (and will be driven by) further customer input. If you did not open this issue and are also impacted by it, please vote this item up.

  3. PowerShell fails to start if path contains brackets

    In a variety of cases, attempting to launch PowerShell from a path containing square brackets either fails entirely, or fails to resolve the relative working directory. For example:

    With this command, PowerShell won't launch:

    PS C:\T[e]st> Start PowerShell

    Start : Cannot perform operation because the wildcard path C:\T[e]st did not resolve to a file.
    
    At line:1 char:1
    + Start PowerShell
    + ~~~~~~~~~~~~~~~~
    + CategoryInfo : OpenError: (C:\T[e]st:String) [Start-Process], FileNotFoundException
    + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.StartProcessCommand

    From CMD or Powershell, this command starts Powershell, but with the wrong working directory:

    C:\T[e]st> PowerShell

    Windows PowerShell
    
    Copyright (C) 2015 Microsoft Corporation. All rights reserved.

    PS…

    6 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 →
  4. Job cmdlets fail with UTF-8 codepage

    Powershell jobs (eg, Start-Job, Wait-Job, Receive-Job) fail when Powershell's codepage is set to UTF8.

    Simple reproduction on Server 2012R2 w/ PS5:
    from cmd.exe, set the parent process codepage and start powershell with:

    chcp 65001
    powershell

    from the powershell that just started:
    $job = Start-Job -ScriptBlock { Write-Output yo }
    Receive-Job $job -Wait

    The Receive-Job call will fail with: "
    [localhost] The background process reported an error with the following message: Cannot process an element with node type "Text". Only Element and EndElement node types are supported. at
    System.Management.Automation.Remoting.OutOfProcessUtils.ProcesData(String data, DataProcessingDelegates callbacks).

    + CategoryInfo          : OpenError: (localhost:String) [], PSRemotingTransportException
    
    + FullyQualifiedErrorId
    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  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  5. PS 5.0 Bug: Transcript stops after restarting a remote computer using ‘Restart-Computer’ with '-Wait' parameter.

    PS 5.0 Bug: Transcript stops after restarting a remote computer using ‘Restart-Computer’ with '-Wait' parameter.

    Example script:
    Start-Transcript c:\test.log
    $computername = "Fred"
    $credential = (get-credential "domain\user")

    Restart the remote computer.

    Restart-Computer -ComputerName $computername -Credential $credential -protocol WsMan -WsmanAuthentication Default -force -wait -for powershell -erroraction stop
    Stop-Transcript

    My tests were performed in the following environment - the source computer is Windows 7 SP1 with PowerShell 5.0, the target is Windows 7 SP1 with PowerShell 4.0.

    Upon completion of the reboot, the transcription is stopped. This is recorded in the transcript log file as “Windows PowerShell transcript end”. This results in 'Stop-Transcript'…

    4 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 →
  6. new parameter -markdown for Format-Table

    Example:

    $Get-Process | select -First 5 | ft -au

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


    716     47 32832 43396   587          1764 AdminManagerClient
    
    257 34 3432 9352 84 1128 AgentService
    495 78 15700 28528 154 3744 AppVClient
    244 35 60952 41796 692 0.56 5416 AppVStreamingUX
    591 18 17280 22992 108 1,751.98 4672 audiodg

    $Get-Process | select -First 5 | ft -markdown

    |Handles|NPM(K)|PM(K)|WS(K)|VM(M)| CPU(s)| Id|ProcessName |
    |-------|------|-----|-----|-----|--------|----|------------------|
    | 716| 47|32832|43396| 587| |1764|AdminManagerClient|
    | 257| 34| 3432| 9352| 84| |1128|AgentService |
    | 495| 78|15700|28528| 154| |3744|AppVClient |
    | 244| 35|60952|41796| 692| 0.56|5416|AppVStreamingUX |
    | 591| 18|17280|22992| 108|1,751.98|4672|audiodg |

    This could be…

    5 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 →
  7. Bug: Move-Item

    Noticed a bug with the "Move-Item" cmdlet.

    Example:
    The source folder and destination folder have different permissions sets.

    $src = "C:\Path\To\Source"
    $dest = "D:\Path\To\Dest"

    ForEach($file in $src)
    {

      Move-Item $($file.fullname) -destination $dest
    

    }

    Using this block of code to move files from one folder to another will result in the files not inheriting permissions from the destination folder.

    The files that were moved retain the permissions from the source folder.

    This doesn't happen with Copy-Item or when you drag / drop files.

    Workaround I found is to add "icacls $dest /T RESET" to the end of the script.

    6 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 →
  8. Properly handle multi-line commands when read from stdin (and stdin is not a tty)

    If Powershell is reading scripts from stdin, when executed using "Powershell -Command - ", then it exits as soon as it sees a multi-line statement. This can be solved by adding an extra newline, but this should not be necessary if stdin is not a tty, and definitely not if "-NonInteractive" is specified.
    Further details and investigation here: http://stackoverflow.com/questions/37417613

    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 →
  9. [BUG] Count property incorrect works with a single WMI object

    You can now use Count or Length on any object, even if it didn’t have the property. If the object didn’t have a Count or Length property, it will will return 1 (or 0 for $null). Objects that have Count or Length properties will continue to work as they always have.

    Returns nothing,but should be

    PS > (Get-WmiObject -Class Win32OperatingSystem).Count
    PS > (Get-CimInstance -ClassName Win32
    OperatingSystem).Count

    Works as expected

    PS > (Get-WmiObject -Class Win32OperatingSystem -Filter "Name=1").Count
    0
    PS > (Get-CimInstance -ClassName Win32
    OperatingSystem -Filter "Name=1").Count
    0
    PS > (Get-CimInstance -ClassName Win32Service).Count
    230
    PS > (Get-WmiObject -Class Win32

    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 →

    I can repro this for sure, but given the difficulty of servicing and the impact of the bug, it’s pretty unlikely to get fixed.

    One possible workaround: (Get-CimInstance -ClassName Win32_OperatingSystem -Filter “Name=1″ | Measure-Object).Count

  10. Allow Environment Variable as default value for function parameter.

    When defining a function, I would like to use an environment variable as the default value. If the environment variable exists and has a value that value will be used. For example,

    function Get-Info ([Alias("name")] [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true)] [string] $projectName = $env:Project_Name)
    {
    }

    Instead of having to passing in the Project Name for each call I would like to store it in an environment variable. When I do it would allow me to call Get-Info with no parameters and the value in the environment variable would be used. If the environment variable does not exist or is empty the user…

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

    We’ll send you updates on this idea

    3 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  11. Bug in Show-Command

    Scriptblock parameters are interpreted as a [bool] value and is shown as a listbox with values $true or $false

    Code to reproduce:

    Show-Command -Name Invoke-Command

    Scriptblock parameter is shown as a [bool] listbox

    Cheers

    Tore

    14 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. BUG: PSBoundParameters contains values from PREVIOUS pipeline input

    When writing functions that take ValueFromPipelineByPropertyName, and accepting pipeline input, if some of the pipeline input is missing some properties, PSBoundParameters contains the previous value... incorrectly reporting the parameter was passed in:

    For example:

    function Get-UserName {
    [CmdletBinding()]
    param(

    [Parameter(ValueFromPipelineByPropertyName,Mandatory)]
    
    $Last,

    [Parameter(ValueFromPipelineByPropertyName)]
    $First

    )
    process {

    if($PSBoundParameters.ContainsKey('First')) {
    
    Write-Host -Foreground Red $PSBoundParameters['First'] $PSBoundParameters['Last'] " " -NoNewLine
    $First[0] + $Last
    } else {
    $Last
    }

    }
    }

    $Users = [PSCustomObject]@{ First = "Ethan"; Last = "Hunt" }, [PSCustomObject]@{ First = "Jason"; Last = "Bourne" }, [PSCustomObject]@{ Last = "Bond" }

    $Users | Get-UserName

    9 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. Please make -NoTypeInformation the default for Export-CSV

    I'm pretty sure that Export-CSV is used for creating Excel compatible files far more often than it is used for Serialising and Deserialising Type-consistent PS Objects.

    Alternatively / additionally adding a PS preference variable to set the default behaviour.

    I understand that this is simply a convenience thing, eliminating the need to add an extra parameter for the most common use case.

    5 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 →
  14. 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 →
  15. 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 →
  16. 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 →
  17. 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 →
  18. 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 →
  19. 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 →
  20. 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 →
← Previous 1 3
  • Don't see your idea?

Feedback and Knowledge Base