Skip to content

Instantly share code, notes, and snippets.

Avatar

Aaron Nelson SQLvariant

View GitHub Profile
@SQLvariant
SQLvariant / DockerDesktop-with-SQL-PowerShell-90.ipynb
Last active Mar 27, 2021
Create a SQL-on-Linux Docker Container with a Host Mount and Restore the AdventureWorks2016 Database
View DockerDesktop-with-SQL-PowerShell-90.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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
@SQLvariant
SQLvariant / Invoke-SqlNotebook.md
Last active Mar 27, 2021
3 different options for using the Invoke-SqlNotebook cmdlet
View Invoke-SqlNotebook.md

Use with Registered Servers

Use Registered Servers or Central Management Server to run Invoke-SqlNotebook against multiple servers.

$datetime = Get-Date -Format yyyyMMddhhmm

dir 'SQLSERVER:\SQLRegistration\Database Engine Server Group' |
WHERE { $_.Mode -ne 'd'} |            
foreach {
@SQLvariant
SQLvariant / Mmmm_Chocolatey.ps1
Last active Feb 24, 2021
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
View CSharp_Corner.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLvariant
SQLvariant / GetStartedWithPowerBIcmdlets.ipynb
Created Dec 11, 2019
PowerShell Notebook to get you started with current PowerShell + Power BI capabilities.
View GetStartedWithPowerBIcmdlets.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLvariant
SQLvariant / Invoke-DaxQuery.Test.ps1
Last active Jan 6, 2021
PowerShell function to run a DAX query against a Power BI Repot / Analysis Services, and accompanying Pester test (which requires a separate .PBIX file that I haven't published yet)
View Invoke-DaxQuery.Test.ps1
Describe "Invoke-DaxQuery" {
Context "Invoke a DAX Query and test the result"{
# Run queries and compare them
$results = Invoke-DaxQuery -DAXQuery "EVALUATE ReportCatalogQuery"
# Test if the config was retrieved
It "Should verify the count is correct by comparing against a static number" {
@($results).Count | Should -Be 36
}
@SQLvariant
SQLvariant / Export_PBI_AuditLogs.ipynb
Created Dec 10, 2019
PowerShell Notebook showing how to use both cmdlets available for extracting Power BI audit log events
View Export_PBI_AuditLogs.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLvariant
SQLvariant / DeploySSIS_ISPac.ps1
Last active Dec 17, 2020
Deploy an .ISPAC file to a SSISDB Catalog using the SSIS Provider
View DeploySSIS_ISPac.ps1
# Variables
$TargetFolderName = "ProviderSolution"
$ProjectFilePath = "C:\temp\SSIS\TestSSISSolution\TestSSISProject\bin\Development\TestSSISProject.ispac"
$ProjectName = "TestSSISProject"
# Get the Integration Services catalog
$ProviderCatalog = Get-Item SQLSERVER:\SSIS\localhost\SQL2017\Catalogs\SSISDB\
# Create the target folder
New-Object "Microsoft.SqlServer.Management.IntegrationServices.CatalogFolder" ($ProviderCatalog,
@SQLvariant
SQLvariant / Query_DB2.ps1
Created Nov 20, 2020
Uploaded via PowerShell
View Query_DB2.ps1
$dbName="SAMPLE"
$server="not.my.localhost"
#Define connection string for the database
$cn = new-object system.data.OleDb.OleDbConnection("server=$($server);Provider=IBMDADB2;DSN=$($dbName);trusted_connection=true;");
#Define data set for first query
$ds = new-object "System.Data.DataSet" "ds"
#Define query to run
$q = "select * from hello_world"
# Define data object given the specific query and connection string