Skip to content

Instantly share code, notes, and snippets.

View SQLvariant's full-sized avatar

Aaron Nelson SQLvariant

View GitHub Profile
@SQLvariant
SQLvariant / Invoke-SqlNotebook.md
Last active May 27, 2022 09:53
3 different options for using the Invoke-SqlNotebook cmdlet

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 / Export_PBIAuditLogs_toDailyJson.ps1
Last active October 3, 2019 22:08
Export Power BI Audit Logs to .JSON files
90..1 |
foreach {
$Date = (((Get-Date).Date).AddDays(-$_))
$StartDate = (Get-Date -Date ($Date) -Format yyyy-MM-ddTHH:mm:ss)
$EndDate = (Get-Date -Date ((($Date).AddDays(1)).AddMilliseconds(-1)) -Format yyyy-MM-ddTHH:mm:ss)
Get-PowerBIActivityEvent -StartDateTime $StartDate -EndDateTime $EndDate -ResultType JsonString |
Out-File -FilePath "c:\temp\PowerBIAuditLogs\PowerBI_AudititLog_$(Get-Date -Date $Date -Format yyyyMMdd).json"
}
@SQLvariant
SQLvariant / Import_HundredsOf_CSVs.PS1
Created October 10, 2019 20:42
Basic script to import every .CSV file from a directory and INSERT each one into it's own table in SQL Server. It will create the table if it doesn't exist.
dir -Filter *.csv |
foreach {
"$($_.Name)";
,(Import-Csv -Path $_.Name) |
Write-SqlTableData -ServerInstance localhost\SQL2017 -DatabaseName BlankDB -SchemaName dbo -TableName $_.BaseName -Force
}
@SQLvariant
SQLvariant / GatewayClusters.ps1
Last active May 23, 2024 15:47
Get the Governance Data You Need Out of Your Power BI Gateways with PowerShell
<# Make sure you have the modules installed.
You only need the ImportExcel module if you want to export the results to Excel files. #>
Install-Module DataGateway
Install-Module ImportExcel
<# Discovery #>
# All Gateway Clusters in your tenant.
Get-DataGatewayCluster -Scope Organization
# All nodes of all Gateway Clusters in your tenant.
@SQLvariant
SQLvariant / DeadSimple_PSResults_Lag.ipynb
Created December 6, 2019 18:26
Examples of lagging results in PowerShell Notebooks with v0.1.2 of the powershell_kernel
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLvariant
SQLvariant / ExportPowerBIWorkspaceAssets_withPowerShell.ipynb
Created December 10, 2019 18:31
PowerShell Notebook (open in Azure Data Studio) to help you export all of your Power BI Workspace Asset information.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLvariant
SQLvariant / Export_PBI_AuditLogs.ipynb
Created December 10, 2019 19:22
PowerShell Notebook showing how to use both cmdlets available for extracting Power BI audit log events
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLvariant
SQLvariant / Export_PowerPlatform_Gateway_Assets.ipynb
Created December 10, 2019 22:24
Export details of your PowerPlatform Gateway assets from your entire tenant.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLvariant
SQLvariant / Copy_PowerBI_WorkspaceItems.ipynb
Created December 11, 2019 00:37
Different options for copying items in a Power BI Workspace.
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 December 11, 2019 00:42
PowerShell Notebook to get you started with current PowerShell + Power BI capabilities.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.