Created
January 29, 2018 11:38
-
-
Save jlabs/0f5d9f5fbc7832b75ee518b4f833fd5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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