Skip to content

Instantly share code, notes, and snippets.

@jlabs
Created January 29, 2018 11:38
Show Gist options
  • Save jlabs/0f5d9f5fbc7832b75ee518b4f833fd5a to your computer and use it in GitHub Desktop.
Save jlabs/0f5d9f5fbc7832b75ee518b4f833fd5a to your computer and use it in GitHub Desktop.
Set-ExecutionPolicy RemoteSigned
# Prompt for the account name
$username = Read-Host "Account name"
# Get the current expiry date
$accexp = Get-LocalUser -Name $username | select AccountExpires
# Display the account name with the expiry date in a easy to read format
Write-Host "Account " -NoNewline; Write-Host $username -BackgroundColor White -ForegroundColor Black -NoNewline; Write-Host " is " -NoNewline; Write-Host $accexp.AccountExpires -BackgroundColor White -ForegroundColor Black
# Get a new expiry
$newexp = Read-Host "Enter new expiry"
# Set the new expiry
Set-LocalUser -name $username -AccountExpires $newexp
# Get the new expiry to confirm
$accexp = Get-LocalUser -Name $username | select AccountExpires
# Display the account name with new expiry in a easy to read format
Write-Host "New expiry for " -NoNewline; Write-Host $username -BackgroundColor White -ForegroundColor Black -NoNewline; Write-Host " is " -NoNewline; Write-Host $accexp.AccountExpires -BackgroundColor White -ForegroundColor Black
# Pause to keep the window open
Pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment