Skip to content

Instantly share code, notes, and snippets.

Avatar

Aaron Nelson SQLvariant

View GitHub Profile
@SQLvariant
SQLvariant / Invoke-KqlQuery.ps1
Last active May 11, 2023 23:44
A PowerShell function to run a KQL query against an Azure Data Explorer cluster. If the Microsoft.Azure.Kusto.Tools NuGet package does not exist, this command will attempt to install the latest version of it.
View Invoke-KqlQuery.ps1
function Invoke-KqlQuery
{ <#
.SYNOPSIS
This command runs a KQL Query against an Azure Data Explorer cluster.
.DESCRIPTION
This command runs a KQL Query against an Azure Data Explorer cluster using the Azure AD User
Authentication method, unless an access token is passed in with the -AccessToken parameter.
.PARAMETER ClusterUrl
@SQLvariant
SQLvariant / Test-Example.PS1
Last active April 13, 2023 21:46
A function to test the Examples inside the Help of a PowerShell command.
View Test-Example.PS1
function Test-Example {
<#
.SYNOPSIS
A function to test the Examples inside the Help of a PowerShell command.
.DESCRIPTION
A function to test the Examples inside the Help of a PowerShell command to see if they can be successfully executed or not.
.NOTES
Currently, this command only supports testing one example at a time.
.LINK
https://gist.github.com/SQLvariant/683b6b16212c7e665d1bffb7fbed98c4
@SQLvariant
SQLvariant / Build_SQLInstance_wStringCreds_andPortNumber.ps1
Last active January 28, 2023 22:28
Use Invoke-ExecuteNotebook to build a SQL-on-Linux instance in a Docker container, by calling Invoke-ExecuteNotebook to execute the Notebook, and passing in the sa_password & digits for the name/port number to the Notebook as a parameter.
View Build_SQLInstance_wStringCreds_andPortNumber.ps1
Invoke-ExecuteNotebook -InputNotebook .\SQL-on-Docker-with-PowerShell.ipynb -Parameters @{sa_password = 'Test9999'; SQLNumber = 97}
@SQLvariant
SQLvariant / Mmmm_Chocolatey.ps1
Last active January 27, 2023 09:35
Install SQL / Data Developer Desktop Tools from Chocolatey
View Mmmm_Chocolatey.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install chocolatey -y
choco install sql-server-management-studio -y
choco install azure-data-studio -y
choco install azuredatastudio-powershell -y
choco install git.install -y
choco install vscode -y
choco install vscode-powershell -y
choco install powerbi -y
@SQLvariant
SQLvariant / CellFindingVisitor.cs
Created August 11, 2020 18:20 — forked from rjmholt/CellFindingVisitor.cs
PowerShell AST visitor to break up a file by comments
View CellFindingVisitor.cs
using System;
using System.Collections.Generic;
using System.Management.Automation.Language;
public class ScriptExtent : IScriptExtent
{
private readonly IScriptPosition _start;
private readonly IScriptPosition _end;
@SQLvariant
SQLvariant / Change_Adf_Retries.ps1
Last active September 14, 2022 17:45
A simple script to change the retry counts on certain activities in ADF pipelines.
View Change_Adf_Retries.ps1
# Go to wherever the pipelines are.
$DownloadLocation = 'C:\temp\ADF\pipeline'
cd $DownloadLocation
# Just have a quick look.
$PipelinesContents = @()
foreach($PipelineFile in dir $DownloadLocation){
$PipelineContents = Get-Content -Path $PipelineFile | ConvertFrom-Json -Depth 20
$PipelinesContents += $PipelineContents
$PipelineFile = $null
@SQLvariant
SQLvariant / Set AzSQL AAD to Remote Group.ipynb
Last active August 23, 2022 20:21
PowerShell commands for setting the AAD Auth of an Azure SQL instance to a Remote Group in a different tenant
View Set AzSQL AAD to Remote Group.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLvariant
SQLvariant / Find_and_Replace.ps1
Created August 5, 2022 13:48
A simple Find & Replace script for changing names of things withing Linked Service, Dataset, or Pipeline files.
View Find_and_Replace.ps1
<# Search for something inside an ADF file and replace it. #>
$Datasets = dir 'C:\temp\MDD-ADF-Test-Repo\dataset' -Recurse
foreach($Dataset in $Datasets.Where({$_.Mode -ne 'd----'})){
$Dataset.Name
if((Get-Content $Dataset.FullName | foreach{ $_ -match 'AzureSqlDatabase1' }) -eq $true ){"Fix it"
(Get-Content $Dataset.FullName).Replace('Azure_SqlDatabase1', 'MDD_SampleSQL_LS') | Set-Content -Path $Dataset.FullName }
else{"Nothing to do"}
}
@SQLvariant
SQLvariant / CopyingPipelineActivities.ipynb
Last active August 3, 2022 20:24
This simple PowerShell script shows you how to copy activities from one ADF pipeline, and add those activities to another ADF pipeline.
View CopyingPipelineActivities.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLvariant
SQLvariant / AdventureWorks_Tables.ipynb
Last active July 21, 2022 18:47
Simple example of running a query against the AdventureWorks db and storing the results in a Jupyter Notebook.
View AdventureWorks_Tables.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.