So This script kind of works…on half of the targets…
1st of all know that WINRM is enabled on all the machines I’m working with. and I’m running the following script.
function getUserInput() {
$targetPassword = “password”
$targetUserName = “domain\username”
massLogin
}
function massLogin() {
$serverList = Get-Content import.txt
foreach ($server in $serverList){
Invoke-Command -ComputerName $server -ScriptBlock {
param($targetUserName,$targetPassword)
Try {Set-ItemProperty ‘HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon’ -Name AutoAdminLogon -Value 1}
Catch {New-ItemProperty ‘HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon’ -Name AutoAdminLogon -PropertyType String -Value 1}
Try {Set-ItemProperty ‘HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon’ -Name DefaultUserName -Value $targetUserName}
Catch {New-ItemProperty ‘HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon’ -Name DefaultUserName -PropertyType String -Value $targetUserName}
Try {Set-ItemProperty ‘HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon’ -Name DefaultPassword -Value $targetPassword}
Catch {New-ItemProperty ‘HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon’ -Name DefaultPassword -PropertyType String -Value $targetPassword}
Restart-Computer -Force
} -ArgumentList $targetUserName, $targetPassword
}
}
getUserInput
This hits 50% of em every time but for the others I get:
[110H31] Connecting to remote server 110H31 failed with the following error message : The client cannot connect to the destination specified in the request.
Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on
the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the
WinRM service: “winrm quickconfig”. For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (110H31:String) , PSRemotingTransportException
+ FullyQualifiedErrorId : CannotConnect,PSSessionStateBroken
I believe this is because it only tries to connect to those devices for about a second. Is there a way to make it so it tries for like 3? Or is it possible that I’m completely wrong about the issue?