Powershell and Windows 11

Jim Harbert 0 Reputation points
2024-06-27T20:41:10.9533333+00:00

In Windows 11 Pro 22H2 running PowerShell v5.1.22621.2506, I'm seeing issues when running PowerShell commands. For example, I run the copy-item command and PowerShell says it is an invalid command. I close PowerShell and open it again and the copy-item command successfully runs. I have never encountered this issue in Windows 10.

Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,738 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,255 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Hania Lian 10,351 Reputation points Microsoft Vendor
    2024-06-28T08:12:31.9266667+00:00

    Hello,

    1. Check the PowerShell configuration file.

    Run to see the contents of the current profile: Get-Content $PROFILE

    Look for any commands that might interfere with or load modules that might override the default behavior.

    1. Test in a new user profile.

    Create a new user profile and test if the issue persists. This can help determine if the issue is specific to your current user profile.

    1. Review the event log.

    Check the Windows event log for any related errors or warnings that may provide more clues.

    1. Reset PowerShell settings.

    As a last resort, you can reset the PowerShell settings to their defaults. Note that this will remove any customizations you have made. Use the following command:

    Remove-ItemProperty -Path "HKCU:\Software\Microsoft\PowerShell\1\PowerShellEngine" -Name "*"

    Hope this helps.

    Best Regards,

    Hania Lian

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments