Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add params (MaxDepth and StopOnSysAdmin) and perf increases to Get-SQLServerLinkCrawl #77

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Prevent circular link traversals
MJVL committed Aug 31, 2022
commit 612285649228077f70b84940bf9949f70e1b0d0a
17 changes: 15 additions & 2 deletions PowerUpSQL.ps1
Original file line number Diff line number Diff line change
@@ -15306,6 +15306,8 @@ Function Get-SQLServerLinkCrawl{

$List += $Server
$SqlInfoTable = New-Object System.Data.DataTable

$Visited = [System.Collections.Generic.HashSet[string]]::new()
}

Process
@@ -15320,14 +15322,25 @@ Function Get-SQLServerLinkCrawl{
Write-Verbose "$Path exceeds max depth. Skipping..."
continue
}
$List = (Get-SQLServerLinkData -list $List -server $Server -query $Query -QueryTarget $QueryTarget)

$TempList = (Get-SQLServerLinkData -list $List -server $Server -query $Query -QueryTarget $QueryTarget)
if ($Server.Instance -ne "Broken Link") {
# if we've already been to this server with the same user, there's nothing new to log or find
$key = "{0}:{1}" -f $Server.Instance, $Server.User
if ($Visited.Contains($key)) {
Write-Verbose "$Path has already been traversed with $($Server.User). Skipping..."
continue
}
$Visited.Add($key) | Out-Null
}
$List = $TempList
$i++

# Verbose output
Write-Verbose "--------------------------------"
Write-Verbose " Server: $($Server.Instance)"
Write-Verbose "--------------------------------"
Write-Verbose " - Link Path to server: $($Server.Path -join ' -> ')"
Write-Verbose " - Link Path to server: $Path"
Write-Verbose " - Link Login: $($Server.User)"
Write-Verbose " - Link IsSysAdmin: $($Server.Sysadmin)"
Write-Verbose " - Link Count: $($Server.Links.Count)"