# 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.
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. ## 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"

(thinking…)
Signed in as (Sign out)

We’ll send you updates on this idea

2. ## Private methods in powershell class's don't work

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.

(thinking…)
Signed in as (Sign out)

We’ll send you updates on this idea

3. ## 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
(thinking…)
Signed in as (Sign out)

We’ll send you updates on this idea

4. ## 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 5. ## 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 7 votes Sign in (thinking…) Sign in with: Facebook Google Signed in as (Sign out) We’ll send you updates on this idea 6. ## 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 7. ## 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 8. ## 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. 12 votes Sign in (thinking…) Sign in with: Facebook Google Signed in as (Sign out) We’ll send you updates on this idea 9. ## 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

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
Invoke-Command -ComputerName Machine1 -ScriptBlock $Script As a result you get "Hello world!" but also an error "Attempting to perform the InitializeDefaultDrives operation on the 'FileSystem' provider failed." The error belongs to I drive which should have been returned as a warning and not error. The invoke does not even use the I drive so why fail on it (we in this case dont even want the invoke to have access… 2 votes Sign in (thinking…) Sign in with: Facebook Google Signed in as (Sign out) We’ll send you updates on this idea 12. ## PowerShell StackOverFlowException: get-childitem -path HKLM:\ -recurse -include *Windows* PowerShell has a bug in it which causes a "StackOverFlowException" when running the following command: get-childitem -path HKLM:\ -recurse -include Windows It was originally reproduced while looking for something different than: Windows This is consistently reproducible in latest updates applied of Windows 10 x64 Business and Home, with both PowerShell.exe, and ISE, x86 and standard.$PSVersionTable.PSVersion

Major Minor Build Revision

5 1 16299 98

(thinking…)
Signed in as (Sign out)

We’ll send you updates on this idea

13. ## Move-Item's -Verbose causes $ErrorActionPreference to be ignored Move-Items's -Verbose parameter causes the global$ErrorActionPreference = "Stop" to be ignored. This is a bug. Here's a repro script:

BugRepro.ps1:

$ErrorActionPreference = "Stop" Write-Host "ErrorActionPreference is$ErrorActionPreference"
mkdir folder -ErrorAction SilentlyContinue | Out-Null
"" > a.txt
Copy-Item a.txt folder
Move-Item a.txt folder -Verbose | Out-Null
Write-Host "If you're reading this, then execution didn't stop!"
Write-Host "Remove the Verbose paramter and it does stop, like it should."

(thinking…)
Signed in as (Sign out)

We’ll send you updates on this idea

14. ## 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&quot; more args

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

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

(thinking…)
Signed in as (Sign out)

We’ll send you updates on this idea

15. ## [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


This example creates a DataTable from the properties of Get-Alias and assigns output to $dt variable This idea comes from Chad Miller's Out-DataTable: https://gallery.technet.microsoft.com/scriptcenter/4208a159-a52e-4b99-83d4-8048468d29dd#content 200 votes Sign in (thinking…) Sign in with: Facebook Google Signed in as (Sign out) We’ll send you updates on this idea After much discussion with Aaron Nelson and Chrissy LeMaire, and thanks to the enormous amount of support for this item, we’ve recognized that this is something we need to accomplish, one way or another. We don’t want to offer an ETA on this as the work is not well understood by our team yet, and no one currently has immediate bandwidth on starting that investigation. But I want to stress the fact that is an important ask that we’re taking seriously as a priority. In the meantime, it would be immensely useful if someone with expertise in the DataTable space could submit an RFC (basically a brief spec) to our PowerShell-RFC repository on GitHub. That way, we can have a discussion about what the design of a ConvertTo-DataTable cmdlet might look like before we dive in on an implementation. The process for doing so is located here: https://github.com/PowerShell/PowerShell-RFC/blob/master/RFC0000-RFC-Process.md#draft I… 18. ## Write-Host -NoNewLine and Transcription Starting with WMF 5.0 the -NoNewLine option for Write-Host is essentially ignored in the transcripts created using Start-Transcript. Simple example script: Start-Transcript log.txt Write-Host -NoNewLine "this should all" Write-Host -NoNewLine "be on one line" Write-Host -NoNewLine "in the log.txt file" Stop-Transcript 12 votes Sign in (thinking…) Sign in with: Facebook Google Signed in as (Sign out) We’ll send you updates on this idea 19. ## Start-Process is behaving strange when -credential switch is used When running Start-Process start-process "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -cred$(Get-Credential) regardless if the credentials differ from the current consoles credentials or the same credentials are used, the new console window seems to be unresponsive, until you switch back to the console from which the new console was launched and start typing something in that console.

If the same thing is done in ISE, this issue does not occour.

I have testet this on PS 5.1.14393.206, 5.1.14393.953 and 5.1.14393.693. Windows Server 2012R2, Windows Server 2016 and Windows 10

Please see the issue in this video: https://goo.gl/8ZvdEV

(thinking…)
Signed in as (Sign out)

We’ll send you updates on this idea

20. ## Include UTC timestamp as property to error object

It'd be very helpful to attach a timestamp of when an error occured to an error object. Open to ideas as to whether it should be UTC, local time, ntp, etc.