Skip to content

Instantly share code, notes, and snippets.

View fireflycons's full-sized avatar

Alistair Mackay fireflycons

View GitHub Profile
@fireflycons
fireflycons / Install-PowerShellService.ps1
Created November 23, 2018 08:19
Script to install a PowerShell script as a Windows Service using NSSM
<#
.SYNOPSIS
Installs PowerShell scripts as Windows Services.
.DESCRIPTION
Installs or removes PowerShell script services.
When installing, any additional command line arguments besides the mandatory ones are supplied as arguments to the script you are installing, and credentials for the service will be prompted for.
The service will be installed for automatic start, however the initial state is 'Stopped'
This tool will additionally pass the switch -Service to the target script which it should implement to know it is running as a service.
@fireflycons
fireflycons / sql-server-all-enable-dynamic-tcp.ps1
Last active September 6, 2018 04:31 — forked from FeodorFitsner/sql-server-all-enable-dynamic-tcp.ps1
Enable dynamic TCP ports for all SQL Server instances (so they can be run simultaneously)
<#
.SYNOPSIS
Set all installed instances of SQL server to dynamic ports
#>
Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\' |
Where-Object {
$_.Name -imatch 'MSSQL[_\d]+\.SQL.*'
} |
ForEach-Object {
@fireflycons
fireflycons / Get-LatestAMI.ps1
Created February 17, 2018 13:26
Builds an AWS CloudFormation mapping for the latest version of an AMI in all accessible regions.
<#
.SYNOPSIS
Build a CloudFormation mapping for the latest version of an AMI in all accessible regions.
.DESCRIPTION
Given an AMI search filter, the script enumerates all known regions looking for the newest AMI that matches the criteria
Depending on where you are and your account permissions, some regions will not return a value e.g. China and Gov Cloud.
Ensure you have the latest version of AWSPowerShell if AWS has recently added new regions.
.PARAMETER ImageName
@fireflycons
fireflycons / Get-S3ETagForLocalFile.ps1
Created February 9, 2018 09:37
Compute Amazon S3 ETag for a local file
<#
.SYNOPSIS
Compute Amazon S3 ETag for a local file
.DESCRIPTION
ETags represent a hash of the content of a file stored in S3.
Comaparing ETags can be used to determine
- If a file in S3 is the same as one you are going to upload
- Following an upload, whether the file was successfully uploaded.