This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Below is a cheatsheet for creating SQL Server client connection strings and finding them in common configuration files. | |
| ------------------------------------------------------------------ | |
| CREATING CONNECTION STRINGS | |
| ------------------------------------------------------------------ | |
| ---------------------- | |
| Authentication Options | |
| ---------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| This outlines how to set the "is_ms_shipped" flag to one for custom stored procedures in SQL Server. | |
| Note: The following has to be executed as a sysadmin | |
| -- Create stored procedure | |
| CREATE PROCEDURE sp_example | |
| AS | |
| BEGIN | |
| SELECT @@VERSION | |
| END |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # hacky ps script to convert ip,openport to ip,allopenports | |
| # Container for final list | |
| $FullList = New-Object System.Data.DataTable | |
| $FullList.Columns.Add("Dest") | Out-Null | |
| $FullList.Columns.Add("Port") | Out-Null | |
| # import full list of open ports – one per line (dest,port) | |
| $ImportList = import-csv C:\temp\open-ports-by-line.csv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| select n [id], USER_NAME(n) [user_name] | |
| from ( | |
| select top 10000 row_number() over(order by t1.number) as N | |
| from master..spt_values t1 | |
| cross join master..spt_values t2 | |
| ) a | |
| where USER_NAME(n) is not null | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $schedule = new-object -com("Schedule.Service") | |
| $schedule.connect() | |
| $tasks = $schedule.getfolder("\").gettasks(0) | |
| $entries = New-Object System.Collections.Generic.List[System.Management.Automation.PSObject] | |
| $tasks | | |
| ForEach-Object { | |
| # Get task information |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This script can be used to extract a list of IIS 6.x HTTP servers from .nessus files. | |
| # Author: Scott Sutherland, NetSPI 2017 | |
| # Instructions: Run the script in a directory containing only .nessus files. Super dirty/slow, but functional. | |
| # Create an output table | |
| $outputtbl =New-Object System.Data.DataTable | |
| $outputtbl.Columns.Add("IpAddress") | Out-Null | |
| $outputtbl.Columns.Add("IISVersion") | Out-Null | |
| # Iterate through each host |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Script: Find-DbaSqlInstance | |
| # version 0.14.5 | |
| # Author: Scott Sutherland, 2018 NetSPI | |
| # Contributions from: Warren F. (Invoke-Parallel), https://gallery.technet.microsoft.com/scriptcenter/List-the-IP-addresses-in-a-60c5bb6b | |
| # ------------------------ | |
| # Current feature summary | |
| # ------------------------ | |
| # 1 - Import list of IP addresses, computer names, or SQL instances from a file via "-SqlInstanceFile" param - works |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- set output directory to install sql server install dir | |
| -- set output file to randomly generate name | |
| -- show advanced options | |
| sp_configure 'show advanced options',1 | |
| reconfigure | |
| go | |
| -- turn on ole automation | |
| sp_configure 'Ole Automation Procedures',1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- This is a TSQL template for executing OS commands through SQL Server using OLE Automation Procedures. | |
| -- Enable Show Advanced Options | |
| sp_configure 'Show Advanced Options',1 | |
| RECONFIGURE | |
| GO | |
| -- Enable OLE Automation Procedures | |
| sp_configure 'Ole Automation Procedures',1 | |
| RECONFIGURE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # todo | |
| <# | |
| - Note: dependant on PowerUpSQL. | |
| 1 - have script accept command or source script as string | |
| --- have that get bake into the wmi provider method | |
| --- update the wmi method to execute the provided string as a script block | |
| --- mod the clr to return the output of the wmi command | |
| - roll into clone of the invoke-sqloscmdclr function so it can scale | |
| - remove wmi cs and dll on client | |
| - remove sql dll cs and dll on client |