I’d like to create a script which will be checking SQL databases in terms of default password and if such password exist, create an event log entry.
I don’t have much experience with PowerShell, and after few hours I’m stuck.
At the moment I’ve created such script, which isn’t perfect, but gathering some data. I stuck on the point, how to verify if the default password exist and if yes, move to step creating an event log entry.
I’ll be grateful for any advises how to achieve that.
$Look4DBs = “select name from sys.databases where name like ‘%XXX%’”
$PassSelect = “select code, name, password from table
where code in (‘User1’,‘User2’,‘User3’) and
password in (‘Password0’,‘Password1’,‘Password3’)”
$DBs = Invoke-Sqlcmd -ServerInstance localhost -Database master -Query $Look4DBs
For ($db = 0; $db -lt $DBs.Count; $db++)
Invoke-Sqlcmd -ServerInstance localhost -Database $DBs.Name[$db] -Query $PassSelect | Select name,password