From 7c09213eb5e065b7b1faa98d2a7ed7d240dba060 Mon Sep 17 00:00:00 2001 From: Daniel Loth Date: Thu, 5 Dec 2024 15:43:25 +1100 Subject: [PATCH] Update Merge Blitz.ps1 so not hardcoded to directory path This change updates the script such that it'll run on other peoples' machines, even when they don't have a folder path that is specific to Brent's developer machine. --- Documentation/Development/Merge Blitz.ps1 | 30 +++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/Documentation/Development/Merge Blitz.ps1 b/Documentation/Development/Merge Blitz.ps1 index 735a0903..c413295b 100644 --- a/Documentation/Development/Merge Blitz.ps1 +++ b/Documentation/Development/Merge Blitz.ps1 @@ -1,24 +1,28 @@ #Set your file path -$FilePath = "/Users/brentozar/LocalOnly/Github/SQL-Server-First-Responder-Kit" -$SqlVersionsPath = "$FilePath/SqlServerVersions.sql" -$BlitzFirstPath = "$FilePath/sp_BlitzFirst.sql" +$RepoRootPath = $PSScriptRoot +$RepoRootPath = Join-Path -Path $RepoRootPath -ChildPath ".." +$RepoRootPath = Join-Path -Path $RepoRootPath -ChildPath ".." +$RepoRootPath = Resolve-Path -Path $RepoRootPath + +$SqlVersionsPath = "$RepoRootPath/SqlServerVersions.sql" +$BlitzFirstPath = "$RepoRootPath/sp_BlitzFirst.sql" #Azure - skip sp_Blitz, sp_BlitzBackups, sp_DatabaseRestore, sp_ineachdb -Get-ChildItem -Path "$FilePath" -Filter "sp_Blitz*.sql" | +Get-ChildItem -Path "$RepoRootPath" -Filter "sp_Blitz*.sql" | Where-Object { $_.FullName -notlike "*sp_Blitz.sql*" -and $_.FullName -notlike "*sp_BlitzBackups*" -and $_.FullName -notlike "*sp_DatabaseRestore*"} | -ForEach-Object { Get-Content $_.FullName } | -Set-Content -Path "$FilePath/Install-Azure.sql" -Force +ForEach-Object { Get-Content $_.FullName } | +Set-Content -Path "$RepoRootPath/Install-Azure.sql" -Force if ( test-path "$BlitzFirstPath") - { Add-Content -Path "$FilePath/Install-All-Scripts.sql" -Value (Get-Content -Path "$BlitzFirstPath")} - + { Add-Content -Path "$RepoRootPath/Install-All-Scripts.sql" -Value (Get-Content -Path "$BlitzFirstPath")} + #All Scripts -Get-ChildItem -Path "$FilePath" -Filter "sp_*.sql" | +Get-ChildItem -Path "$RepoRootPath" -Filter "sp_*.sql" | Where-Object { $_.FullName -notlike "*sp_BlitzInMemoryOLTP*" -and $_.FullName -notlike "*sp_BlitzFirst*"} | -ForEach-Object { Get-Content $_.FullName } | -Set-Content -Path "$FilePath/Install-All-Scripts.sql" -Force +ForEach-Object { Get-Content $_.FullName } | +Set-Content -Path "$RepoRootPath/Install-All-Scripts.sql" -Force #append script to (re-)create SqlServerVersions Table (https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/issues/2429) if ( test-path "$SqlVersionsPath") - { Add-Content -Path "$FilePath/Install-All-Scripts.sql" -Value (Get-Content -Path "$SqlVersionsPath")} + { Add-Content -Path "$RepoRootPath/Install-All-Scripts.sql" -Value (Get-Content -Path "$SqlVersionsPath")} if ( test-path "$BlitzFirstPath") - { Add-Content -Path "$FilePath/Install-All-Scripts.sql" -Value (Get-Content -Path "$BlitzFirstPath")} + { Add-Content -Path "$RepoRootPath/Install-All-Scripts.sql" -Value (Get-Content -Path "$BlitzFirstPath")}