Skip to content

Instantly share code, notes, and snippets.

@dgosbell
dgosbell / update-SsasLastProcessed.ps1
Created May 13, 2015 11:11
This script will update the specified target table the last processed date and time of every other table in the SSAS Tabular database. For more details see http://darren.gosbell.com/archive/2015/05/13/ssas-tabularndashper-table-lastprocessed-dates.aspx
<#
.SYNOPSIS
Updates a LastProcessed table in an SSAS Tabular database
.DESCRIPTION
This script uses AMO to loop through each table in the specified
database and pushed the table name and the LastProcessed Date/time
value into the specified table. Requires
.NOTES
File Name : update-ssaslastupdated.ps1
Author : Darren Gosbell
## the following lists all the constrained delegation settings for a given AD user
## adapted from http://www.harbar.net/archive/2015/06/02/Configuring-Kerberos-Constrained-Delegation-with-Protocol-Transition-and-the-Claims.aspx
## to get ActiveDirectory Powershell module on Win 10 use the following
## https://gallery.technet.microsoft.com/Install-the-Active-fd32e541
Param(
[Parameter(Mandatory=$true, Position=0, HelpMessage="AD Account Name")]
[string]$account
)
import-module ActiveDirectory
$u = get-aduser $account -properties "msDS-AllowedToDelegateTo", ServicePrincipalNames
$serverName="localhost"
$databaseName = "AdventureWorks"
$cubeName = "Model"
$outputFolder = "d:\data"
# load the AMO into the current runspace
[System.Reflection.Assembly]::LoadwithpartialName("Microsoft.AnalysisServices") > $null
# connect to the server
$svr = new-Object Microsoft.analysisservices.Server
$serverList = @("localhost","localhost\MD12") #an array of SSAS instances
$roleName = "Metadata Role"
$roleMembers = @("Everyone") # an array of user/group names
# load the AMO assemblies into the current runspace
$assembly = [System.Reflection.Assembly]
$assembly::LoadWithPartialName("Microsoft.AnalysisServices") > $null
<#
.SYNOPSIS
Warms the SSAS permissions when using a dynamic security role
.NOTES
Author: Darren Gosbell
Date: 6 Jul 2016
.DESCRIPTION
Warms the Global Scope cache for a list of users. This is useful when
the first connection on a cold cache per user is slow due to evaluation
of a dynamic security role. For production usage it would make sense
## This is an example script showing how to detect the compatibility level
## and execute the DBCC command against multiple databases
## note: to execute DBCC from powershell you need to wrap it in <Execute> and <Command> wrappers
## or it won't work
## Author: Darren Gosbell
## Date : 19 July 2016
$serverName = 'localhost\tab16'
[Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices") > $null
@dgosbell
dgosbell / refresh-with-override-example.txt
Last active December 7, 2016 00:50
Working TMSL Examples
// working examples to replace ones from https://msdn.microsoft.com/en-us/library/mt697588.aspx?f=255&MSPPError=-2147217396
{
"refresh" : {
"type" : "dataOnly",
"objects" : [{
"database" : "AdventureWorks2016",
"table" : "Customer"
}
],
"overrides" : [{
<#
.Synopsis
Turns remote errors on or off for an instance of Power BI Report Server
.PARAMETER $enabled
a boolean that controls whether remote errors are enabled or not
.INPUTS
None - you cannot pipe into this function
.OUTPUTS
None
.EXAMPLE
param (
[string] $dllFile = $(throw "-dllFile parameter required"),
[string] $xmlaFile
)
if ($xmlaFile -eq $null) { $xmlaFile = $dllFile.Replace(".dll", ".xmla") }
write-host "Started Creating Xmla script: $xmlaFile"
<#
$dllfile = "C:\Users\c950497\Downloads\SQLQuery v1.3.5\SQLQuery.dll"
$xmlafile = "C:\Users\c950497\Downloads\SQLQuery v1.3.5\SQLQuery.xmla"
## installs the PowerBIPS module if it's not already installed
if ((get-module MicrosoftPowerBIMgmt.Profile) -eq $null) { install-module PowerBIPS }
## login to PowerBI with credentials that have capacity management rights
Login-PowerBI
## lists the details of the available capacities
Invoke-PowerBIRestMethod -Method GET -Url "https://api.powerbi.com/v1.0/myorg/capacities"