Skip to content

Instantly share code, notes, and snippets.

### Author: Darren Gosbell (https://darren.gosbell.com)
### Date : 22 Jan 2021
### Usage : To use this script just update the following 4 variables for you environment
$server = "localhost\tab17"
$database = "adventure works"
$query = “evaluate 'Date'”
$filename = “c:\temp\tofile.csv”
@dgosbell
dgosbell / QueryForCSDLMetadata.dax
Created September 13, 2020 05:16
A DMV query that returns the CSDL metadata for the specified database
SELECT *
FROM SYSTEMRESTRICTSCHEMA ($SYSTEM.DISCOVER_CSDL_METADATA
, [CATALOG_NAME] = '<databaseid>'
, [VERSION]='2.0')
###
### Script : AMO_GetTraceEventCategories.ps1
### Author : Darren Gosbell (https://darren.gosbell.com)
### Date : 14 August 2020
### Description: Outputs a list of the Trace Event Category and Subcategories for Analysis Services
###
$server = "Localhost\tab17"
$null = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.adomdclient")
@dgosbell
dgosbell / Load-PackageAdomdClient.ps1
Created March 11, 2020 06:15
Load AnalysisServices nuget packages into a Powershell session
#load the type from the Microsoft.AnalysisServices.AdomdClient nuget package
Install-Package Microsoft.AnalysisServices.AdomdClient.retail.amd64 -Source "https://www.nuget.org/api/v2"
$p = get-package Microsoft.AnalysisServices.AdomdClient.retail.amd64
$nugetFile = get-childitem $p.source
$adomdFile = join-path $nugetFile.DirectoryName "lib\net45\Microsoft.AnalysisServices.AdomdClient.dll"
add-type -path $adomdFile
@dgosbell
dgosbell / New-RandomSalt.ps1
Created November 6, 2019 11:11
Creates a new random base 64 salt
$SaltByteLength = 64
$rncCsp = new-object System.Security.Cryptography.RNGCryptoServiceProvider
$salt = new-object byte[] $SaltByteLength
$rncCsp.GetBytes($salt);
[System.Convert]::ToBase64String($salt)
<#
.Synopsis
This script checks a local Power BI Report Server instance against the version
currently available for download and reports if the two versions are no the same.
.Notes
Author: Darren Gosbell
Date: 8 April 2019
.Example
@dgosbell
dgosbell / Generate-MachineKey.ps1
Last active May 5, 2020 04:13
Generates a machineKey element for Power BI Report Server. Goes under <Configuration> element in rsreportserver.config file when you have an NLB setup
# Generates a <machineKey> element that can be copied + pasted into a rsReportServer.config file for PowerBI Report Server
function Generate-MachineKey {
[CmdletBinding()]
param (
[ValidateSet("AES", "DES", "3DES")]
[string]$decryptionAlgorithm = 'AES',
[ValidateSet("MD5", "SHA1", "HMACSHA256", "HMACSHA384", "HMACSHA512","AES")]
[string]$validationAlgorithm = 'AES' #'HMACSHA256'
)
process {
$process = "MSMDSRV"
get-process -name $process | % {get-nettcpconnection -OwningProcess $_.id} | select-object @{Name="Process"; Expression = {$Process}},LocalPort, RemotePort, OwningProcess
$process = "PBIDesktop"
get-process -name $process | % {get-nettcpconnection -OwningProcess $_.id} | select-object @{Name="Process"; Expression = {$Process}},LocalPort, RemotePort, OwningProcess
function Get-NetworkStatistics
{
$properties = ‘Protocol’,’LocalAddress’,’LocalPort’
$properties += ‘RemoteAddress’,’RemotePort’,’State’,’ProcessName’,’PID’
netstat -ano | Select-String -Pattern ‘\s+(TCP|UDP)’ | ForEach-Object {
$item = $_.line.split(” “,[System.StringSplitOptions]::RemoveEmptyEntries)
if($item[1] -notmatch ‘^\[::’)
@dgosbell
dgosbell / deploy-BimFile.ps1
Created January 15, 2019 22:09
A simple example of how to manually deploy a model.bim file using Powershell
#Requires -Version 3.0
param(
[Parameter(Mandatory=$true)]
[string]$serverName,
[Parameter(Mandatory=$true)]
[string]$databaseName,
[Parameter(Mandatory=$true)]
[string]$pathToBimFile
)