Skip to content

Latest commit

 

History

History
209 lines (143 loc) · 4.33 KB

File metadata and controls

209 lines (143 loc) · 4.33 KB
external help file Locale Module Name ms.date online version schema title
Microsoft.Powershell.LocalAccounts.dll-Help.xml
en-US
Microsoft.PowerShell.LocalAccounts
12/13/2022
2.0.0
Rename-LocalUser

Rename-LocalUser

SYNOPSIS

Renames a local user account.

SYNTAX

InputObject

Rename-LocalUser [-InputObject] <LocalUser> [-NewName] <String> [-WhatIf] [-Confirm] [<CommonParameters>]

Default

Rename-LocalUser [-Name] <String> [-NewName] <String> [-WhatIf] [-Confirm] [<CommonParameters>]

SecurityIdentifier

Rename-LocalUser [-NewName] <String> [-SID] <SecurityIdentifier> [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

The Rename-LocalUser cmdlet renames a local user account.

Note

The Microsoft.PowerShell.LocalAccounts module is not available in 32-bit PowerShell on a 64-bit system.

EXAMPLES

Example 1: Rename a user account

Rename-LocalUser -Name "Admin02" -NewName "AdminContoso02"

This command renames the user account named Admin02.

PARAMETERS

-InputObject

Specifies the user account that this cmdlet renames. To obtain a user account, use the Get-LocalUser cmdlet.

Type: Microsoft.PowerShell.Commands.LocalUser
Parameter Sets: InputObject
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

-Name

Specifies the name of the user account that this cmdlet renames.

Type: System.String
Parameter Sets: Default
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

-NewName

Specifies a new name for the user account.

Type: System.String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SID

Specifies the security ID (SID) of a user accounts that this cmdlet renames.

Type: System.Security.Principal.SecurityIdentifier
Parameter Sets: SecurityIdentifier
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.Management.Automation.SecurityAccountsManager.LocalUser

You can pipe a local user to this cmdlet.

System.String

You can pipe a string to this cmdlet.

System.Security.Principal.SecurityIdentifier

You can pipe a SID to this cmdlet.

OUTPUTS

None

This cmdlet returns no output.

NOTES

Windows PowerShell includes the following aliases for Rename-LocalUser:

  • rnlu

The PrincipalSource property is a property on LocalUser, LocalGroup, and LocalPrincipal objects that describes the source of the object. The possible sources are as follows:

  • Local
  • Active Directory
  • Microsoft Entra group
  • Microsoft Account

PrincipalSource is supported only by Windows 10, Windows Server 2016, and later versions of the Windows operating system. For earlier versions, the property is blank.

RELATED LINKS

Disable-LocalUser

Enable-LocalUser

Get-LocalUser

New-LocalUser

Remove-LocalUser

Set-LocalUser