Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9945aa6

Browse files
Update PS-SQLSEC-Report.ps1
1 parent 0457f4a commit 9945aa6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

‎PS-SQLSEC-Report.ps1

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#Created by EGGSTOASTBACON :: https://github.com/eggstoastbacon
2-
31
#SQL MANAGEMENT STUDIO SHOULD BE INSTALLED FROM WHERE YOU RUN THIS
42
#The server this is run from should have SQL Port and WMI access to the servers you intend to connect to.
53
#You will require file sqlserver.psd1, change the path to it below.
@@ -47,8 +45,9 @@ foreach ($IP in $IPs) {
4745
$sysinfo = Get-WmiObject -computer $IP -credential $wmiCredentials -Class Win32_ComputerSystem -ErrorAction SilentlyContinue
4846
$server = $sysinfo.Name
4947

48+
5049
$portCheck = Test-NetConnection -computername $IP -port $SQLPort
51-
if ($portCheck.tcpTestSucceeded -like "True") { $portPassed = "True" }else { write-host "Unable to Connect to $IP on $SQLPort" }
50+
if ($portCheck.tcpTestSucceeded -like "True") { $portPassed = "True" }else { write-host "Unable to Connect to $IP on $SQLPort" }
5251

5352
if ($portPassed -like "True") {
5453

@@ -116,10 +115,12 @@ foreach ($IP in $IPs) {
116115
$userrole = $userrole + "public"
117116
$userrole
118117

118+
119119
if ($login.name -notlike "*dbo*" -and $login.name -notlike "sys"`
120120
-and $login.name -notlike "guest" -and $login.name -notlike "*##*"`
121121
-and $login.name -notlike "*MS_*" -and $login.name -notlike "*_SCHEMA*") {
122122

123+
123124
#Create an object and write properties about the account
124125
$row = New-Object PSObject
125126
$row | Add-Member -MemberType NoteProperty -Name "Database" -Value "Server Login"
@@ -143,7 +144,7 @@ foreach ($IP in $IPs) {
143144
if ($srv.DatabaseEngineEdition -like "*Enterprise*") { } else { $AGNAME = "No SQL Connection" }
144145

145146
#Write SQL Login Information to a SQL Row
146-
$query = "
147+
$query = "
147148
INSERT into $storeTABLE (IP,CNAME,DB,DOMAIN,LOGIN,CREATED,MODIFIED,LOGINTYPE,SERVICEACCOUNT,ROLES,DISABLED,DATE,MONTH,DAY,YEAR,AGNAME,LISNAME,CLUNAME) VALUES ('$IP','$Server','$Databasename','$DOMAIN','$LoginName','$LoginCreateDate','$LoginDateLastModified','$LoginLoginType','$ServiceAccount','$userrole','$loginisdisabled','$date','$Month','$Day','$Year','$agname','$listenername','$clustername')
148149
"
149150
Invoke-Sqlcmd -ServerInstance $storeSQLServer -Database $storeSQLdatabase-Query $query -MaxCharLength 3000 -Verbose
@@ -199,7 +200,7 @@ INSERT into $storeTABLE (IP,CNAME,DB,DOMAIN,LOGIN,CREATED,MODIFIED,LOGINTYPE,SER
199200

200201
if ($srv.DatabaseEngineEdition -like "*$SQLEdition*") { } else { $AGNAME = "No SQL Connection" }
201202

202-
$query = "
203+
$query = "
203204
INSERT into $storeTable (IP,CNAME,DB,DOMAIN,LOGIN,CREATED,MODIFIED,LOGINTYPE,SERVICEACCOUNT,ROLES,DISABLED,DATE,MONTH,DAY,YEAR,AGNAME,LISNAME,CLUNAME) VALUES ('$IP','$Server','$Databasename','$DOMAIN','$UserName','$UserCreateDate','$UserDateLastModified','$UserLoginType','$ServiceAccount','$userrole','$userisdisabled','$date','$Month','$Day','$Year','$agname','$listenername','$clustername')
204205
"
205206
Invoke-Sqlcmd -ServerInstance $storeSQLServer -Database $storeSQLdatabase-Query $query -MaxCharLength 3000 -Verbose
@@ -212,4 +213,4 @@ INSERT into $storeTable (IP,CNAME,DB,DOMAIN,LOGIN,CREATED,MODIFIED,LOGINTYPE,SER
212213

213214
}
214215
}
215-
216+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /