Forum Discussion

shadranok's avatar
shadranok
Copper Contributor
Oct 18, 2022

New_LocalUser not working

I'm trying to use powershell 7 to create a new local user on my computer and I always get an error message.

PowerShell 7.2.6
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS C:\Windows\System32> new-localuser -name 'bob'

cmdlet New-LocalUser at command pipeline position 1
Supply values for the following parameters:
Password:
New-LocalUser: Could not load type 'Microsoft.PowerShell.Telemetry.Internal.TelemetryAPI' from assembly 'System.Management.Automation, Version=7.2.6.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
PS C:\Windows\System32>
  • DESCRIPTION
    The `New-LocalUser` cmdlet creates a local user account. This cmdlet creates a local user account or a local user account that is connected to a Microsoft account.

    > [!NOTE] > The Microsoft.PowerShell.LocalAccounts module is not available in 32-bit PowerShell on a 64-bit > system

    Have the same issue, does work in PowerShell v5. It does work after running import-module microsoft.powershell.localaccounts -UseWindowsPowerShell (Effectively running it in PowerShell v5 mode in PowerShell v7)
  • DESCRIPTION
    The `New-LocalUser` cmdlet creates a local user account. This cmdlet creates a local user account or a local user account that is connected to a Microsoft account.

    > [!NOTE] > The Microsoft.PowerShell.LocalAccounts module is not available in 32-bit PowerShell on a 64-bit > system

    Have the same issue, does work in PowerShell v5. It does work after running import-module microsoft.powershell.localaccounts -UseWindowsPowerShell (Effectively running it in PowerShell v5 mode in PowerShell v7)
    • santiago_-_-'s avatar
      santiago_-_-
      Copper Contributor
      Hello, I am getting the same issue when I use the new-localuser on a Powershell version 7.3.6. I don't understand how to fix this.
      • Harm_Veenstra's avatar
        Harm_Veenstra
        MVP

        santiago_-_- 

        "it does work after running import-module microsoft.powershell.localaccounts -UseWindowsPowerShell (Effectively running it in PowerShell v5 mode in PowerShell v7)"

         

        Just tested it again, still works like that in PowerShell 7

         

         

Resources