Set-LocalUser

Modify a local user account.

Syntax
      Set-LocalUser [-Name] String
         [-AccountExpires DateTime] [-AccountNeverExpires] [-Description String]
            [-FullName String] [-Password SecureString] [-PasswordNeverExpires]
               [-UserMayChangePassword] [-WhatIf] [-Confirm] [CommonParameters]

      Set-LocalUser { [-InputObject] LocalUser | [-SID] SecurityIdentifier }
         [-AccountExpires DateTime] [-AccountNeverExpires] [-Description String]
            [-FullName String] [-Password SecureString] [-PasswordNeverExpires]
               [-UserMayChangePassword] [-WhatIf] [-Confirm] [CommonParameters]

Key
   -AccountExpires
       Specify when the user account should expire.
       To obtain a DateTime object, use Get-Date.
       If you do not want the account to expire, specify the -AccountNeverExpires parameter.

   -AccountNeverExpires
       Set the account to not expire (boolean).

   -Description
       Set a comment for the user account. The maximum length is 48 characters.

   -FullName
       Change the full name of the user account. The full name differs from the user name of the user account.

   -InputObject
       The user account that this cmdlet changes. To obtain a user account, use Get-LocalUser.

   -Name
       The name of the user account to change.

   -Password SecureString
       Specify a new password for the user account.
       If the user account is connected to a Microsoft account, do not set a password.
       You can use Read-Host -GetCredential, Get-Credential, or ConvertTo-SecureString to create a SecureString
       object for the password.
       If you omit the Password you will be prompted for a password to set.

   -PasswordNeverExpires
       Indicate whether the password expires (boolean).

   -SID
       The security ID (SID) of the user account to change.

   -UserMayChangePassword
       Indicate that the user can change the password on the user account.
 
   -Confirm
       Prompt for confirmation before executing the command.

   -WhatIf
       Describe what would happen if you executed the command without actually executing the command.

Set-LocalUser modifies a local user account. This cmdlet can reset the password of a local user account.
The Microsoft.PowerShell.LocalAccounts module is not available in 32-bit PowerShell on a 64-bit system.

This cmdlet does not generate any output.

Examples

Change a description of a user account:

PS C:\> Set-LocalUser -Name "Kiosk64" -Description "Local Kiosk account."

Change the password on an account:

PS C:\> $User = Get-LocalUser -Name "User64"

PS C:\> $User | Set-LocalUser -Password (Read-Host -Prompt "Enter a New Password" -AsSecureString)

“Be soft. Do not let the world make you hard. Do not let the pain make you hate. Do not let the bitterness steal your sweetness. Take pride that even though the rest of the world may disagree, you still believe it to be a beautiful place” ~ Iain Thomas

Related PowerShell Cmdlets

Set-ADAccountPassword - Modify the password of an Active Directory account.
New-LocalUser - Create a local user account.
Add-LocalGroupMember - Add members to a local group.
Equivalent bash command: date - Display or change the date.


 
Copyright © 1999-2024 SS64.com
Some rights reserved