Skip to content

Instantly share code, notes, and snippets.

View matt40k's full-sized avatar

Matt Smith matt40k

View GitHub Profile
@matt40k
matt40k / Get-LocalAdmins.ps1
Last active February 5, 2025 13:05
Get the members of the Local Administrators group
Function Get-LocalGroupMembers
{
param(
[Parameter(ValuefromPipeline=$true)][array]$server = $env:computername,
$GroupName = $null
)
PROCESS {
$finalresult = @()
$computer = [ADSI]"WinNT://$server"
@matt40k
matt40k / googlepbi.ps1
Created March 23, 2021 23:03
Simple PowerShell script to use the Google Search API to search for public Power BI reports
$apikey = ""
$baseUri = "https://www.googleapis.com/customsearch/v1"
$cx = ""
$query = "site:https://app.powerbi.com"
function GetSearchResults([string]$start)
{
$uri = "$($baseUri)?key=$($apikey)&cx=$($cx)&q=$($query)&start=$($start)"
$c = Invoke-WebRequest -Uri $uri -UseBasicParsing -Method Get
@matt40k
matt40k / Enable_CDC_On_All_Tables.sql
Created September 25, 2015 10:15
Enable CDC on all tables - Author: Rasmus Reinholdt Nielsen
USE [master]
GO
ALTER DATABASE [{{DATABASE-NAME}}]
ADD FILEGROUP CDC;
GO
ALTER DATABASE [{{DATABASE-NAME}}] ADD FILE
( NAME = N'{{DATABASE-NAME}}_CDC'
, FILENAME = N'{{SQL-DATA}}\MSSQL\DATA\{{DATABASE-NAME}}_cdc.MDF'
@matt40k
matt40k / Template.biml
Last active July 31, 2023 11:46
BIML Template for creating SSIS packages
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<#=CallBimlScript("Connections.biml")#>
<Packages>
<Package Name="{{PACKAGE-NAME}}" ProtectionLevel="DontSaveSensitive" ConstraintMode="Linear">
<Annotations>
<Annotation AnnotationType ="Description">{{PACKAGE-NAME}}</Annotation>
</Annotations>
<Connections>
<!-- BI connections -->
<Connection ConnectionName="Staging"/>
@matt40k
matt40k / 40k.md
Created June 10, 2023 21:11
Warhammer 40,000 10th edition notes
Name Description
Critical Hit Unmodified 6 to hit
Critical Wound Unmodified 6 to wound

Shooting

Name Description
Heavy +1 to hit if remained stationary
@matt40k
matt40k / email.csv
Created April 2, 2023 21:03
Common user mistakes entering email addresses
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
gmai.com|gmail.com
gmail.colm|gmail.com
gmail.coml.com|gmail.com
gmail.on|gmail.com
gmal.com|gmail.com
goglemail.com|googlemail.com
homail.com|hotmail.com
htmail.com|hotmail.com
@matt40k
matt40k / mergeCSVFiles.ps1
Created November 17, 2016 18:58 — forked from conrjac/mergeCSVFiles.ps1
Powershell Script to merge multiple CSV files into one (by appending each file to the end)
$folder = 'C:\Data' #INPUT FOLDER PATH - e.g C:\Data
$files = Get-ChildItem $folder\*.csv -Exclude $folder\MergedCsvFile.csv
Get-Content $files | Set-Content $folder\MergedCsvFile.csv
@matt40k
matt40k / GetGeoJSON.sql
Created November 29, 2015 20:57
Turns SQL Server Geography to GeoJSON
CREATE FUNCTION GetGeoJSON (@geo geography)
RETURNS varchar(max)
WITH SCHEMABINDING
/*
* Reference: http://stackoverflow.com/questions/6506720/reformat-sqlgeography-polygons-to-json
*/
AS
BEGIN
DECLARE @Result varchar(max)
SELECT @Result = '{' +
@matt40k
matt40k / CloudFlareDNSLookupApi.ps1
Last active November 23, 2022 10:28
Uses DNS over HTTPS endpoint to lookup A records - PowerShell
$domain = 'cloudflare.com'
$url = 'https://cloudflare-dns.com/dns-query?name='+$domain+'&type=A';
$header = @{"accept"="application/dns-json"}
$response = (Invoke-WebRequest -Uri $url -Headers $header -UseBasicParsing).Content
$r = [System.Text.Encoding]::UTF8.GetString($response) | ConvertFrom-Json
$r
foreach ($item in $r.Answer)
{
Write-Host $item
@matt40k
matt40k / reset_sysman
Created May 28, 2015 14:00
Reset SIMS \ FMS sysman password
exec sims.db_p_reset_sysman_password