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

We’ll send you updates on this idea

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

(thinking…)
Signed in as (Sign out)

We’ll send you updates on this idea

3. ## 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…

(thinking…)
Signed in as (Sign out)

We’ll send you updates on this idea

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

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

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

7. ## 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 8. ## 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 9. ## 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 10. ## 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 11. ## 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 15. ## 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

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

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

18. ## [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 &quot;path\to\our\samplescript.psd1&quot; 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 path to the… 4 votes Sign in (thinking…) Sign in with: Facebook Google Signed in as (Sign out) We’ll send you updates on this idea 19. ## Add ExportTo-Markdown Hi Using Markdown is common nowadays in VCS tools like Git for readme files. Plus it's handy to get a tabular strcture for better visibility. Example use cases: - Get-Process output comparison at different dates and time - SQL query results in tabular form with column names as headers So it'd be someInput|ExportTo-MarkDown 2 votes Sign in (thinking…) Sign in with: Facebook Google Signed in as (Sign out) We’ll send you updates on this idea 20. ## Out-DataTable Creates a DataTable based on an objects properties. Useful for converting any Powershell object into a DataTable which then can be bulk imported into a SQL Server table. .EXAMPLE$dt = Get-PSDrive | Out-DataTable
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

(thinking…)
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…