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. How do I create an Azure Automation schedule with PowerShell using the Az Cmdlet New-AzAutomationSchedule?

    When I attempt to run the Cmdlet below with the following parameters, it fails:

    $AutomationAccountName = "CZEU1-INF-NP-0faa84be-AAA-01"

    $ResourceGroupName = "czeu2-app-np-rgp-01"

    $vmStartTime = (Get-Date "08:00:00").AddDays(1)

    $vmStopTime = (Get-Date "18:00:00")

    $timeZone = [TimeZoneInfo]::Local.DisplayName

    $vmStartupScheduleName = "Startup VMs 08:00 Daily Weekdays:

    $timeZone"

    $vmShutdownScheduleName = "Shutdown VMs 18:00 Daily

    Weekdays: $timeZone"

    [System.DayOfWeek[]]$WeekDays = @([System.DayOfWeek]::Monday..[System.DayOfWeek]::Friday)

    New-AzAutomationSchedule -AutomationAccountName $AutomationAccountName -Name $vmStartupScheduleName -StartTime $vmStartTime -WeekInterval 1 -DaysOfWeek $WeekDays -ResourceGroupName $ResourceGroupName -Verbose

    The error is: New-AzAutomationSchedule : Exception of type 'Microsoft.Azure.Management.Automation.Models.ErrorResponseException' was thrown. At line:1 char:1 + New-AutomationSchedule -AutomationAccountName $AutomationAccountNam... + CategoryInfo : CloseError: (:) [New-AzAutomationSchedule], ErrorResponseException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Automation.Cmdlet.NewAzureAutomationShedule

    19 votes
    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. New-ScheduledTaskTrigger missing option to NOT 'Synchronize across time zones'

    New-ScheduledTaskTrigger missing option to NOT 'Synchronize across time zones'

    The default is to always set it. This should not be an implied default as it creates problem with Daylight Saving etc.

    To remove must do as follows which should not be needed:

    $str = Get-ScheduledTask -TaskName TESTTASK

    $NewTriggers = @()
    foreach($trigger in $str.Triggers)
    {

    if($trigger.StartBoundary -match '\+01:00$')
    
    {
    $Trigger.StartBoundary = $Trigger.StartBoundary.Substring(0,$Trigger.StartBoundary.Length-6)
    }
    $NewTriggers += $trigger

    }

    $str.Triggers = $NewTriggers
    Set-ScheduledTask -InputObject $str

    Please add switch to disable either through New-ScheduledTaskTrigger or via Set-ScheduledTask

    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  ·  Microsoft.PowerShell.* Modules  ·  Flag idea as inappropriate…  ·  Admin →
  3. New-AzAutomationConnection Cmdlet incorrectly states that -ResourceGroupName parameter value exeeds length of 90.

    There appears to be a bug when using this Cmdlet, where the -ResourceGroupName parameter incorrectly states that the parameter value for the resource group exceeds a length of 90 when a variable is used, i.e. $rgName (string length is actually 19 <CZEU2-APP-NP-RGP-01>. When the hard coded value of: "CZEU2-APP-NP-RGP-01" is used however, the Cmdlet works as designed.

    13 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 →
  4. How to modify "Date" column in Windows Explorer

    In Windows Explorer there are two columns available: "Date modified" and "Date". I've tried both setting the .LastWriteTime and .CreationTime for files and it changes the date in the "Date Modified" column, but does not change the "Date" column.

    Is there a way to modify the "Date" column in Windows Explorer using Powershell scripting? I basically want to create a "touch" command that will affect BOTH "Date modified" and "Date" columns in Windows Explorer.

    Thanks!

    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  ·  Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
  5. Add-Member unexpected behaviour when adding method to value types

    Trying to alter value with a method:
    $x = 2
    Add-Member -InputObject $x -MemberType ScriptMethod -Name "AlterValue" -Value {param ([int]$NewValue) $NewValue; $this = $NewValue}
    $x.AlterValue(3)
    $x
    No error (even with Set-StrictMode -Version Latest), no update either.

    $y = 'b'
    Add-Member -InputObject $y -MemberType ScriptMethod -Name "AlterValue" -Value {param ([string]$NewValue) $NewValue; $this = $NewValue}
    $y.AlterValue('a')
    Error: Method invocation failed because [System.String] does not contain a method named 'AlterValue'.
    Then trying like this:
    $y | Add-Member -MemberType ScriptMethod -Name "AlterValue" -Value {param ([string]$NewValue) $NewValue; $this = $NewValue}
    Runs without error, but $y.AlterValue('a') results in the same error as above. Same if I…

    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  ·  Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
  6. ISE updates prematurely

    If you run changes (to see how they work), your changes will be updated if you leave ISE. There should be an 'do you want to update changes?' before quiting

    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  ·  ISE and tooling  ·  Flag idea as inappropriate…  ·  Admin →
  7. MinimumCompatibleVersion still causes "Cannot find module PSDesiredStateConfiguration_1.0 from the server"

    Although a very similar issue has been resolved in WMF5.1 we are encountering an issue when working with partial configurations.

    It seems that the MinimumCompatibleVersion for the complete configurations is taken from the "first" (alphabetical order) partial configuration. If this happens to be a 2.0.0 configuration then other partials which were 1.0.0 cannot load the PSDesiredStateConfiguration module.

    Please take a look at the reproduction in the attachment.
    We reproduced this on windows server 2012r2, 2016 and 2019 and it is causing a very blocking issue for us.

    Edit; since the attachments dont seem to work:

    if (-not $inputCredential)
    {

    $inputCredential
    11 votes
    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 →
  8. DISM creates corrupt archive

    If two (or more) files are present with the exact same content, where file extension is irrelevant also content of file, as long as its the exactly the same; Dism will create a corrupted archive

    e.g.

    a.txt & b.txt

    Content of both files: 0x6c

    Shouldn't this be a case for the dedublication? Both files are separeted inside the wim (Both have only 1 link)

    https://sourceforge.net/p/sevenzip/discussion/45798/thread/db110477b8/

    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 →
  9. "using module" does not provide a way to disable name checking

    The Import-Module cmdlet provides a way to silence the warning about unapproved verbs in function/cmdlet names (-DisableNameChecking). There does not seem to be a way to do this via the "using module" statement, which generates unwanted noise (we have our own internal naming conventions).

    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. Powershell display the letter Ø/ø wrong

    The letter Ø/ø is displaying as an O/o in PowerShell 5.1.18362.628. All other letters is displayed correctly, but not Ø/ø. I suspect that this is because 0 is looking similar, but Ø/ø is not the same as O/o so this is wrong.

    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 →
  11. 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 →
  12. 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 →
  13. 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 →
  14. 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 →
  15. 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 →
  16. Get-Service -ComputerName not supported anymore?

    Get-Service used to support a ComputerName parameter so that I can connect to a remote server and get the services from there. Is it no longer supported in PS7? I saw a suggestion to run the script remotely on each server where you want to get the services from, which is highly impractical and slow too.

    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 →
  17. 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 →
  18. 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 →
  19. 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 →
  20. 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 →
← Previous 1 3 4 5 85 86
  • Don't see your idea?

Feedback and Knowledge Base