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. powershell get-childitem works unexpected differently

    Hi there

    Im working with WindowsPE and have to identify my USB-Drive.

    So I´m looking for the drive and assign a variable:

    $usbdrive = (Get-WmiObject -class Win32LogicalDisk -filter DriveType=2 | Foreach {Get-ChildItem -Filter *.wim -r -d 1 $.DeviceID} 2>$null | Where {$.name -eq "boot.wim"}).PsDrive.Root

    With Powershell 5.1.14393.2791 its working as expected. With 5.1.18361.1 not.

    The reason is this part:

    Get-WmiObject -class Win32LogicalDisk -filter DriveType=2 | Foreach {Get-ChildItem -Filter *.wim -r -d 1 $.DeviceID}

    The Reason is handling of $_.Deviceid. On both versions the Result is c:

    On both versions Get-Childitem C: gets the entries…

    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 →
  2. 'Using module' does not work when having multiple levels of inheritance

    When having more than one level of inheritance, 'Using module' does not work as expected.

    Example:

    Class A is defined in module A.
    Class B is defined in module B.
    Class C is defined in module C.

    A.psm1
    class A {}

    B.psm1
    Using module 'A'

    class B : A {}

    C.psm1
    Using module 'B'

    class C : B {}

    With the above example class C only inherits the properties and methods from B class and not from A class.

    The reason for separating the classes in different modules is to allow their reuse in other modules.

    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 →
  3. 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 →
  4. "using module" does not take variable as parameter

    The "using module" statement does not take a variable as a parameter for the module name, which is inconvenient if you're writing scripts based on taking modules from variable DFS paths based on the environment (usign different Active Directory forests as the root for the paths for instance).

    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. Merge "Windows PowerShell" and "PowerShell Core", make result default on Windows

    When sending code to someone, I don't want to have to qualify the post with "if it doesn't work, try the other PowerShell...". I know there will be OS-specific modules/commands, but there should not be two code bases for the shell itself, or two product names.

    16 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 →
  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. 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.

    3 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 →
  8. 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 →
  9. 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 →
  10. 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 →
  11. 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 →
  12. Inconsistent Array Initialization Behaviour

    Creating an array of arrays as below works well:

    $myArray = @(
    
    @(1,2,3),
    @(4,5,6)
    )
    $myArray[0] #outputs 1, 2, 3
    $myArray[1] #outputs 4, 5, 6

    $myBuggyArray = @(
    @(1,2,3)
    ,@(4,5,6)
    )
    $myBuggyArray[0] #outputs 1
    $myBuggyArray[3] #outputs 4, 5, 6

    I wouldn't expect the order of line break & comma to impact the behaviour of the command / can't find any documentation stating that it should.

    PSVersion: 5.1.14409.1012

    8 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 →
  13. Bug: -Exclude does not work as -Include does in Get-ChildItem, or as expected

    Three folders; d1, d2, d3, with files test.txt and test.mp3 in in d1 and d3.

    '-Include d1' includes only content from d1. Would expect '-Exclude d1' to include the inverse, but it has no effect, it returns all data.

    unless it's run after -Include.

    So '-Include d1 -Exclude d1' returns nothing, as expected.

    Exclude only works as it applies to a file name, not a path.

    So '-Exclude .txt' will exclude all files '.txt' as expected.

    The syntax usage in the help file is identical for both parameters.

    Please fix -Exclude parameter so that it works…

    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. Terminating error in if statement script block generates duplicate errorvariable entries

    Consider the following 2 functions (contrived to illustrate the issue).

    function 1error { [CmdletBinding()] Param(); throw "This produces 1" }
    function 2error { [CmdletBinding()] Param(); if($true) {throw "This produces 2"} }

    If you call the function 1error with an error variable, the error variable will act as expected.

    1error -ErrorVariable +1var
    $1var.count #results in 1

    If you call function 2error with an error variable, the error variable will have 2 identical errors.

    2error -ErrorVariable +2var
    $2var.count # results in 2

    PSVersion is 5.1.14393.2189

    5 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 →
  15. format-volume whatif

    format-volume with option -whatif not working. It's should "Shows what would happen if the cmdlet runs. The cmdlet is NOT RUN."

    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 →
  16. Add 'StopExisting' as a valid argument for New-ScheduledSettingsSet -MultipleInstances

    Only Parallel, Queue, and IgnoreNew are supported right now. One would expect that the option available from the Task Scheduler GUI would be available in the powershell interface.

    Steps to reproduce

    $a = New-ScheduledTaskSettingsSet -MultipleInstances StopExisting

    Expected behavior

    The task's multiple instances policy is set to kill existing tasks before starting another instance.
    Actual behavior

    value "StopExisting" to type "Microsoft.PowerShell.Cmdletization.GeneratedTypes.ScheduledTask.MultipleInstancesEnum".
    Error: "Unable to match the identifier name StopExisting to a valid enumerator name. Specify one of the following
    enumerator names and try again:
    Parallel, Queue, IgnoreNew"
    At line:1 char:131
    + ... ngOnBatteries -ExecutionTimeLimit $b -MultipleInstances StopExisting
    + ~~~~~~~~~~~~

    + CategoryInfo
    6 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 →
  17. copy-item progress

    Add an optional switch to show the progress of an ongoing copy operation. Could be useful for large operation. Basically replicate as much information as the Explorer does, without the performance graph.

    13 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. Powershell write-progress memory leak in remote sessions

    Hello, I have noticed some strange behavior with Powershell when run in a remote session, it seems as if there is a memory leak with write-progress when run in a remote session.

    Take the following code for example:

    $MaxVal = 10000000

    for ($x=1;$x -le $MaxVal;$x++)
    {

    Write-Progress -Activity "Writing a progress event" -PercentComplete ($x / $MaxVal * 100) -Status "$($x / $MaxVal * 100)% complete"
    

    }

    If I run this locally, powershell.exe runs normally and does not take up much memory.

    However, if I run it on the same computer from a remote session (as in, I do an enter-psesssion…

    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 →
  19. BUG: PowerShell stderr redirect to file inserts newlines

    If I run the following command in PowerShell:

    $ .\longerrormessage.exe 2>error.txt

    , I get spurious newlines in error.txt. I generated a full repro and extremely clumsy solution at [1]. Can we declare this behavior as a bug? Note that cmd.exe operates exactly as one would expect.

    [1] https://stackoverflow.com/questions/48655624/powershell-stderr-redirect-to-file-inserts-newlines

    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 →
  20. [Bug] Bitwise AND operation on long value is ignored when Most-Significant 32 bits is masked with zero

    [Bug] Bitwise AND operation on long value is ignored when Most-Significant 32 bits is masked with zero

    Sample Code to replicate issue:

    Should return: @(1,1,168,192,0,0,0,0)
    Actually returns : @(1,1,168,192,255,255,255,255)

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

Feedback and Knowledge Base