Skip to main content

Posts

Showing posts from 2017

Azure Automation Script - Process Tabular Model in Azure Analysis Services

workflow ProcessTabularModel {    param         (             # Fully-qualified name of the Azure AS server             [parameter(Mandatory=$true)]             [string] $AzureASName = "asazure://xxxxxxx.asazure.windows.net/yyyyyyyyy",             # DB Name             [parameter(Mandatory=$true)]             [string] $DataBaseName = "zzzzzzzz",             # Credentials for $AzureASName stored as an Azure Automation credential asset             # When using in the Azure Automation UI, please enter the name of the credential asset for the "Credential" parameter             [parameter(Mandatory=$true)]             [PSCredential] $AzureASCredential ...

Generate Calendar Table in Power BI with Fiscal Year Attributes

In Power BI go to Get Data --> Blank Query and paste into the Function windows the text below. This function takes as parameters: - StartYear (e.g., 2012) - EndYear (e.g., 2018) -FiscalYearStartMonth (e.g., 4) And it will generate a calendar table for dates from Jan-1-<StartYear> till Dec-31-<EndYear> and columns for Fiscal Year, Fiscal Month, Fiscal Quarter, Fiscal Year Day where the Fiscal year begins on FiscalYearStartMonth = (StartYear as number, EndYear as number, FiscalYearStartMonth as number)=> let     //Capture the date range from the parameters     StartDate = #date(StartYear, 1, 1),     EndDate = #date(EndYear, 12, 31), //Get the number of dates that will be required for the table     GetDateCount = Duration.Days(EndDate - StartDate)+1, //Take the count of dates and turn it into a list of dates     GetDateList = List.Dates(StartDate, GetDateCount,  ...

Find All Azure DBs where a table is missing

Import-Module "SqlServer" $fullsqlsrv='myservername.database.windows.net' $sa='myadmin' $sapwd='mypassword' $connStr = "Server = $fullSqlSrv ; Database = master; User ID=$sa;Password=$sapwd" $connection = New-Object Microsoft.SqlServer.Management.Common.ServerConnection $connection.ConnectionString = $connStr $connection.Connect() $server = New-Object Microsoft.SqlServer.Management.Smo.Server($connection) $allDBs= $server.Databases foreach ($db in $alldbs){     if (!($db.tables.Name -contains 'cspCompany')) {"$($db.name) has no CSpCompany"}     }

Generate Random Password with PowerShell

This snippet generates a random password starting with 2 digits or capital letters following by 16 random characters with ASCII codes between 33 and 126 and ending with two random lower case letters (48..57)+(65..90) | Get-Random -Count  2 | % -begin {$PwdStr='';} -process {$PwdStr+=[char]$_} (33..126) | Get-Random -Count 16 | % -process {$PwdStr+=[char]$_}  (97..122) | Get-Random -Count  2 | % -process {$PwdStr+=[char]$_} -end {$PwdStr} Exclude XML escape characters (as well as '\' and '/') from the passwords (33..126) | ? {([int][char]'!',[int][char]'<',[int][char]'>', [int][char]'\',[int][char]'/',[int][char]'"',[int][char]"'", [int][char]'&' ) -notcontains $_} `  | Get-Random -Count 44 | % -begin {$PwdStr=''} -process {$PwdStr+=[char]$_} -end {$pwdStr} Password from a string --> $("!@#$%*_-=+.:;[]{}0123456789abcdefghijklmnopqrstuvwxyzABCDEFGH...

T-SQL to get Azure SQL Database Edition and Service Objective

SELECT  @@VERSION        AS AzureVersion , DATABASEPROPERTYEX(DB_NAME(), 'Edition')      AS AzureEdition , COALESCE(DATABASEPROPERTYEX(DB_NAME(), 'ServiceObjective'), 'N/A in v11') AS AzureTier Returns: Microsoft SQL Azure (RTM) - 12.0.2000.8   Feb  8 2017 04:15:27   Copyright (C) 2016 Microsoft Corporation. All rights reserved. Premium  P1