Skip to content

Instantly share code, notes, and snippets.

View MJRichardson's full-sized avatar

Michael Richardson MJRichardson

  • Brisbane, Australia
View GitHub Profile
@MJRichardson
MJRichardson / octopus-lets-encrypt-cloudflare.ps1
Last active June 15, 2020 07:06
An example of what the DNS challenge script in the Octopus Let's Encrypt step might look like for Cloudflare as the DNS provider
# The following was based on the Cloudflare DNS plugin from Posh-Acme:
# https://github.com/rmbolger/Posh-ACME/blob/master/Posh-ACME/DnsPlugins/Cloudflare.ps1
function Add-DnsTxtCloudflare {
[CmdletBinding(DefaultParameterSetName='Email')]
param(
[Parameter(Mandatory,Position=0)]
[string]$RecordName,
[Parameter(Mandatory,Position=1)]
[string]$TxtValue,
@MJRichardson
MJRichardson / octopus-set-azure-web-app-ssl-certificate.ps1
Created March 29, 2018 00:47
Octopus - Set Azure Web App SSL Certificate
<#
Takes an Octopus certificate variable and
1) Writes it to a temporary file with a password (as Azure requires the PFX have a password)
2) Invokes New-AzureRmWebAppSSLBinding
3) Removes the temporary certificate file
#>
$ErrorActionPreference = 'Stop'
Write-Verbose "Creating temporary certificate file"
@MJRichardson
MJRichardson / approver-is-not-deployer.ps1
Created March 27, 2018 23:30
Octopus Deploy - Prevent deployer from approving intervention
$ApprovalStepName = "Approve Deployment"
$Deployer = $OctopusParameters["Octopus.Deployment.CreatedBy.Username"]
$Approver = $OctopusParameters["Octopus.Action[$ApprovalStepName].Output.Manual.ResponsibleUser.Username"]
Write-Host "Deployment created by $Deployer"
Write-Host "Deployment approved by $Approver"
if ($Deployer -eq $Approver) {
Fail-Step "Approval cannot be given by the person performing the deployment"
}
@MJRichardson
MJRichardson / ActiveDirectoryMembership.cs
Created January 18, 2016 00:55
Octopus Deploy Active Directory Membership
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.DirectoryServices.AccountManagement;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Principal;
using Octopus.Core.Model.Events;
using Octopus.Core.Model.Users;
using Octopus.Core.RelationalStorage;