Skip to content

Instantly share code, notes, and snippets.

View Matticusau's full-sized avatar

Matt Lavery Matticusau

View GitHub Profile
@Matticusau
Matticusau / FiscalCalendar.dax
Created July 1, 2020 22:58
A DAX query to add a fiscal calendar to your PowerBI dataset.
Fiscal Calendar =
// based on https://guyinacube.com/2018/02/13/power-bi-date-table-create-using-dax/
VAR BaseCalendar = CALENDAR("01/01/2010", "01/01/2025")
RETURN
GENERATE(
BaseCalendar,
VAR BaseDate = [Date]
VAR YearDate = Year(BaseDate)
VAR MonthNumber = MONTH(BaseDate)
VAR FiscalYearLong = IF (MonthNumber <= 6, INT(FORMAT(BaseDate, "yyyy")), INT(FORMAT(BaseDate, "yyyy")) + 1)
@Matticusau
Matticusau / get-sqldemos.ps1
Created June 13, 2018 03:27
Clone and extract Sql Server Samples for demos
# clone the repo
git clone -n https://github.com/Microsoft/sql-server-samples .\sql-server-samples
# check out the repo so you can use the demo files
cd sql-server-samples
git config core.sparsecheckout true
echo samples/features/* | out-file -append -encoding ascii .git/info/sparse-checkout
echo samples/demos/*| out-file -append -encoding ascii .git/info/sparse-checkout
git checkout
@Matticusau
Matticusau / SqlVersionsApi-HealthCheckScript-Example.ps1
Last active June 8, 2018 14:29
Example SQL Health Check script for querying the SQL Versions API for life cycle support information
# Example script for using the SQL Versions API to check the life cycle and support information of a particular SQL Version
# Further information here -> http://blog.matticus.net/2018/06/new-sql-version-life-cycle-tool.html
# Live data example of a single instance
# Import the SQL Module
# NOTE: In July 2016 a new module was released therefore there are two methods of this now
# https://blogs.technet.microsoft.com/dataplatforminsider/2016/06/30/sql-powershell-july-2016-update/
# Method 1: Module as part of SQL Setup.exe
@Matticusau
Matticusau / choco-setup-windows-tools.ps1
Last active April 20, 2018 07:16
Chocolatey install script for my common packages on Windows Server
<#
Author: Matt Lavery
Date: 12/04/2018
Purpose: Provides a script to install Chocolatey and my common packages for Windows Servers
Major Version: 0.1.0
Disclaimer: This script is provided "AS IS".
History
When Version Who What
-----------------------------------------------------------------
@Matticusau
Matticusau / ConvertPPTtoPDF.ps1
Created October 9, 2017 03:46
Convert PPTX(s) to PDF
# adapted from https://gist.github.com/ap0llo/05cef76e3c4040ee924c4cfeef3f0b40
# Powershell script to export Powerpoint Presentations to pdf using the Powerpoint COM API
# Based on a VB script with the same purpose
# http://superuser.com/questions/641471/how-can-i-automatically-convert-powerpoint-to-pdf
function Export-Presentation
{
@Matticusau
Matticusau / ConvertTo-Markdown.ps1
Last active February 9, 2022 15:25 — forked from BenNeise/ConvertTo-Markdown.ps1
ConvertTo-Markdown
<#
.Synopsis
Converts a PowerShell object to a Markdown table.
.EXAMPLE
$data | ConvertTo-Markdown
.EXAMPLE
ConvertTo-Markdown($data)
.EXAMPLE
Invoke-ScriptAnalyzer -Path C:\MyScript.ps1 | Select-Object -Property RuleName,Line,Severity,Message | `
ConvertTo-Markdown | Out-File C:\MyScript.ps1.md
@Matticusau
Matticusau / FindFilesWithRegEx.ps1
Created May 8, 2017 06:44
Find files with contents matching a RegEx pattern
$searchPath = (Get-Location).Path;
$searchRegEx = 'find this text'
Get-ChildItem -Path $searchPath -Recurse -File | % {if ((Get-Content -Path $PSItem.FullName | Out-String) -match $searchRegEx) {Write-Host $PsItem.FullName -ForegroundColor Red} else {Write-Host $PsItem.FullName -ForegroundColor green}}
@Matticusau
Matticusau / README-Template.md
Last active March 21, 2017 01:20
A README.md template that I use for my repositories to simplify development environment setup

ProjectName

A description of the project

System Requirements

  • WMF (PowerShell) 5.0
  • Windows Server 2012 R2, Windows 10 or greater

Required PowerShell Modules

The following PowerShell modules.