Welcome › Forums › General PowerShell Q&A › Script to check credentials for multiple Windows machines.
- This topic has 5 replies, 3 voices, and was last updated 1 year, 1 month ago by
Participant.
-
AuthorPosts
-
-
December 13, 2019 at 2:54 pm #193261
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
-
December 13, 2019 at 3:29 pm #193309
Did you attempt to search? My search “powershell test local user credentials” produced many results, like this one:
-
December 14, 2019 at 8:59 am #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:
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.
-
December 16, 2019 at 11:43 am #193631
Did you attempt to search? My search “powershell test local user credentials” produced many results, like this one:
Hi Rob,
But i dont think i got the result which i was looking for in the given link
-
December 16, 2019 at 11:45 am #193634
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
} -
December 16, 2019 at 1:01 pm #193637
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:
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.
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
-
-
AuthorPosts
- The topic ‘Script to check credentials for multiple Windows machines.’ is closed to new replies.