Script to check credentials for multiple Windows machines.

Hi All,

Can someone help me to get the simple script to check the credentials for multiple windows machines. and also if possible is their any script where credentials will be taken from notepad and check the credentials by its own instead of manual enter.

Thanks,

Kiran

Did you attempt to search? My search “powershell test local user credentials” produced many results, like this one:

https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/test-local-user-account-credentials

The Get-Credential cmdlet supports the -ComputerName parameter, which will allow you to run it against a remote system. A simple application of Foreach would allow you to loop through many remote systems.

Test-Cred is an example of a script written to do exactly what you want - test the credentials of a user on remote systems. It can also store the credential for use within the same session. You would want to modify that script so that it passes the credential information to whatever other tasks you need to perform.

However, this:

is a very bad idea. You should never store credential information of any kind in static, un-encrypted files. Doing so effectively breaks your security. Think of it like making a copy of your house key and then leaving it lying around where other people can find it - you might as well just take the lock off your door.

[quote quote=193309]Did you attempt to search? My search “powershell test local user credentials” produced many results, like this one:

https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/test-local-user-account-credentials

[/quote]
Hi Rob,

 

But i dont think i got the result which i was looking for in the given link

Hi,

Can someone help to fix the below issue for the given script

Issue:- If i enter the wrong password also it is connecting , which is not supposed to be happened. I have multiple machines needs to be logged in .

Below is the Script i am using.

$servers = Get-Content C:\Users\esxxkir\Documents\Scripts\Connectivitycheck\test.txt
$cred = Get-Credential
foreach ($server in $servers) {
if(Test-Connection $server -Count 1 -ErrorAction SilentlyContinue) {
if(New-PSDrive -Name testshare -PSProvider FileSystem -Root “\$server\c$” -Credential $cred -ErrorAction SilentlyContinue)
{
$status = ‘online and able to connect’
Remove-PSDrive testshare
}
else {
$status = ‘online but unable to connect’
}
}
else {
$status = ‘offline/not in DNS’
}
Write-Host $server - $status
}

[quote quote=193315]The Get-Credential cmdlet supports the -ComputerName parameter, which will allow you to run it against a remote system. A simple application of Foreach would allow you to loop through many remote systems.

Test-Cred is an example of a script written to do exactly what you want – test the credentials of a user on remote systems. It can also store the credential for use within the same session. You would want to modify that script so that it passes the credential information to whatever other tasks you need to perform.

However, this:

Kirangowda31 wrote:
and also if possible is their any script where credentials will be taken from notepad and check the credentials by its own instead of manual enter.
is a very bad idea. You should never store credential information of any kind in static, un-encrypted files. Doing so effectively breaks your security. Think of it like making a copy of your house key and then leaving it lying around where other people can find it – you might as well just take the lock off your door.

[/quote]
I agree for your point but if we have bulk machines with different Passwords how to work on it. If you have any script at least that should for me to enter once my credentials and get the output whether machines are able to connect or not.

Thanks,

Kiran