none
Powershell Script to reset Local Administrator password RRS feed

  • Question

  • Hi,

    I have a script which is to reset local administrator password of remote machines and I have mentioned the host list in the script.But just would like is there any way, so that we can add line in my script, so that this will reset the administrator password of all machine which is there in a specific set of subnet(example :10.241.1.0 and 10.241.2.0) in a domain ?

    Can anyone help me with that ?

    $computers = Get-Content -path C:\hosts.txt
    $user = "Administrator"
    $pass = "password1"

    Foreach($computer in $computers)
    {
     $user = [adsi]"WinNT://$computer/$user,user"
     $user.SetPassword($pass)
     $user.SetInfo()

    Monday, July 3, 2017 4:15 AM

Answers

All replies