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.

Please feel free to provide feedback or file bugs here.

(thinking…)

Enter your idea and we'll search to see if someone has already suggested it.

If a similar idea already exists, you can support and comment on it.

If it doesn't exist, you can post your idea so others can support it.

Enter your idea and we'll search to see if someone has already suggested it.

  • Hot ideas
  • Top ideas
  • New ideas
  • My feedback
  1. using module <Module> does not work as expected

    I have a problem with loading classes from a module.

    Script is just two lines as following:
    using module AzureAD
    class TestClass { [Microsoft.Open.AzureAD.Model.Application] static DoIt() { return $null; } }

    If I run this, using .\Script.ps1 I get the following error:
    At C:\path\Script.ps1:3 char:20
    + class TestClass { [Microsoft.Open.AzureAD.Model.Application] static D ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Unable to find type [Microsoft.Open.AzureAD.Model.Application].
    + CategoryInfo : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : TypeNotFound

    However, if I run "using module AzureAD" from the command line first and then run the script, it works fine...

    What is the difference in running using module from…

    1 vote
    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)

      We’ll send you updates on this idea

      0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
    • very inconsistent drive letter usage

      Hi there

      in this case I have to remove and reinstall an OS while booting from usb stick. But this is only one example - it´s not the first time im seeing this behaviour.

      if (Test-path c:) {Get-Volume -DriveLetter c | Get-Partition | Remove-PartitionAccessPath -AccessPath c:\}

      In this line the term C is used three times

      First time as c: (here would be c:\ also possible)
      Second time as c (neither c: nor c:\ is working here)
      Third time as c:\ (neither c nor c: is working here)

      I´m working with variables - this means I have to create 3…

      1 vote
      Sign in
      Check!
      (thinking…)
      Reset
      or sign in with
      • facebook
      • google
        Password icon
        I agree to the terms of service
        Signed in as (Sign out)

        We’ll send you updates on this idea

        2 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
      • Make Import-DSCResource dynamic keyword parameter -ModuleVersion mandatory or generate parsing warning

        Configurations expire when the DSCResource modules they import change. It would be very welcomed if a warning was generated by the pasrser when the Import-DSCResource keyword was used without specifying either the Fully Qualified Module Name (FQMN) or the ModuleVersion parameter/Argument pair. This would simplfy managing different versions of a configuration both on the build server as well consuming blog posts that have you guessing what version of the Module was being used.

        1 vote
        Sign in
        Check!
        (thinking…)
        Reset
        or sign in with
        • facebook
        • google
          Password icon
          I agree to the terms of service
          Signed in as (Sign out)

          We’ll send you updates on this idea

          0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
        • PS 5 assigning to list value while PS 4 isn´t

          Hi!

          We recently got WMF 5.1 (KB3191566) that included PS 5.
          We then began finding differences in the behavior of PS 5 and PS 4 when running our scripts. The result was different.

          We didn´t notice this problem since someone wrapped it in a try catch block... So to recreate this issue/bug I made this script and ran it on one host with PS 5 and one VM host on PS 4.

          add-type -Language CSharpVersion3 -TypeDefinition @"
          public class TestClass
          {
          public System.Collections.Generic.List<System.Int32> listObject { get; set; }
          }
          "@

          [string]$string = "1"

          $classWithList = New-Object TestClass

          $classWithList.listObject = $string

          1 vote
          Sign in
          Check!
          (thinking…)
          Reset
          or sign in with
          • facebook
          • google
            Password icon
            I agree to the terms of service
            Signed in as (Sign out)

            We’ll send you updates on this idea

            1 comment  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
          • PS5: Get-Help <anycommand> -ShowWindow doesn't display help

            When executing "Get-Help <anycommand> -ShowWindow", the resulting window doesn't contain any help text.

            1 vote
            Sign in
            Check!
            (thinking…)
            Reset
            or sign in with
            • facebook
            • google
              Password icon
              I agree to the terms of service
              Signed in as (Sign out)

              We’ll send you updates on this idea

              0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
            • [Bug] IE automation script will no longer work in PowerShell version 5

              To be better notified of incoming tickets in our ticket system I developed a script that opens a hidden IE instance:

              $ie = New-Object -ComObject InternetExplorer.Application
              (I tried the respective registry entry and "$ie = new-object -Com InternetExplorer.ApplicationMedium", no better.)

              (This input box is too small.)

              After some script statements to log in and navigate to the incoming tickets monitor, I do a

              $newcalls = $ie.Document.getElementsByName("callid")

              (This input box is too small.)

              That's working perfectly fine in PowerShell version 4, but in v5 I get

              Exception from HRESULT: 0x800A138A
              At <path>.ps1:89
              char:5
              + $newcalls = $ie.Document.getElementsByName("callid")
              + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              + CategoryInfo…

              1 vote
              Sign in
              Check!
              (thinking…)
              Reset
              or sign in with
              • facebook
              • google
                Password icon
                I agree to the terms of service
                Signed in as (Sign out)

                We’ll send you updates on this idea

                5 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
              • Catch illegal syntax in array definition

                Today I had an issue where getting an element at a certain index in a typed array failed. As I was troubleshooting this issue I found that it was simply because I had used a '.' (dot) instead of a ',' (comma) to separate the elements when I defined the typed array variable.
                Okay, that is a clear mistake on my part. However, as I thought about it I would have loved to be alerted by the Powershell engine .

                -- Experienced on v5.1.14409.1012 of PowerShell
                -- Win7 x64 OS

                TO REPRODUCE:

                open vscode
                create ps1 file
                $array = "hej",…

                1 vote
                Sign in
                Check!
                (thinking…)
                Reset
                or sign in with
                • facebook
                • google
                  Password icon
                  I agree to the terms of service
                  Signed in as (Sign out)

                  We’ll send you updates on this idea

                  0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
                • [BUG] Drag and drop to scripts shortcuts split paths containing spaces

                  Drag and dropping any file to a script shortcut split this path before passing the splitted strings as multiple parameters. Here's my detailed Issue Report :

                  Steps to reproduce
                  ------------------

                  1 - Get any script, for example :
                  [samplescript.psd1] :
                  ```
                  param([string]$path)
                  Write-Host($path)
                  pause
                  ```
                  or a simpler one-line sample: ```Write-Host($args);pause```

                  2 - Create a shortcut that runs the script :
                  [Shortcut Target ] : ```PowerShell "path\to\our\samplescript.psd1"```

                  3- Drag and drop a file containing spaces in its name to the shortcut
                  [sample file ] : ```C:\Some file with spaces.txt```

                  Expected behavior
                  -----------------

                  Drag and dropping the file should pass its…

                  2 votes
                  Sign in
                  Check!
                  (thinking…)
                  Reset
                  or sign in with
                  • facebook
                  • google
                    Password icon
                    I agree to the terms of service
                    Signed in as (Sign out)

                    We’ll send you updates on this idea

                    1 comment  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
                  • Can you add some stuff to Get-ClipBoard?

                    I would have liked the default behaviour to be that an array of newline-split strings was returned from Get-ClipBoard. 97 % of the time I end up writing (Get-ClipBoard) -split "\r?\n" | ...... often filtering out empty elements - and that's just boring.

                    In my own version I used -Raw for a string and nothing for an array/list.

                    Of course you can't change that now in the 5.x version (or later, sigh, will this be our doom in some distant future), but can you maybe add at least -AsArray or similar? Make it so it can only be used with…

                    3 votes
                    Sign in
                    Check!
                    (thinking…)
                    Reset
                    or sign in with
                    • facebook
                    • google
                      Password icon
                      I agree to the terms of service
                      Signed in as (Sign out)

                      We’ll send you updates on this idea

                      0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
                    • Fix .NET date formatting bug in .ToString()

                      PS D:\> gcim win32_operatingsystem | % caption
                      Microsoft Windows Server 2016 Standard

                      PS D:\> $PSVersionTable.PSVersion

                      Major Minor Build Revision
                      ----- ----- ----- --------
                      5 1 14393 1358

                      PS D:\> [DateTime]::Now.ToString('yyyy-MM-dd HH:mm:ss')
                      2017-07-27 12.29.37

                      9 votes
                      Sign in
                      Check!
                      (thinking…)
                      Reset
                      or sign in with
                      • facebook
                      • google
                        Password icon
                        I agree to the terms of service
                        Signed in as (Sign out)

                        We’ll send you updates on this idea

                        9 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
                      • Remote Powershell Session "-ErrorAction Stop" give Non-Terminating Error

                        Script with Remote Powershell that are using Try/Catch and (of course) Terminating error, but for some reason under PSv5.1 Shell now those "-ErrorAction Stop" aren’t producing Terminating Error.

                        I need to force $ErrorActionPreference = “Stop” to have my Try/Catch to work.

                        1 vote
                        Sign in
                        Check!
                        (thinking…)
                        Reset
                        or sign in with
                        • facebook
                        • google
                          Password icon
                          I agree to the terms of service
                          Signed in as (Sign out)

                          We’ll send you updates on this idea

                          0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
                        • Powershell does not interpret set variables

                          Powershell has (optionally) replaced cmd as a standard shell in Windows 10.

                          However it is a pity that Powershell is not able to interpret commands that rely on usage of variables that are defined in "set"

                          like %computername%, %windir%, %userprofile%, %appdata% etc
                          etc

                          Please respect your own system variables in use for decades Microsoft. Thank you a lot.
                          There must be way without breaking this.

                          try issuing a simple

                          cd %appdata%

                          in powershell (often used in KB articles), good luck and have fun (or not).

                          Imho while I could understand limitations this is pretty odd.

                          2 votes
                          Sign in
                          Check!
                          (thinking…)
                          Reset
                          or sign in with
                          • facebook
                          • google
                            Password icon
                            I agree to the terms of service
                            Signed in as (Sign out)

                            We’ll send you updates on this idea

                            5 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
                          • Command line parsing bug: spaces and trailing slash

                            There appears to be a bug parsing arguments to EXEs. If you pass a properly-quoted path that has spaces and a trailing slash, the rest of the command is lumped into the same argument. This also happens if you use a PowerShell variable to hold the path string.

                            To repro, first, install EchoArgs.exe (if using chocolatey: cinst -y echoargs). It demonstrates what arguments would get passed to any exe.

                            Then run:

                            PS> & EchoArgs "C:\spaces and trailing slash\" more args

                            Echo args shows that it all got lumped into one argument:

                            Arg 0 is <C:\spaces and trailing slash" more args>

                            6 votes
                            Sign in
                            Check!
                            (thinking…)
                            Reset
                            or sign in with
                            • facebook
                            • google
                              Password icon
                              I agree to the terms of service
                              Signed in as (Sign out)

                              We’ll send you updates on this idea

                              0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
                            • Make the Continue statement work in ForEach-Object

                              Within in ForEach-Object script block, "continue" behaves like "break", and one should use "return" to simulate "continue". But, from my perspective, it would make sense to give "continue" foreach-object awareness

                              3 votes
                              Sign in
                              Check!
                              (thinking…)
                              Reset
                              or sign in with
                              • facebook
                              • google
                                Password icon
                                I agree to the terms of service
                                Signed in as (Sign out)

                                We’ll send you updates on this idea

                                0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
                              • Bug: New-PSDrive mounts locally scoped, even though it is supposed to be across a powershell Session.

                                Confirmed that PSDrive is only scope locally in the class method is was called in:

                                Test Setup:

                                Mount(): HKU, HKCC, HKCUHKLM in class method. Display PSDrive mounts.
                                Call Test() within that Mount(), which mounts HKCR; Display PSDrive in method call.
                                Display PSDrive mounts on Test() return
                                Display PSDrive mounts on Mount() return
                                Call Test() method from main, Display PSDrive mounts.
                                Display PSDrive mounts on Test() return
                                VERBOSE: Mounting registry drives for use ...
                                VERBOSE: HKU
                                VERBOSE: HKCC
                                VERBOSE: HKCU
                                VERBOSE: HKLM
                                Alias C Cert Env Function HKCC HKCU HKLM HKU Variable WSMan (Scope: Mount())
                                Alias C Cert Env Function HKCC…

                                1 vote
                                Sign in
                                Check!
                                (thinking…)
                                Reset
                                or sign in with
                                • facebook
                                • google
                                  Password icon
                                  I agree to the terms of service
                                  Signed in as (Sign out)

                                  We’ll send you updates on this idea

                                  0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
                                • Slow "." hash lookups

                                  Slow "." hash lookups (more than 100 times slower than []) from PowerShell Version 2 to Version 5.1

                                  This could be either a documentation problem or a bug. The documentation never says that the "." hash lookup can be much slower than the [] lookup. I hope it is a bug (one less thing to remember). They both worked at the same speed in PS Version 2.0 and diverged sometime after that.

                                  Two script files. The first calls the second forcing versions 1 thru 5 of PowerShell.

                                  The "." hash lookups in PS Version 2.0 take .028 seconds.
                                  The "."…

                                  1 vote
                                  Sign in
                                  Check!
                                  (thinking…)
                                  Reset
                                  or sign in with
                                  • facebook
                                  • google
                                    Password icon
                                    I agree to the terms of service
                                    Signed in as (Sign out)

                                    We’ll send you updates on this idea

                                    0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
                                  • Provide a native ternary operator

                                    It would be very nice and convenient if PowerShell had a native ternary operator like C# does (https://msdn.microsoft.com/en-us/library/zakwfxx4(v=vs.100).aspx).

                                    Basically it would allow you to write a short-hand if-else statement, so instead of having to write:

                                    if ($someBoolCondition)
                                    {
                                    $x = $y.Property1
                                    }
                                    else
                                    {
                                    $x = $y.Property2
                                    }

                                    you could just write:

                                    $x = $someBoolCondition ? $y.Property1 : $y.Property2

                                    This operator is fairly standard in many programming languages, so it would be awesome if PowerShell could come up to speed with it as well. Thanks.

                                    2 votes
                                    Sign in
                                    Check!
                                    (thinking…)
                                    Reset
                                    or sign in with
                                    • facebook
                                    • google
                                      Password icon
                                      I agree to the terms of service
                                      Signed in as (Sign out)

                                      We’ll send you updates on this idea

                                      2 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
                                    • Do not require starting brace to be on same line as cmdlet

                                      It is very annoying and confusing that some cmdlets require the starting brace to be on the same line as the cmdlet, while others do not.

                                      For example, this is valid:

                                      ... | ForEach-Object {
                                      $sourcefile = $_.Name
                                      }

                                      but this is not:

                                      ... | ForEach-Object
                                      {
                                      $sourcefile = $_.Name
                                      }

                                      yet using this is valid:

                                      foreach ($x in $y)
                                      {
                                      $sourcefile = $_.Name
                                      }

                                      I know that you can use the backtick to make it valid, like this:

                                      ... | ForEach-Object `
                                      {
                                      $sourcefile = $_.Name
                                      }

                                      but that's still not intuitive and requires you to remember to do…

                                      1 vote
                                      Sign in
                                      Check!
                                      (thinking…)
                                      Reset
                                      or sign in with
                                      • facebook
                                      • google
                                        Password icon
                                        I agree to the terms of service
                                        Signed in as (Sign out)

                                        We’ll send you updates on this idea

                                        0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
                                      • Foreach Does Not Run If Statements For Array Elements

                                        Copy and run with -Debug. You'll see...

                                        function Get-ArrayDups([array]$ArrayCheck, $IOI) {
                                        $indices = @()

                                        For($i=0;$i -le $ArrayCheck.Length; $i++) {If ($IOI -eq $ArrayCheck[$i]) {$indices += $i}}
                                        "Variable `$indices = " + $indices
                                        "`$ArrayCheck[0] = " + $ArrayCheck[0]
                                        "`$ArrayCheck[9] = " + $ArrayCheck[9]
                                        }

                                        Function Get-ArrayDups {
                                        [cmdletbinding()]
                                        Param(
                                        [Parameter(ValueFromPipeline = $true)]
                                        [Array]
                                        $ArrayContent,

                                        [int]
                                        $IOI
                                        )
                                        BEGIN { [array]$indices = @()
                                        $Len = $ArrayContent.Count
                                        $i = 0
                                        Write-Debug "Initial Value: `$Len = $Len"
                                        Write-Debug "Initial Value: `$ArrayContent[`$Len] = $($ArrayContent[$Len-1])"
                                        Write-Debug "Initial Value: IOI is $IOI"
                                        Write-Debug "Initial Value: The full passed in array is $ArrayContent"
                                        Write-Debug "Initial Value: Length of `$indices…

                                        1 vote
                                        Sign in
                                        Check!
                                        (thinking…)
                                        Reset
                                        or sign in with
                                        • facebook
                                        • google
                                          Password icon
                                          I agree to the terms of service
                                          Signed in as (Sign out)

                                          We’ll send you updates on this idea

                                          0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
                                        • ExecutionPolicyOverride-Problem with GPO in place on Server 2016

                                          I'm preparing some "Windows Server 2016" machines. While testing I stumbled across some issues with PowerShell.
                                          I invested some time and narrowed it down a bit.

                                          I also posted the issue on Microsoft Technet Forum and got the recommendation to file a Bug/Request here. Other users were also able to reproduce it quite easily:
                                          (see: https://social.technet.microsoft.com/Forums/en-US/842c2cc2-c7f6-41b7-9561-31b2c65262b0/executionpolicyoverrideproblem-with-gpo-in-place-?forum=winserverpowershell)

                                          Steps to reproduce:

                                          I create a new VM, insert the Server 2016 ISO, boot up and install. After first start I change the network-settings for my environment and join the domain. I move the new computer-object to an OU where the group policy…

                                          3 votes
                                          Sign in
                                          Check!
                                          (thinking…)
                                          Reset
                                          or sign in with
                                          • facebook
                                          • google
                                            Password icon
                                            I agree to the terms of service
                                            Signed in as (Sign out)

                                            We’ll send you updates on this idea

                                            0 comments  ·  PowerShell Engine  ·  Flag idea as inappropriate…  ·  Admin →
                                          ← Previous 1 3 4 5 16 17
                                          • Don't see your idea?

                                          Feedback and Knowledge Base