Skip to content

Commit a83cad2

Browse files
authored
Update PowerUpSQL.ps1
Add optional sql link crawl to invoke-sqldumpinfo.
1 parent 3179bd7 commit a83cad2

File tree

1 file changed

+40
-19
lines changed

1 file changed

+40
-19
lines changed

PowerUpSQL.ps1

+40-19
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
File: PowerUpSQL.ps1
44
Author: Scott Sutherland (@_nullbind), NetSPI - 2023
55
Major Contributors: Antti Rantasaari and Eric Gruber
6-
Version: 1.128
6+
Version: 1.129
77
Description: PowerUpSQL is a PowerShell toolkit for attacking SQL Server.
88
License: BSD 3-Clause
99
Required Dependencies: PowerShell v.2
@@ -12625,9 +12625,9 @@ Function Get-SQLStoredProcedureCLR
1262512625
# Check count
1262612626
$CLRCount = $TblAssemblyFiles.Rows.Count
1262712627
if ($CLRCount -gt 0){
12628-
Write-Verbose "$Instance : Found $CLRCount CLR stored procedures"
12628+
Write-Verbose "$Instance : - Found $CLRCount CLR stored procedures"
1262912629
}else{
12630-
Write-Verbose "$Instance : No CLR stored procedures found."
12630+
Write-Verbose "$Instance : - No CLR stored procedures found."
1263112631
}
1263212632

1263312633
# Return data
@@ -26810,7 +26810,12 @@ Function Invoke-SQLDumpInfo
2681026810

2681126811
[Parameter(Mandatory = $false,
2681226812
HelpMessage = 'Write output to csv files.')]
26813-
[switch]$csv
26813+
[switch]$csv,
26814+
26815+
[Parameter(Mandatory = $false,
26816+
HelpMessage = 'Crawl available SQL Server links.')]
26817+
[switch]$CrawlLinks
26818+
2681426819
)
2681526820

2681626821
Begin
@@ -27071,20 +27076,6 @@ Function Invoke-SQLDumpInfo
2707127076
$Results | Export-Csv -NoTypeInformation $OutPutPath
2707227077
}
2707327078

27074-
# Getting Server Links
27075-
Write-Verbose -Message "$Instance - Getting server links..."
27076-
$Results = Get-SQLServerLink -Instance $Instance -Username $Username -Password $Password -Credential $Credential -SuppressVerbose
27077-
if($xml)
27078-
{
27079-
$OutPutPath = "$OutFolder\$OutPutInstance"+'_Server_links.xml'
27080-
$Results | Export-Clixml $OutPutPath
27081-
}
27082-
else
27083-
{
27084-
$OutPutPath = "$OutFolder\$OutPutInstance"+'_Server_links.csv'
27085-
$Results | Export-Csv -NoTypeInformation $OutPutPath
27086-
}
27087-
2708827079
# Getting Server Credentials
2708927080
Write-Verbose -Message "$Instance - Getting server credentials..."
2709027081
$Results = Get-SQLServerCredential -Instance $Instance -Username $Username -Password $Password -Credential $Credential -SuppressVerbose
@@ -27350,7 +27341,37 @@ Function Invoke-SQLDumpInfo
2735027341
{
2735127342
$OutPutPath = "$OutFolder\$OutPutInstance"+'_Server_oledbproviders.csv'
2735227343
$Results | Export-Csv -NoTypeInformation $OutPutPath
27353-
}
27344+
}
27345+
27346+
# Getting Server Links
27347+
Write-Verbose -Message "$Instance - Getting server links..."
27348+
$Results = Get-SQLServerLink -Instance $Instance -Username $Username -Password $Password -Credential $Credential -SuppressVerbose
27349+
if($xml)
27350+
{
27351+
$OutPutPath = "$OutFolder\$OutPutInstance"+'_Server_links.xml'
27352+
$Results | Export-Clixml $OutPutPath
27353+
}
27354+
else
27355+
{
27356+
$OutPutPath = "$OutFolder\$OutPutInstance"+'_Server_links.csv'
27357+
$Results | Export-Csv -NoTypeInformation $OutPutPath
27358+
}
27359+
27360+
# Getting Server Links via Crawl
27361+
if($CrawlLinks){
27362+
Write-Verbose -Message "$Instance - Crawling linked servers..."
27363+
$Results = Get-SQLServerLinkCrawl -Instance $Instance -Username $Username -Password $Password -Credential $Credential -Export2
27364+
if($xml)
27365+
{
27366+
$OutPutPath = "$OutFolder\$OutPutInstance"+'_Server_links_crawl.xml'
27367+
$Results | Export-Clixml $OutPutPath
27368+
}
27369+
else
27370+
{
27371+
$OutPutPath = "$OutFolder\$OutPutInstance"+'_Server_links_crawl.csv'
27372+
$Results | Export-Csv -NoTypeInformation $OutPutPath
27373+
}
27374+
}
2735427375

2735527376
Write-Verbose -Message "$Instance - END"
2735627377
}

0 commit comments

Comments
 (0)