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. Mount-DiskImage fails with: "Access is denied" 0x5 occurred while reading the console output buffer

    After upgrade from Windows 1803 to Windows 1809 Mount-DiskImage $iso_path starts failing with the following error:

    ```
    Exception calling "EndProcessing" with "0" argument(s): "Win32 internal error "Access is denied" 0x5 occurred while reading the console output buffer. Contact Microsoft Customer Support Services."
    At line:352 char:17
    + $_cmdletizationobjectModelWrapper.EndProcessing()
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : HostException

    ```

    The powershell command is executed under Administrator user in packer. It actually mounts specified image path, but throws this exception on attempt to interact with stdout.

    4 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 →
  2. BUG: Shell crashing with x509Certificate2 objects

    Problem:

    When creating an object from the x509Certificate class the shell adds 3 script properties:

    DnsNameList
    EnhancedKeyUsageList
    SendAsTrustedIssuer

    The SendAsTrustedIssuer property causes Powershell to hit a CLR exception and hard crash when accessed.

    Repro Code:


    • Note: do this in a fresh session as it will crash the session

    $Test = New-Object System.Security.Cryptography.x509Certificates.x509Certificate2
    $Test | select *

    Alternately,

    $Test = New-Object System.Security.Cryptography.x509Certificates.x509Certificate2
    $Test.SendAsTrustedIssuer

    Crash dump:

    Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    at System.Management.Automation.Security.NativeMethods.CertGetCertificateContextProperty(IntPtr pCertContext, CertPropertyId dwPropId, IntPtr pvData, Int32& pcbData)
    at Microsoft.PowerShell.Commands.SendAsTrustedIssuerProperty.ReadSendAsTrustedIssuerProperty(X509Certificate2 cert)
    at CallSite.Target(Closure , CallSite…

    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 →
  3. Remote Invoke-Command with -ScriptBlock changes types of arguments if scripblock contains variables

    What's going on here???

    PS C:> Invoke-Command -ComputerName somemachine -Credential $cred -ArgumentList {Write-Host hi} -ScriptBlock {param($sb); Write-Host $sb.GetType().Name}
    ScriptBlock
    PS C:> Invoke-Command -ComputerName somemachine -Credential $cred -ArgumentList {Write-Host hi} -ScriptBlock {param($sb); Write-Host $sb.GetType().Name; $a=3}
    String
    PS C:> Invoke-Command -ComputerName somemachine -Credential $cred -ArgumentList {Get-ChildItem} -ScriptBlock {param($sb); Write-Host $sb.GetType().Name}
    ScriptBlock
    PS C:> Invoke-Command -ComputerName somemachine -Credential $cred -ArgumentList {Get-ChildItem} -ScriptBlock {param($sb); Write-Host $sb.GetType().Name; $a=3}
    String

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

    We’ll send you updates on this idea

    5 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
  4. SMTPEventConsumer doesnt format message body properly

    I found a bug in PS 4.0 when working with SMTPEventConsumers. The bug I found truncated the string used for the "Message" property of the SMTPEventConsumer. The code truncated anything after the first 16 characters. It didn't matter what I used for an escape sequence, formatted as here string, nothing worked. I ran the exact same code on a PS 5.1 host and the SMTP message was formatted exactly as expected. For more indepth info I have included a link to the thread I started on TechNet for this issue.

    https://social.technet.microsoft.com/Forums/en-US/62c4552b-b5e8-4bf3-ac74-6c5f1668af9f/issues-properly-formatting-smtpeventconsumer-message-body-in-powershell?forum=ITCG

    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 →
  5. Transfer $DebugPreference and $VerbosePreference to New-PSSession

    I want a PSSessionOption that says to transfer over common applicable session level variables over to the remote session, specifically $DebugPreference and $VerbosePreference.
    $DebugPreference = 'continue'
    $PSSession = New-PSSession -ComputerName 'localhost'
    Write-Debug $DebugPreference # Writes 'continue'
    Invoke-Command -ScriptBlock {Write-Debug $DebugPreference} -Session $PSSession # Writes nothing

    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 →
  6. Move-AzureRmDataLakeStoreItem not working in newer versions of module

    I created a runbook on several automation accounts that move around files and folders on Datalake Storage Accounts (gen 1). The runbook works without hitches on 2 automation accounts, but did not work on the other 2.

    There were quite a few differences in the versions of the added modules: the runbook worked on the older versions of the modules, but not the newer. Specifically the cmdlet Move-AzureRmDataLakeStoreItem threw an error on the newer versions:
    "Account name ***.azuredatalakestore.net/ is invalid. Specify the full account including the domain name."

    After trying quite a few iterations of writing the account name (just…

    2 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 →
  7. ERROR: Select-Object with -First parameter populates -ErrorVariable even if there was no error

    If you run: 1..2 | select -ErrorVariable a
    then $a is empty - OK.

    If you run: 1..2 | select -First 2 -ErrorVariable a
    then in $a is "System error"

    2 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 →
  8. Private methods in powershell class's don't work

    For reference: https://docs.microsoft.com/en-us/powershell/wmf/5.0/class_newtype#methods

    Creating private methods following the documentation does not work. To reproduce follow the following steps:


    • Open Powershell or the ISE

    • Copy the code from microsoft documentation

    • if ISE: The interface will alarm indicating problems

    • Execute documented test code

    • Observe several errors complaining about code syntax and missing brackets.

    You can also repro by adding the private designation to any working method of an existing class and it will bomb.

    2 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 →
  9. Errors that terminate script due to -ErrorAction Stop do not show correct line number

    PS > type .\error.ps1
    [Cmdletbinding()]
    param()

    "hello"
    "world"

    1/0
    

    PS > .\error.ps1
    hello
    world
    Attempted to divide by zero.
    At D:\junk\error.ps1:10 char:5
    + 1/0
    + ~~~

    + CategoryInfo          : NotSpecified: (:) [], RuntimeException
    
    + FullyQualifiedErrorId : RuntimeException

    PS > $ErrorActionPreference = "Stop"
    PS > .\error.ps1
    hello
    world
    D:\junk\error.ps1 : Attempted to divide by zero.
    At line:1 char:1
    + .\error.ps1
    + ~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [error.ps1], RuntimeException
    
    + FullyQualifiedErrorId : RuntimeException,error.ps1

    Note incorrect line number being reported on second invocation when ErrorActionPreference equals "Stop"

    This can also be reproduced by putting "$ErrorActionPreference = "Stop" at line 3 of the…

    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 →
  10. Bug: Powershell doesn't deal with returning empty arrays from functions to methods

    Given this module:
    class TestClass {

    [object]ReturnEmptyArray() {
    
    $testobject = Get-EmptyArray
    if($testobject -eq $null){
    Write-Host "Is Null"
    }
    return $testObject
    }

    [object]ReturnNull() {
    $testobject = Get-Null
    if($testobject -eq $null){
    Write-Host "Is Null"
    }
    return $testObject
    }

    }

    function Get-EmptyArray {

    return @()
    

    }

    function Get-Null {

    return $null
    

    }

    function Get-TestClass {

    return [TestClass]::new()
    

    }

    Export-ModuleMember Get-BlackDuckProject, Invoke-BlackDuckUrl, Get-TestClass

    the following works as expected:
    $test = Get-TestClass
    $test.ReturnNull()
    (a $null is returned)

    However, the following throws an exception:
    $test.ReturnEmptyArray()
    Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index

    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 →
  11. Bug: wrongly displayed elements in an array with different types

    This issue is easy to reproduce, just simplely put 2 objects of different types in an array variable, output the variable, and then change the 2 elements' order in the array, output the array variable again, you'll see the difference:
    > only the 1st element will be displayed in its correct format; the subsequent elements are displayed in the full output format.

    More details please refer to the gitlab issue:
    https://github.com/PowerShell/PowerShell/issues/7839#issuecomment-424193334

    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 →
  12. Bug: Invoke-WebRequest keeps downloading beyond the file's size

    Migrated from here: https://github.com/PowerShell/PowerShell/issues/7822.

    To repro:

    powershell wget https://storage.googleapis.com/chrome-infra/depot_tools.zip

    The file size is ~19MB, but the download progress goes way beyond that and has to be manually stopped.

    At the same time, (New-Object System.Net.WebClient).DownloadFile() works correctly.

    2 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 →
  13. Receive-Job duplicates Write-Host output

    Starting in PowerShell 5.1, if a background job uses Write-Host, the Receive-Job cmdlet shows each line of output twice.

    Steps to Reproduce


    1. Run this command: Start-Job { 1..10 | % { Start-Sleep -Milliseconds 10 ; Write-Host $_ } } | Wait-Job | Receive-Job

    2. Note the duplicate numbers. This error does not happen in Powershell 6.0.4.

    2 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 →
  14. Allow trailing commas

    Trailing commas in lists are incredibly useful in a large number of instances, and there are very few good reasons and no really strong reasons not to.

    Not allowing trailing commas is inconvenient in many situations: it frequently turns a one-line commit into two, polluting history (all I did was remove a comma from that line); it can complicate (and often put bugs in) code-generation ("$str += $value + "," doesn't cut it)

    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 →
  15. Issue with running commands on remote machine

    Hi Team,

    I am using powershell to trigger commands on remote machine (as this doesn't require anything additional package to install). Recently I am facing issues with running commands on remote machine.

    $ComputerName = "..."

    Function ExecuteCommand() {

    Get-PSDrive
    

    }

    Set-Item WSMan:\localhost\Client\Trustedhosts -Value $ComputerName -Concatenate -Force
    
    

    $Credentials = Import-Clixml $CredentialsFile

    Invoke-Command -ComputerName $ComputerName -Credential $Credentials -ScriptBlock ${function:ExecuteCommand} -HideComputerName

    I am storing the credentials in the file and using the above script to run commands on remote machine.


    1. Get-PSDrive doesn't return mapped network drive details.

    2. using net use command to map network path. Network path gets mapped…
    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 →
  16. 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 →
  17. Code analysis inside of a try block in a class thinks a variable isn't assigned when it is.

    Import-Module says that $variable2 is not assigned, but there is no way to reach its usage in the Write-Host without the variable having a value.

    Class MyClass {

    DoThing() {
    
    $variable1 = "var1"
    try {
    $variable2 = "var2"
    } finally {
    Write-Host "Tidying"
    }

    Write-Host $variable1
    Write-Host $variable2
    }

    }

    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 →
  18. "Using module" statement does not reload module after changes are made

    Problem Description

    If you are using the using module statement, it will load the module without any issues. However, if you make a change to the module and run the using module statement again without restarting your PowerShell session, it will not load the new modified module into memory, and instead will continue to use the old existing module that was loaded. This makes doing development with using module statements very tedious as you must continually reload your PowerShell session whenever you make changes to the module.

    Ideally we would just use Import-Module -Name [module name] -Force to avoid this…

    38 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 →
  19. Backport Powershell 6.x to Windows Powershell

    To keep Windows Powershell up to date please backport any new features from Powershell 6.x to Windows Powershell.

    7 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 →
  20. 1 vote
    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 →
  • Don't see your idea?

Feedback and Knowledge Base