Skip to content

Instantly share code, notes, and snippets.

Avatar

Aaron Nelson SQLvariant

View GitHub Profile
@SQLvariant
SQLvariant / Change_Adf_Retries.ps1
Last active Sep 14, 2022
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 / Find_and_Replace.ps1
Created Aug 5, 2022
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 Aug 3, 2022
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 Jul 21, 2022
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.
@SQLvariant
SQLvariant / Read_ADF_LinkedService_Contents.ps1
Created Jul 15, 2022
PowerShell script to read info out of Linked Services .JSON files on your local machine.
View Read_ADF_LinkedService_Contents.ps1
# > Before you begin, navigate to a local directory containing the Linked Services files from your ADF
c:\temp\ADF\linkedService
# First, run through all of the ADF LinkedService files to extract all the pieces of the connection information we're loking for.
$LinkedServices = @()
$LinkedServiceFiles = dir -Filter *.json
foreach($LinkedServiceFile in $LinkedServiceFiles){
$LinkedServiceContents = Get-Content -Path $LinkedServiceFile | ConvertFrom-Json -Depth 20
switch($LinkedServiceContents.properties.type){
'AzureSqlDatabase' {$Connection = $LinkedServiceContents.properties.typeProperties.connectionString}
'AzureSqlDW' {$Connection = $LinkedServiceContents.properties.typeProperties.connectionString}
@SQLvariant
SQLvariant / Invoke-KqlQuery.ps1
Last active Sep 8, 2022
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 / Get-SqlChange.ps1
Last active May 12, 2022
Simple PowerShell function to wrap the SQLPackage.exe command for deployment automation
View Get-SqlChange.ps1
function Get-SqlChange
{ <#
.SYNOPSIS
This command runs SQLPackage.exe to compare a .DACPAC file to a database and generate a file.
.DESCRIPTION
This command runs SQLPackage.exe to compare a .DACPAC file to a database and generate a either a DeployReport or SQL change file.
.PARAMETER Action
Specify the action, currently only "DeployReport" and "Script" are supported.
@SQLvariant
SQLvariant / Set AzSQL AAD to Remote Group.ipynb
Last active Aug 23, 2022
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 / Out-DataTable.ps1
Created Aug 3, 2021
v1.1 of Chad Miller's Out-DataTable PowerShell function
View Out-DataTable.ps1
#######################
<#
.SYNOPSIS
Creates a DataTable for an object
.DESCRIPTION
Creates a DataTable based on an objects properties.
.INPUTS
Object
Any object can be piped to Out-DataTable
.OUTPUTS
@SQLvariant
SQLvariant / Invoke-DB2Query.ps1
Last active Mar 27, 2021
PowerShell function for running a query against a DB2 database.
View Invoke-DB2Query.ps1
function Invoke-DB2Query
{
<#
.SYNOPSIS
This function runs a query against a DB2 database.
.DESCRIPTION
This function runs a query against a DB2 database using the account of the user executing the command.
.PARAMETER Server