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 April 27, 2024 10:45
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 / 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
@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 / wahapediaDownload.ps1
Created April 24, 2022 19:40
Download the Wahapedia CSV exports
$baseUri = "http://wahapedia.ru/wh40k9ed/"
$r = (Invoke-WebRequest -Uri "$($baseUri)Last_update.csv" -UseBasicParsing).Content | ConvertFrom-Csv -Delimiter "|" -Header "last_update" | Select-Object -Skip 1
$lastUpdated = $r.last_update
$factions = (Invoke-WebRequest -Uri "$($baseUri)Factions.csv" -UseBasicParsing).Content | ConvertFrom-Csv -Delimiter "|" -Header "id", "name", "link" | Select-Object -Skip 1
$datasheets = (Invoke-WebRequest -Uri "$($baseUri)Datasheets.csv" -UseBasicParsing).Content | ConvertFrom-Csv -Delimiter "|" -Header "id", "name", "link", "faction_id", "source_id", "role", "unit_composition", "transport", "power_points", "priest", "psyker", "open_play_only", "crusade_only", "virtual", "cost_per_unit", "Cost" | Select-Object -Skip 1
$wargear = (Invoke-WebRequest -Uri "$($baseUri)Wargear_list.csv" -UseBasicParsing).Content | ConvertFrom-Csv -Delimiter "|" -Header "id", "name", "type", "description", "source_id", "is_relic", "faction_id", "legend" | Select-Object -Skip 1
$datasheetWargear =