Skip to content

Instantly share code, notes, and snippets.

View adamrushuk's full-sized avatar

Adam Rush adamrushuk

View GitHub Profile
@adamrushuk
adamrushuk / Get-GuidFromMsiFile.ps1
Last active March 22, 2024 22:59
Getting the Product ID / GUID from MSI file
# Vars
$msiPath = 'C:\Users\arush\Downloads\sqlncli.msi'
# Definition
$sig = @'
[DllImport("msi.dll", CharSet = CharSet.Unicode, PreserveSig = true, SetLastError = true, ExactSpelling = true)]
private static extern UInt32 MsiOpenPackageW(string szPackagePath, out IntPtr hProduct);
[DllImport("msi.dll", CharSet = CharSet.Unicode, PreserveSig = true, SetLastError = true, ExactSpelling = true)]
private static extern uint MsiCloseHandle(IntPtr hAny);
[DllImport("msi.dll", CharSet = CharSet.Unicode, PreserveSig = true, SetLastError = true, ExactSpelling = true)]
@adamrushuk
adamrushuk / Publish-AzDOArtifactFeed.ps1
Created June 20, 2019 20:54
Publish a PowerShell Module to an Internal Azure DevOps Artifacts feed
[CmdletBinding()]
param (
[string]$AzDOAccountName = 'adamrushuk',
[string]$AzDOArtifactFeedName = 'dev',
[string]$AzDOPat,
[string]$ModuleFolderPath = (Join-Path -Path $env:SYSTEM_ARTIFACTSDIRECTORY -ChildPath "PowerShellPipeline\PSModule\PSvCloud")
)
# Variables
$feedUsername = 'NotChecked'
@adamrushuk
adamrushuk / KeePass.ps1
Created March 17, 2019 14:24
KeePass PowerShell examples
#Requires -RunAsAdministrator
# Testing KeePass automation against KeePass v2.39.1
# Vars
$masterKeyCredential = New-Object -TypeName 'PSCredential' -ArgumentList ('KPMasterUser', (ConvertTo-SecureString -String 'Passw0rd123!' -AsPlainText -Force))
$repoPath = 'C:\Code\KeePass\KeePassDB'
$databaseName = 'KeePassDatabase'
$databasePath = Join-Path -Path $repoPath -ChildPath "$databaseName.kdbx"
$databaseProfileName = 'KeePassDatabaseProfile01'
$testGroupName = 'TestAccounts'
@adamrushuk
adamrushuk / expand_k8s_pvc.sh
Created November 2, 2020 08:51
Testing process to expand k8s PVCs without losing data
# Testing process to expand k8s PVCs without losing data
#region Install
# Check the current cluster
kubectl config current-context
# Add bitnami repo
helm repo list
helm repo add bitnami https://charts.bitnami.com/bitnami
@adamrushuk
adamrushuk / deploy_aks_periscope.sh
Created September 26, 2022 08:07
AKS Periscope Kustomize Deployment Script
#!/usr/bin/env bash
# AKS Periscope Kustomize Deployment Script
# This script will do the following:
# - create a SAS token valid for 60 minutes
# - deploy AKS Periscope into your cluster
# - collect and save logs into the storage account specified
# Set some variables for where you want the logs uploaded to:
@adamrushuk
adamrushuk / aks-disk-detach-wait.ps1
Last active September 23, 2022 07:54
AKS Disk Detach Wait Scripts
# get disk for aks to check attachment state during disk expansion
# vars
$subscriptionName = ""
$aksClusterName = ""
$aksClusterResourceGroupName = ""
$pvcName = ""
# login
Connect-AzAccount -UseDeviceAuthentication
@adamrushuk
adamrushuk / 01-Boxstarter.ps1
Last active July 14, 2021 07:01
New Computer Configuration Scripts - run each script in order
# Install Boxstarter and Chocolatey
Set-ExecutionPolicy -ExecutionPolicy "RemoteSigned" -Verbose
. { iwr -useb https://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
# Set Explorer options
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar -DisableOpenFileExplorerToQuickAccess -DisableShowRecentFilesInQuickAccess -DisableShowFrequentFoldersInQuickAccess -DisableExpandToOpenFolder -DisableShowRibbon
# Set Taskbar options
Set-TaskbarOptions -Size Large -Lock -Dock Bottom -Combine Always
@adamrushuk
adamrushuk / Clear-DeletedBranches.ps1
Created May 29, 2021 08:39
Clear deleted git branches
function Clear-DeletedBranches {
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
[Alias("cdb")]
param(
[Parameter(Mandatory = $false)]
[string]
$GitDir = $PWD
)
$defaultBranch = ((git symbolic-ref --short refs/remotes/origin/HEAD) -split "/")[1]
#!/bin/bash
# Installs Ansible AWX
echo "INFO: Started Installing Ansible AWX..."
# Install prereq: Docker SDK for Python
echo "INFO: Started Installing Docker SDK for Python..."
pip install docker
echo "INFO: Finished Installing Docker SDK for Python."
2020/06/25 12:34:07 [INFO] Packer version: 1.6.0 [go1.13.12 linux amd64]
2020/06/25 12:34:07 Checking 'PACKER_CONFIG' for a config file path
2020/06/25 12:34:07 'PACKER_CONFIG' not set; checking the default config file path
2020/06/25 12:34:07 Attempting to open config file: /home/adamr/.packerconfig
2020/06/25 12:34:07 [WARN] Config file doesn't exist: /home/adamr/.packerconfig
2020/06/25 12:34:07 Setting cache directory: /mnt/c/Users/adamr/code/Packer-Templates/azure-test/packer_cache
2020/06/25 12:34:07 Creating plugin client for path: /usr/local/bin/packer
2020/06/25 12:34:07 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-builder-azure-arm"}
2020/06/25 12:34:07 Waiting for RPC address for: /usr/local/bin/packer
2020/06/25 12:34:07 packer-builder-azure-arm plugin: [INFO] Packer version: 1.6.0 [go1.13.12 linux amd64]