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
| <?xml version="1.0" encoding="utf-8" ?> | |
| <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
| <_locDefinition xmlns="urn:locstudio"> | |
| <_locDefault _loc="locNone" /> | |
| <_locTag _loc="locData">Title</_locTag> | |
| <_locTag _loc="locData">Description</_locTag> | |
| <_locTag _loc="locData">Author</_locTag> | |
| <_locTag _loc="locData">ToolTip</_locTag> | |
| </_locDefinition> | |
| <CodeSnippet Format="1.0.0"> |
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
| DECLARE @Debug BIT= 1; | |
| DECLARE @ImSure BIT= 1; | |
| IF(@Debug = 1) | |
| BEGIN | |
| PRINT @MyQuery; | |
| END; | |
| IF(@ImSure = 1) | |
| BEGIN | |
| EXEC sp_executesql @MyQuery; |
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
| import-module dbatools; | |
| $MyQuery = @" | |
| select * from sys.databases where [name] = @DBName | |
| "@; | |
| $Params = @{"DBName" = "model"}; | |
| Invoke-DbaSqlQuery -SqlInstance YOURSERVER -Query $MyQuery -SqlParameters $Params; | |
| remove-module dbatools; |
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
| import-module dbatools,ImportExcel; | |
| $MyQuery = @" | |
| select * from sys.databases where [name] = @DBName | |
| "@; | |
| $Params = @{"DBName" = "model"}; | |
| Invoke-DbaSqlQuery -SqlInstance YOURSERVER -Query $MyQuery -SqlParameters $Params | export-excel -Path e:\tmp\myfile.xlsx; | |
| $MyData = Import-Excel -path e:\tmp\myfile.xlsx; | |
| $MyData|ConvertTo-DbaDataTable|Write-DbaDataTable -SqlInstance YOURSERVER -database Demo -Table MyTable -Schema dbo -AutoCreateTable; |
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
| $SourceServer = "MYSOURCE"; | |
| $SourceDB = "MySourceDB"; | |
| $DestDB = "MyDestDB"; | |
| $TableName = "MyTable"; | |
| # Get the table definition from the source | |
| $tablescript = Get-DbaDbTable -ServerInstance $SourceServer -Database $SourceDB -Table $TableName | Export-DbaScript -Passthru; | |
| # Run the script to create the table in the destination | |
| Invoke-DbaQuery -Query $tablescript -ServerInstance $SourceServer -Database $DestDB; |
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
| Invoke-WebRequest -Uri http://firstresponderkit.org | Select-Object -ExpandProperty Headers | |
| Key Value | |
| --- ----- | |
| x-amz-id-2 {QtTLMVw5QobGd/xlueEIY44Ech2va1ZKALhaMrY9f/yI0fBHvAoA6KwGUa5jTQxPF5fF85tuYws=} | |
| x-amz-request-id {86A4E2A10548CA53} | |
| Date {Sat, 03 Jun 2017 16:14:47 GMT} | |
| ETag {"4ff7c8b410c399d5b18e2ab05bbfce22"} | |
| Server {AmazonS3} |
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
| <!DOCTYPE HTML> | |
| <html lang="en-US"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta http-equiv="refresh" content="1;url=https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/tree/master"> | |
| <script type="text/javascript"> | |
| window.location.href = "https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/tree/master" | |
| </script> | |
| <title>Page Redirection</title> |
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
| (Invoke-WebRequest -Uri http://firstresponderkit.org).Links |Format-List | |
| outerHTML : <a href="https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/tree/master">head over here.</a> | |
| tagName : A | |
| href : https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/tree/master |
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
| import-module poshrsjob; | |
| $DownloadDir = "/users/andy/Downloads/poshrsjob"; | |
| $MaxJobs = 3; | |
| foreach ($i in 1..24) { | |
| Start-RSJob -Throttle $MaxJobs -Batch "Demo" -argumentlist $i, $DownloadDir -ScriptBlock { | |
| param($JobNum, $OutputDir) | |
| $OutputFile = Join-Path -Path $OutputDir -ChildPath "RSJob$JobNum.zip"; | |
| Start-Sleep -Seconds (get-random -Minimum 1 -Maximum 15); | |
| Invoke-WebRequest -uri "https://github.com/proxb/PoshRSJob/archive/master.zip" -OutFile $OutputFile; | |
| } |
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
| import-module poshrsjob; | |
| $PollingInterval = 5; | |
| $CompletedThreads = 0; | |
| $Status = Get-RSJob | Group-Object -Property State; | |
| $TotalThreads = ($Status|Select-Object -ExpandProperty Count | Measure-Object -Sum).Sum; | |
| while ($CompletedThreads -lt $TotalThreads) { | |
| $CurrentJobs = Get-RSJob; | |
| $CurrentJobs.Where( {$PSItem.State -eq "Completed"}) | Receive-RSJob | Out-Null; | |
| $CurrentJobs.Where( {$PSItem.State -eq "Completed"}) | Remove-RSJob | Out-Null; | |
| $Status = $CurrentJobs|Group-Object -Property State; |