Skip to content

Instantly share code, notes, and snippets.

@mwjcomputing
Last active December 12, 2015 01:48
Show Gist options
  • Select an option

  • Save mwjcomputing/4693395 to your computer and use it in GitHub Desktop.

Select an option

Save mwjcomputing/4693395 to your computer and use it in GitHub Desktop.
function Set-LocalPasswords
{
param(
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[string]$computer,
[Parameter(Mandatory=$true)]
[string]$password
)
process {
$userList = Get-WmiObject -Class Win32_UserAccount -ComputerName $computer
foreach ($user in $userList) {
([adsi]"WinNT://$computer/$user).SetPassword($password)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment