|
1 | 1 | $__=$__ #quiesce warnings
|
2 | 2 | $CommonFunctionsAndMethodsDir = $PSScriptRoot
|
3 |
| -Write-Host "Loading CommonFunctionsAndMethods.psm1 from: $PSCommandPath" |
| 3 | +Write-Verbose "Loading CommonFunctionsAndMethods.psm1 from: $PSCommandPath" |
4 | 4 | . (Join-Path $CommonFunctionsAndMethodsDir 'SQLServerConnection.ps1');
|
5 | 5 |
|
6 | 6 | $MergeHashTables = {param([HashTable]$base,[HashTable]$new);$new.GetEnumerator()|%{$base.remove($_.Key);$base += @{$_.Key=$_.Value}};$base;};
|
@@ -40,10 +40,10 @@ Function Invoke-SqlFile
|
40 | 40 | $parameters['Verbose'] = $true
|
41 | 41 | }
|
42 | 42 |
|
43 |
| - $dddbefore = Get-Date;Write-Warning("------->>BEFORE<<-------(CommonFunctionsAndMethods.p1:Invoke-SqlFile:Invoke-SqlCommand[$($dddbefore|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") |
| 43 | + $dddbefore = Get-Date;Write-Verbose("------->>BEFORE<<-------(CommonFunctionsAndMethods.p1:Invoke-SqlFile:Invoke-SqlCommand[$($dddbefore|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") |
44 | 44 | $results = (Invoke-SqlCmd @parameters)
|
45 |
| - $dddafter = Get-Date;Write-Warning("------->>After<<-------(CommonFunctionsAndMethods.p1:Invoke-SqlFile:Invoke-SqlCommand[$($dddafter|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") |
46 |
| - Write-Warning("Runtime in Milliseconds: $(($dddafter-$dddbefore).TotalMilliseconds)") |
| 45 | + $dddafter = Get-Date;Write-Verbose("------->>After<<-------(CommonFunctionsAndMethods.p1:Invoke-SqlFile:Invoke-SqlCommand[$($dddafter|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") |
| 46 | + Write-Verbose("Runtime in Milliseconds: $(($dddafter-$dddbefore).TotalMilliseconds)") |
47 | 47 | return $results
|
48 | 48 | }
|
49 | 49 |
|
@@ -100,11 +100,11 @@ Function Invoke-SQLFileOrQuery
|
100 | 100 | AdditionalParameters = $AdditionalParameters
|
101 | 101 | PrintSqlOutput = $PrintSqlOutput
|
102 | 102 | }
|
103 |
| -$dddbefore = Get-Date;Write-Warning("------->>BEFORE<<-------(tSQLt_Validate.ps1:Invoke-SQLFileOrQuery:Invoke-SqlFile[$($dddbefore|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") |
| 103 | +$dddbefore = Get-Date;Write-Verbose("------->>BEFORE<<-------(tSQLt_Validate.ps1:Invoke-SQLFileOrQuery:Invoke-SqlFile[$($dddbefore|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") |
104 | 104 | $QueryOutput = Invoke-SqlFile @parameters
|
105 |
| -$dddafter = Get-Date;Write-Warning("------->>After<<-------(tSQLt_Validate.ps1:Invoke-SQLFileOrQuery:Invoke-SqlFile[$($dddafter|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") |
106 |
| -$dddafter-$dddbefore |
107 |
| - return $QueryOutput |
| 105 | +$dddafter = Get-Date;Write-Verbose("------->>After<<-------(tSQLt_Validate.ps1:Invoke-SQLFileOrQuery:Invoke-SqlFile[$($dddafter|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") |
| 106 | +Write-Verbose("Runtime in Milliseconds: $(($dddafter-$dddbefore).TotalMilliseconds)") |
| 107 | + return $QueryOutput |
108 | 108 | }
|
109 | 109 | catch{
|
110 | 110 | throw
|
@@ -186,46 +186,46 @@ Function Remove-ResourceGroup{
|
186 | 186 | [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string] $ResourceGroupName,
|
187 | 187 | [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string] $BuildId);
|
188 | 188 |
|
189 |
| - Write-Output "▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-"; |
190 |
| - Write-Output ("[{0}]Start processing delete for {1}" -f ((get-date).toString("O")), ($ResourceGroupName)); |
| 189 | + Write-Verbose "▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-"; |
| 190 | + Write-Verbose ("[{0}]Start processing delete for {1}" -f ((get-date).toString("O")), ($ResourceGroupName)); |
191 | 191 |
|
192 | 192 | $MyAzResourceGroup = (Get-AzResourceGroup -name "$ResourceGroupName");
|
193 | 193 | if(("RemovalBy" -in $MyAzResourceGroup.tags.keys) -and (![string]::isnullorempty($MyAzResourceGroup.tags.RemovalBy))) {
|
194 | 194 | $MyAzResourceGroup = $null;
|
195 | 195 | }
|
196 | 196 | if($null -ne $MyAzResourceGroup) {
|
197 | 197 | $Tags = @{};
|
198 |
| - Write-Output ("Add Tag to {0}" -f $ResourceGroupName); |
| 198 | + Write-Verbose ("Add Tag to {0}" -f $ResourceGroupName); |
199 | 199 | $Tags = $MyAzResourceGroup.Tags;
|
200 | 200 | $Tags.remove("RemovalBy");
|
201 | 201 | $Tags += @{"RemovalBy"="$BuildId"};
|
202 | 202 | $MyAzResourceGroup | Set-AzResourceGroup -Tags $Tags;
|
203 | 203 | Start-Sleep 10;
|
204 |
| - Write-Output ("Confirming Tags are still in place for {0}" -f $ResourceGroupName); |
| 204 | + Write-Verbose ("Confirming Tags are still in place for {0}" -f $ResourceGroupName); |
205 | 205 | $MyAzResourceGroup = $MyAzResourceGroup | Get-AZResourceGroup | Where-Object {$_.Tags.RemovalBy -eq "$BuildId"};
|
206 | 206 | $MyAzResourceGroup.Tags | Format-Table;
|
207 | 207 |
|
208 | 208 | if($null -ne $MyAzResourceGroup) {
|
209 |
| - Write-Output "Removing Locks" |
| 209 | + Write-Verbose "Removing Locks" |
210 | 210 | $retrievedResourceGroupName = $MyAzResourceGroup.ResourceGroupName;
|
211 | 211 | Get-AzResource -ResourceGroupName $retrievedResourceGroupName | ForEach-Object {
|
212 | 212 | Get-AzResourceLock -ResourceType $_.ResourceType -ResourceName $_.Name -ResourceGroupName $_.ResourceGroupName | ForEach-Object{
|
213 |
| - Write-Output ("{0} -> {1}" -f $_.ResourceType, $_.ResourceName); |
| 213 | + Write-Verbose ("{0} -> {1}" -f $_.ResourceType, $_.ResourceName); |
214 | 214 | $_ | Remove-AzResourceLock -Force
|
215 | 215 | }
|
216 | 216 | }
|
217 |
| - Write-Output ("Removing RG {0}" -f $retrievedResourceGroupName); |
| 217 | + Write-Verbose ("Removing RG {0}" -f $retrievedResourceGroupName); |
218 | 218 | $MyAzResourceGroup | Remove-AzResourceGroup -Force;
|
219 | 219 | }
|
220 | 220 | else {
|
221 |
| - Write-Output ("Tags changed by another process. Resource Group {0} is no longer eligible to be deleted." -f $ResourceGroupName); |
| 221 | + Write-Verbose ("Tags changed by another process. Resource Group {0} is no longer eligible to be deleted." -f $ResourceGroupName); |
222 | 222 | }
|
223 | 223 | }
|
224 | 224 | else {
|
225 |
| - Write-Output ("Processing skipped for Resource Group: {0} Build Id: {1}" -f $ResourceGroupName, $BuildId); |
| 225 | + Write-Verbose ("Processing skipped for Resource Group: {0} Build Id: {1}" -f $ResourceGroupName, $BuildId); |
226 | 226 | }
|
227 |
| - Write-Output ("[{0}]Done processing delete for {1}" -f ((get-date).toString("O")), ($ResourceGroupName)) |
228 |
| - Write-Output "▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-"; |
| 227 | + Write-Verbose ("[{0}]Done processing delete for {1}" -f ((get-date).toString("O")), ($ResourceGroupName)) |
| 228 | + Write-Verbose "▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-"; |
229 | 229 | }
|
230 | 230 |
|
231 | 231 | Function Get-SnipContent {
|
@@ -267,7 +267,7 @@ Function Replace-InFile {
|
267 | 267 | $isRegex = $true
|
268 | 268 | $rv = $rv[0]
|
269 | 269 | }
|
270 |
| - Write-Host("Replacing >$_< with >$rv<..."); |
| 270 | + Write-Verbose("Replacing >$_< with >$rv<..."); |
271 | 271 | if($isRegex){
|
272 | 272 | $fileContent = $fileContent -replace $_, $rv
|
273 | 273 | }else{
|
|
0 commit comments