The user's account has expired - Microsoft Windows - Workgroup

This post describes how to resolve the error "The user's account has expired" on a Microsoft Windows Workgroup machine i.e. without Active Directory Users and Computers.

The user's account has expired - Workgroup

Cause

This error can occur when the local user account's expiry date is in the past and you try to logon as that user.


Resolution

You can't use Local Users and Groups to change the user account expiry date.

The expiry date can be be changed using either Powershell or VBScript.


PowerShell method

To get the current expiry date, run the following command in PowerShell, replacing accountname with the account you want to get.

Get-LocalUser accountname|SELECT *

Screenshot showing the user account expiry date in PowerShell


To set the expiry date to a specified date:

Set-LocalUser asmith -AccountExpires (Get-Date).AddDays(12)

Screenshot showing setting the user account expiry date in PowerShell

To set the expiry date to never expire:

Set-LocalUser accountname -AccountNeverExpires

Screenshot showing setting the user account expiry date to never expires in PowerShell


VBScript method

The following VBScript gets the current expiry date:

Set objUser = GetObject("WinNT://hostname/accountname")
Wscript.Echo objUser.Name, objUser.AccountExpirationDate

User account expiry date

To increment the expiry date by 60 days:

Set objUser = GetObject("WinNT://hostname/accountname")
objUser.AccountExpirationDate = Date + 60
objUser.SetInfo
Wscript.Echo objUser.Name, objUser.AccountExpirationDate

User account expiry date updated

My VBScripts are based on information from this excellent post: https://devblogs.microsoft.com/scripting/how-can-i-configure-an-expiration-date-for-a-local-user-account/


Comments

Popular posts from this blog

LG TV This app will now restart to free up more memory

LG TV Clear All Browsing History Data

LG TV turn off Quick Start in settings