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
function Compare-Array | |
{ | |
param( | |
[array]$Ref, | |
[array]$Diff | |
) | |
$max = [math]::Max($Ref.Length,$Diff.Length) | |
for($i = 0; $i -lt $max; $i++){ |
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
function New-ToDo { | |
<# | |
.SYNOPSIS | |
Creates quick To Do list in Notepad | |
.DESCRIPTION | |
Creates quick To Do list in Notepad | |
.PARAMETER List | |
comma separated list of items to put in to do list |
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
function Read-SQLConfigFile { | |
<# | |
.SYNOPSIS | |
Takes configuration file and shows features that are being set | |
.DESCRIPTION | |
Function to show what features and settings are being adjusted by the configuration file. Allows for comparison of | |
config files when combined with Compare-Object | |
.EXAMPLE |
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
function Show-ExceptionType { | |
<# | |
.SYNOPSIS | |
Function to give inheritence of exception types for error handling purposes | |
.DESCRIPTION | |
Take an error and returns all InnerException types for the Error object and the error message | |
.PARAMETER Exception | |
The error exception as it occurred in your script |
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
===== | |
For VSCode extension replacerules <https://marketplace.visualstudio.com/items?itemName=bhughes339.replacerules> | |
This needs to be placed in the settings.json file | |
dont forget to add a trailing comma to the content that you find there | |
and also close the final curly brace correctly | |
===== | |
"replacerules.rules": { | |
"Format sp_diagnostics results 01": { | |
"find": "><", |
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
git branch -m master main | |
git checkout main | |
git push -u origin main | |
now go to github.com and change the default branch ot main | |
created with reference to https://www.hanselman.com/blog/EasilyRenameYourGitDefaultBranchFromMasterToMain.aspx |
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
<# | |
Zips a set of files into a set of zip files with a max size to allow emailing of zip files in size-restricted email environment. | |
Imagine 20 evenly sized files that need to be zipped and when compressed into a single .zip file, the file is 65MB. With an Exchange | |
email size limit of 15MB this cannot be sent by email. Using this function you can set a ZipSize limit of 12MB and then the output | |
will be 5 .zip files with a size around 12MB and one of around 5MB. | |
No source file will be spanned across zip files so the actual balance of zip file sizes will vary. | |
#> |
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
/* | |
To visualise the hierarchy of SQL Server Audit Events and their parent groups | |
I think this was originally on the Microsoft official SQL Server Books online and it possibly still is. I can however never | |
find it when I need it so I have taken an adjusted version and pasted it here for easy access. | |
Thanks to unknown Microsoft employee that got their head around the CTE and Event relationships logic to come up with this. | |
*/ | |
WITH datas (EventLevel, EventParent, EventName, EventType) |
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
<# | |
Assumptions | |
$splatExcel is a hash table used for splatting the data into the Excel file with Export-Excel. Path is the path for the file. | |
The Excel file has a worksheet with the name of _BatchLoadData_ which has a single table named _BatchLoadDataTable_ in it | |
The data table has many columns that include _JobID_ and _Batch_ | |
Result | |
A worksheet is added to the workbook called _BatchLoadPvt_ which contains the pivot table that we describe |
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
$scrpt1 = { | |
if(!(test-connection 'localhost' -Count 1 -Quiet)){return} | |
else{0..7 | % { "'"+(get-date).AddDays($_)+"'" }} | |
} | |
$scrpt2 = { | |
if((get-date).minute % 2 -eq 0){ | |
@('Mon','Wed','Fri')} | |
else{ | |
@('Tue','Thu','Sat') | |
} |