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
$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
## 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"
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 ‘^\[::’)
<#
.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