This file contains 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
# create an array of SQL Server instances | |
$allInstances = @('server1', 'server2', 'server3') | |
# Loop through each SQL server instance | |
foreach($sqlInstance in $allInstances) { | |
# Output the current SQL server instance | |
Write-Output "`$sqlInstance: $sqlInstance" | |
# Execute a query on the current SQL server instance and store the results |
This file contains 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
<# How to use TSS Tools with Microsoft Support - https://gist.github.com/nanoDBA/ac409275a6ef406f9134856f1245f72f #> | |
<# Pretty Timestamp prompt using dbatools module#>function Prompt{Write-Host "[" -NoNewline; Write-Host (Get-Date -Format "HH:mm:ss") -ForegroundColor Gray -NoNewline;try{$history = Get-History -ErrorAction Ignore;if ($history) {Write-Host "][" -NoNewline;if (([System.Management.Automation.PSTypeName]'Sqlcollaborative.Dbatools.Utility.DbaTimeSpanPretty').Type){Write-Host ([Sqlcollaborative.Dbatools.Utility.DbaTimeSpanPretty]($history[-1].EndExecutionTime - $history[-1].StartExecutionTime)) -ForegroundColor Gray -NoNewline} else{Write-Host ($history[-1].EndExecutionTime - $history[-1].StartExecutionTime) -ForegroundColor Gray -NoNewline;}}}catch { }Write-Host "] $($executionContext.SessionState.Path.CurrentLocation.ProviderPath)" -NoNewline;"> "} | |
cd $env:temp | |
$targetTssDir = 'c:\tss_tools' | |
if (!(Test-Path $targetTssDir)) {mkdir $targetTssDir }; | |
Start-BitsTransfer -Destination .\tss_tools.zip - |
This file contains 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
<# copy DiskSpd to c:\DiskSpd after downloading it#> | |
cd $env:temp | |
Start-BitsTransfer -Destination .\DiskSpd.zip -Source 'https://aka.ms/getdiskspd' | |
$Path = 'c:\DiskSpd'; If(-not (Test-Path $Path)){ mkdir $Path } | |
Expand-Archive -Path .\DiskSpd.zip -OutputPath C:\DiskSpd | |
cd \ | |
<# | |
"This example command line will run a 30 second random I/O test using a 20GB test file located on the T: drive, with | |
a 25% write and 75% read ratio, with an 8K block size. It will use eight worker threads, each with four outstanding | |
I/Os and a write entropy value seed of 1GB. It will save the results of the test to a text file called |
This file contains 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
# Console Output RED/GREEN failures for SQL Agent job history, multiple key property sorts | |
# attempting to imitate the output of the SQL Server Management Studio Job History window | |
$paramHash = @{ | |
SqlInstance = 'YOURSERVER01','YOURSERVER02' # comma separated list of SQL Server instances | |
StartDate = "$(((Get-Date).AddDays(-.1) ))" # 0.1 days ago - ARE YOU SURE? This does not mean 1 day. It means 2.4 hours ago. | |
# StartDate = "$(((Get-Date).AddDays(-90) ))" # 90 days ago | |
EndDate = "$((Get-Date ))" # now | |
Job = 'Some SQL Agent Job Name goes here' # name of SQL Agent job goes here | |
ExcludeJobSteps = $false |
This file contains 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
Proposed SQL Server Patching Approach | |
We do not patch to the absolute latest cumulative update(CU). | |
Rather, we strive to patch to the cumulative update(CU) that | |
was released without any intermediate releases(such as hotfixes) | |
between it and the most recent CU. Basically N-1 as long as | |
there aren't any hotfixes. If there were hotfixes then we'll wait | |
until two CU subsequent releases have occurred | |
without hotfixes in between the two to deploy the CU. |
This file contains 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
<# | |
.SYNOPSIS | |
BoxStarter script to configure Windows 10 development PC. | |
.DESCRIPTION | |
You might need to set: | |
Set-ExecutionPolicy RemoteSigned | |
Set-ExecutionPolicy Unrestricted | |
Set-ExecutionPolicy Bypass |
This file contains 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
$sourceFrameRate = 10.74 | |
$filename = "C:\Users\kilroy\2023-02-17_17-37-36_boxstarter_2_of_2.mp4" | |
$newFilename = "$(dir $filename | foreach { Join-Path -Path $_.Directory -ChildPath $_.BaseName })_remove_nonmotion_mute_audio.mp4" | |
ffmpeg.exe -i "$($filename)" -vf "select=gt(scene\,0.0002),setpts=N/($($sourceFrameRate)*TB)" -an "$($newFilename)" | |
<# -an remove audio #> | |
<# -vf "select=gt(scene\,0.001),setpts=N/(<framerategoeshere>*TB)" #> | |
<# https://superuser.com/questions/984841/ffmpeg-remove-parts-without-motion/1029175#1029175 |
This file contains 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
do { | |
$ssms = Get-WmiObject -Class Win32_Process -Filter "name = 'Ssms.exe'" | |
<# Timer/time bomb stub #> $now = Get-Date | |
$timespan = New-TimeSpan -Start $now -End (Get-Date).AddMinutes(55) # '20:25') #'2077-10-09 19:30' | |
Write-Host -ForegroundColor magenta "SSMS active user count: $(($ssms.GetOwner()).User.count)" | |
Write-Host -ForegroundColor magenta "SSMS active users: $(($ssms.GetOwner()).User)" | |
Write-Host -ForegroundColor magenta "Sleeping until $((Get-date).AddSeconds($timespan.TotalSeconds)) ..." | |
Start-Sleep -Seconds $timespan.TotalSeconds | |
} | |
while ( ($ssms.GetOwner()).User.count -GT 0 ) |
This file contains 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
#requires -version 5.0 | |
#Requires -RunAsAdministrator | |
<# DANGER REBOOTING! | |
This is meant for a local machine in a scheduled task | |
and is not handling remoting or remote credentials | |
#> | |
[CmdletBinding()] | |
param ( | |
[Parameter()][int]$DelayMinutes = 15 #default to 15 minute delay if this parameter is not supplied | |
) |
This file contains 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
### Get Command Line History for all users | |
# source: https://gist.github.com/nanoDBA/48f2cd1eab1e4433a97bd106e0dac08d | |
$dirs = (Get-ChildItem -Directory (Split-Path $env:USERPROFILE)).FullName | Sort-Object | |
$allHistories = foreach($profileDir in $dirs){ | |
Write-Output "### $profileDir" | |
$historySavePath = "$profileDir\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt" | |
if(!(Test-Path ($historySavePath) )) { | |
Write-Output "### $historySavePath does not exist" | |
} |
NewerOlder