Windows Server 2008: PowerShell Change Local Administrator Password 2015 01


Here is the full article:
https://sites.google.com/a/uom.edu.gr/greekit/my-articles/windows-powershell/admin-password-change

First we will find the local computer name:
$env:COMPUTERNAME

Now we use the ADSI type accelerator:
[ADSI]$Admin=”WinNT://SNF-603902/Administrator”

// we can do also this:
[ADSI]$Admin=”WinNT://$env:COMPUTERNAME/Administrator”

$Admin.PasswordAge
That value is the number of seconds since the password was changed on this computer.
We can see this value in days with:
$Admin.PasswordAge.Value/86400

Now, to make password change all I have to do is to call SetPassword Method and specify the password in the parenthesis:
$Admin.SetPassword(“S3cre+sr!n”)

So I hit enter and the password has now been changed.

Good Links:
Here is Microsoft explanation of ADSI WinNT Provider:
http://msdn.microsoft.com/en-us/library/aa772237(v=vs.85).aspx

Windows Server 2008 PowerShell 2 Ten Tasks, by Jeffery Hicks (03:01-05:51):
https://www.youtube.com/watch?v=OVuDFlWGJ4Y&index=3&list=PLGkGxdP-_hB5GHCn4eb1OOunAESQkLWYs