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. Get-UICulture DateTimeFormat ShortTimePattern cannot set 24h format

    On Windows 10 / Server 2012 / 2016 I can set the "short time format" by using the Get-UICulture and Set-Culture commandlets to the 12 hour format with AM/PM indicators.
    However, I can not change it from 12 hour format to 24 hour format. It remains in the 12 hour format - meanwhile there is no problem to set the 24h format from the Settings app in Windows.

    (In contrast to that, the LongTimePattern works fine both ways)

    Steps to reproduce

    (Get-UICulture).DateTimeFormat | Select ShortTimePattern,LongTimePattern | fl
    $modCulture = Get-UICulture
    ($modCulture.DateTimeFormat).ShortTimePattern = "h:mm"
    ($modCulture.DateTimeFormat).LongTimePattern = "h:mm:ss"
    Set-Culture $modCulture

    (Get-UICulture).DateTimeFormat |…

    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  ·  Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
  2. Powershell 5.1-14409-1018 throws "The type initializer for 'System.Management.Automation.Runspaces.LocalRunspace' threw an exception."

    Randomly we're seeing "The type initializer for 'System.Management.Automation.Runspaces.LocalRunspace' threw an exception." when trying to start powershell. It's not always the same command.

    Example command:

    powershell.exe -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -InputFormat None -Command "[System.Environment]::GetEnvironmentVariable('ChocolateyInstall', 'MACHINE')"

    Server 2K12R2. Doesn't happen every time, even running the same command multiple times in a row, not able to correlate to anything that's going on with the system at the time.

    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  ·  Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
  3. Update-Help doesn't work for some modules because HTTP redirection on module's Help URI

    Update-Help doesn't work for some modules because there're >10 redirection on module's given Help URI.
    On my machine concerned modules are:
    ConfigDefender, Defender, HgsClient, HgsDiagnostics, Microsoft.PowerShell.Operation.Validation, ShieldedVMDataFile, UEV, Whea, WindowsDeveloperLicense.
    Step to reproduce:
    -Open Windows Powershell 5.1.18362.628 on a Windows 10 1909 machine
    -Type: Update-Help -UICulture en-US -Scope AllUsers -Force -Verbose -Debug

    Expected behavior: Help is updated
    Actual behavior: You receive this error: "Update-Help: Failed to update Help for the module(s) 'ConfigDefender, Defender, HgsClient, HgsDiagnostics, Microsoft.PowerShell.Operation.Validation, ShieldedVMDataFile, UEV, Whea, WindowsDeveloperLicense' with UI culture(s) {en-US} : A Help URI cannot contain more than 10 redirections. Specify a valid Help URI.."

    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  ·  Microsoft.PowerShell.* Modules  ·  Flag idea as inappropriate…  ·  Admin →
  4. Why I have to create a path if not present using Move-Item

    Why we need to create a path prior to moving a file from one location to other, if the destination doesn't have the relative path created using Move-item in powershell scripting.

    For e.g. I have a source path as "E:\abc\0000\xyz.txt" and destination where it should be copied has a folder "D:\vfd". Now with Move Item I need to copy the xyz.txt using relative path as

    Move-Item "E:\abc\0000\xyz.txt" -Destination "D:\vfd\0000\xyz.txt"

    Now the above command will error since Destination doesn't have the 0000 directory.

    In Unix if destination path is not present then it creates the required path and move the item.…

    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  ·  Microsoft.PowerShell.* Modules  ·  Flag idea as inappropriate…  ·  Admin →
  5. Remove-Variable unexpected behaviour when the same variable name is created with the same value

    Code run first:
    $x = 2
    Add-Member -InputObject $x -MemberType ScriptMethod -Name "Get" -Value {$this}
    $x.Get()
    Remove-Variable x
    $x
    Error: The variable '$x' cannot be retrieved because it has not been set.

    Trying again:
    $x = 2
    Add-Member -InputObject $x -MemberType ScriptMethod -Name "Get" -Value {$this}
    Error: Add-Member : Cannot add a member with the name "Get" because a member with that name already exists.
    $x.Get()
    Remove-Variable x
    Error: The variable '$x' cannot be retrieved because it has not been set.

    $x = 1
    $x.Get()
    Error: Method invocation failed because [System.Int32] does not contain a method named 'Get'.

    So the…

    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  ·  Microsoft.PowerShell.* Modules  ·  Flag idea as inappropriate…  ·  Admin →
  6. Compress-Archive | handle if directory contains symbolic link(s)

    Copying directories that contain sub-directories that contain symbolic links... Getting "Access to path '{path}' is denied". Was using Get-ChildItem to exclude a directory and tried to use it to ignore symbolic links but it seems like it not play nice with -Recurse.. Cant Compress-Archive just ignore symbolic links?

    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  ·  Microsoft.PowerShell.* Modules  ·  Flag idea as inappropriate…  ·  Admin →
  7. set-PSrepository doesn't respect verbose parameter

    the "set-PSrepository" cmdlet of the "powershellget" module does not respect the verbose parameter. OS is windows 10.1809.

    steps to reproduce:
    PS C:\Users\Administrator> $PSversiontable

    Name Value


    PSVersion 5.1.17763.1007
    PSEdition Desktop
    PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
    BuildVersion 10.0.17763.1007
    CLRVersion 4.0.30319.42000
    WSManStackVersion 3.0
    PSRemotingProtocolVersion 2.3
    SerializationVersion 1.1.0.1

    PS C:\Users\Administrator> get-command -name 'set-PSrepository'

    CommandType Name Version Source


    Function Set-PSRepository 2.2.2 powershellget

    PS C:\Users\Administrator> powershellget\set-PSrepository -name 'PSgallery' -installationpolicy 'untrusted' -verbose:$false
    VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'True'; IsRegistered = 'True'.
    VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'True'; IsRegistered = 'True'.
    PS…

    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  ·  Package Management  ·  Flag idea as inappropriate…  ·  Admin →
  8. Bug: ConvertTo-Json produces invalid JSON output for WmiObject

    The following command fails RFC 8259 validation due to escaping problems. This issue can be easily reproduced by pasting the output into a json validator such as jsonlint.com or jsonformatter.curiousconcept.com

    Get-WmiObject -Class Win32_Bios | ConvertTo-Json

    Error: Parse error on line 26:
    ..."Path": { "Path": "\\TST-SRV-01\roo
    ----------------------^
    Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'

    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  ·  WMI  ·  Flag idea as inappropriate…  ·  Admin →
  9. Problem passing Arguments to Win10 Secondary Tile App

    I am trying to launch the Win10 bluetooth configuration page via PowerShell shortcut.

    In a nutshell:

    start-process -FilePath "shell:appsFolder\windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel" -ArgumentList "Page=SettingsPageDevices"

    does open the device settings, but the argument to navigate to the Bluetooth Devices is not taken.

    Background: I exported the tile settings using:
    Export-StartLayout -UseDesktopApplicationID -Path m:\layout.xml
    That gave me:
    <start:SecondaryTile AppUserModelID="windows.immersivecontrolpanelcw5n1h2txyewy!microsoft.windows.immersivecontrolpanel" TileID="SystemSettingsL2_SettingsPageDevices" DisplayName="" Size="2x2" Column="2" Row="0" Arguments="page=SettingsPageDevices" Square71x71LogoUri="ms-appx:///" Square150x150LogoUri="ms-appdata:///local/SettingsTiles/Devices.png" Wide310x150LogoUri="ms-appdata:///local/SettingsTiles/wide.Devices.png" Square310x310LogoUri="ms-appx:///" ShowNameOnSquare150x150Logo="true" ShowNameOnWide310x150Logo="true" BackgroundColor="#00000000" ForegroundText="light" />

    When I call the above to start it in the same way, I am not getting to the arguments being applied. I tried many different notation for the args…

    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  ·  Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
  10. How can i write logs to single file using foreach-object parallel?

    Issue
    I am trying to write logs to a single log file using the PSlogging PowerShell module.

    The Script is using the Foreach-object parallel.

    The script works, But sometimes the script gets stuck in between.

    Please help me to resolve it? Is there a better way to achieve this?

    Powershell core 7

    code

    ```
    $sScriptVersion = '1.0'

    $sScriptVersion = '1.0'
    $sLogName = 'custom.log'
    $sLogPath = "C:\Users\Dixon\Desktop\automation\azure\log"
    $sLogFile = Join-Path -Path $sLogPath -ChildPath $sLogName

    Start-Log -LogPath $sLogPath -LogName $sLogName -ScriptVersion $sScriptVersion

    $allServers = $(Get-AzVM -Status)

    try {

    $allServers | ForEach-Object -parallel {
    
    

    $sScriptVersion = &#39;1.0&#39;
    $sLogName = &quot;parallel-&quot; + $_.Name +&quot;.log&quot; …

    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  ·  Microsoft.PowerShell.* Modules  ·  Flag idea as inappropriate…  ·  Admin →
  11. Smartcard support

    Add Smartcard support to Get-Credential in Powershell 7. Add a cmdlet for enumerating certificates on a smartcard

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

    We’ll send you updates on this idea

    0 comments  ·  Microsoft.PowerShell.* Modules  ·  Flag idea as inappropriate…  ·  Admin →
  12. Invoke-DscResource always create a CimSession to invoke the DSC resource using WSMan over HTTP

    I am trying to install SQLServer 2019 on Windows Server 2019 using ansible and SqlServerDsc I am getting aN error about missing CimClass MSFT_SqlSetup.

    The error happens when ONLY HTTPS listener is active (The HTTP listener is deleted)

    The investigation from Ansible team shows that the problem comes down to Invoke-DscResource always creating a CimSession to invoke the DSC resource using WSMan over HTTP by the default configured port. The only thing we can control is the port but even then it won't work for the HTTPS listener as the wrong protocol will be used.

    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  ·  Desired State Configuration (DSC)  ·  Flag idea as inappropriate…  ·  Admin →
  13. 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  ·  Microsoft.PowerShell.* Modules  ·  Flag idea as inappropriate…  ·  Admin →
  14. When running exe in scriptblock antimalware executable gets triggered

    I'm attempting to run an executable remotely on a machine that needs updating. Whenever the exe is called, Antimalware Service Executable pops up on the remote machine for a moment, and then nothing else happens.

    Code is attached. Unsure if this is user error/known issue/isolated bug

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

    We’ll send you updates on this idea

    1 comment  ·  Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
  15. Console applications with a file association start a new cmd window. This is unhelpful.

    I have a simple win32 console application (example.exe) which just printf's all its arguments. In the windows registry I've set up a file association so that the file extension ".myfile" invokes "example.exe %1".

    In a CMD window running .\example.exe file.myfile displays the output in the cmd window. (this is good)
    In a CMD window running .\file.myfile invokes example.exe and displays the output in the cmd window. (this is good)

    In a Powershell window running .\example.exe file.myfile displays the output in the powershell window. (this is good)
    In a powershell window running .\file.myfile opens a new cmd window, in which example.exe…

    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  ·  Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
  16. Get-ChildItem -Recurse -Attributes Directory lists $RECYCLE.BIN

    Hello!

    With Powershell 6, my target ist to list all folders.

    I find no way to exclude $RECYCLE.BIN
    :
    Get-ChildItem -LiteralPath 'D:&#39; -Recurse -Attributes !Hidden+!System+!ReadOnly+!Encrypted+!IntegrityStream+Directory `

    -ErrorAction SilentlyContinue
    

    Thank You for advice me

    Erhie

    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 →
  17. Powershell much slower in export to excel

    I am using a script to export a configuration to excel
    running this scipt in powershell 7 (7.0.0) is much slower than in the native powershell for windows 10 (5.1.18362.628).
    This scipt can be found https://github.com/skippernl/Fortigate2Excel
    What could be the cause of this?

    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. Test-Path Incorrectly reports false when FileName contains [ ]

    Test-Path incorrectly returns false when FileName contains [ ] brackets

    PS D:&gt; $FN = "D:\DEST2\4213-2(None)(None)[1007959] NULL.pdf";

    PS D:&gt; Test-Path $FN -PathType Any
    False

    PS D:&gt; [System.IO.File]::Exists($FN)
    True

    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  ·  Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
  19. add-appxpackage does not have -user option.

    add it so we can add those packages to specific user without logging in to that specific user.

    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  ·  Microsoft.PowerShell.* Modules  ·  Flag idea as inappropriate…  ·  Admin →
  20. "Get-ADGroupMember: An operations error occurred" with cross-forest members

    Any group that contains a user account that is cross-forest to the group object is hitting the non-descriptive error in the title when running Get-ADGroupMember. I can successfully run the command with on groups where all members are in the same forest as the group object.

    The current workaround is to use Get-ADGroup and expand the Members property and then make a subsequent Get-ADObject call for each member. This takes about 5x longer to run.

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

    We’ll send you updates on this idea

    1 comment  ·  Microsoft.PowerShell.* Modules  ·  Flag idea as inappropriate…  ·  Admin →
  • Don't see your idea?

Feedback and Knowledge Base