Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

PowerShell Script: Autologon, select each computername with username and password (in csv) write into remote registry.

$
0
0

$csvfile = "C:\users\zahadadmin3\desktop\domain\computers.txt" 
Import-Csv $csvfile | foreach {  
$computer=$_.computer; 
$user=$_.user;
$password=$_.password;

Function AutoAdminLogon2 { 

 [cmdletbinding()] 
Param( 
[string] $User     = $(Throw 'No user id specified'), 
[string] $Password = $(Throw 'No password specified') 


$RegPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' 

Set-ItemProperty -Path $RegPath -Name AutoAdminLogon -Value 1
Set-ItemProperty -Path $RegPath -Name DefaultUserName -Value -user $_.user
Set-ItemProperty -Path $regPath -Name DefaultPassword -Value -password $_.password
 }
}

  I am unable to write the registry key into remote pc, it keeps changing my local pc registry each time i run. I must have missed something, can someone help to point out?

Viewing all articles
Browse latest Browse all 15028

Trending Articles