Skip to content

Instantly share code, notes, and snippets.

Dalmiro Granas Dalmirog

Block or report user

Report or block Dalmirog

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View resetIISBindings.ps1
$OctopusAPIkey = "" #Octopus API Key
$OctopusURL = "" #Octopus root url
$projectName = ""
$goodBinding = '[{"protocol":"http","port":"80","host":"","thumbprint":null,"certificateVariable":null,"requireSni":false,"enabled":true}]'
$badBinding = '[]'
View createLibraryVariableSetWithVariables.ps1
$MyLibrarySet = "MyVariableSet"
#Create an instance of a Library Set Object
$libraryVariableSet = Get-OctopusResourceModel -Resource LibraryVariableSet
#Add mandatory properties to the object
$libraryVariableSet.Name = $MyLibrarySet
#Create the Library Set
New-OctopusResource -Resource $libraryVariableSet
View PushFilesFromFolder.ps1
$OctoExe = "" #FULL path of the Octo.exe executable (i.e. c:\tools\octo.exe)
$OutputFolder = "" #Output folder where all packages are dropped
$BuildID = "" #<-- This should be the build ID variable that comes from Jenkins
$OctopusServer = "" #Octopus Server base URL
$OctopusAPIKey = ""#Octopus API Key
$FilterPattern = "*$BuildID.nupkg"
Dalmirog / file.ps1
Created Dec 6, 2016
Get nuget package on Tentacle with clean name and do something with it
View file.ps1
$OctopusPackage = get-item $OctopusParameters['Octopus.Tentacle.CurrentDeployment.PackageFilePath']
#Octopus adds a GUID to the package name when it drops them on disk (i.e MyPackage.20160309.10.nupkg-e9ba4f11-9303-485f-8abc-6ea6c3776588), so you need to get your hands a bit dirty to clean it up:
#Dir where the package with the clean name will be dropped
$CopyDir = "C:\TempPackages"
If(!(Test-Path $CopyDir)){
New-Item $CopyDir -ItemType Directory -verbose
  • 1 Project
  • 2 Lifecycles
    • Lifecycle one can be called "Dev Only" and should only contain the "Dev" environment.
    • Lifecycle 2 "Default Lifecycle" should contain the rest of the environments.
  • 2 Channels
    • Channel "Dev Only" Will use the "Dev Only" lifecycle and will have a rule that will only deploy packages with the unstable tag
    • Channel "Default" will use "Default Lifecycle" and will have a rule to make it only deploy packages without tags.

You can read more about Channels configurations here: You'll particularly want to pay attention to the Versioning Rules section:

Dalmirog / setMaintenanceModeOffFromDB.sql
Created Nov 9, 2016
Turn off maintenance mode from DB
View setMaintenanceModeOffFromDB.sql
UPDATE [dbo].[Configuration]
SET [JSON] = '{"IsInMaintenanceMode":false}'
WHERE ID = 'maintenance'
SELECT * FROM [dbo].[Configuration]
Dalmirog / email.html
Created Nov 1, 2016
Octopus email with log link for failed steps
View email.html
<style type="text/css">
font-family: 'Segoe UI';
font-size: 14px;
.bold {
font-weight: bold;
Dalmirog / CheckHealthSkippingDrives.ps1
Last active Nov 2, 2016
Checks Tentacle's health but skipping a few drives
View CheckHealthSkippingDrives.ps1
$freeDiskSpaceThreshold = 5GB
$skipdrives = ("D:")
Try {
Get-WmiObject win32_LogicalDisk -ErrorAction Stop | ? { ($_.DriveType -eq 3) -and ($_.FreeSpace -ne $null) -and ($SkipDrives -notcontains $_.DeviceID)} | % { CheckDriveCapacity @{Name =$_.DeviceId; FreeSpace=$_.FreeSpace} }
} Catch [System.Runtime.InteropServices.COMException] {
Get-WmiObject win32_Volume | ? { ($_.DriveType -eq 3) -and ($_.FreeSpace -ne $null) -and ($_.DriveLetter -ne $null) -and ($SkipDrives -notcontains $_.driveletter) } | % { CheckDriveCapacity @{Name =$_.DriveLetter; FreeSpace=$_.FreeSpace} }
Get-WmiObject Win32_MappedLogicalDisk | ? { ($_.FreeSpace -ne $null) -and ($_.DeviceId -ne $null)} | % { CheckDriveCapacity @{Name =$_.DeviceId; FreeSpace=$_.FreeSpace} }
View gist:43b31815d40d812e5803b6459c1745d4
View GetPackagesFolder.ps1
Function Get-PackagesLocalFolder {
$OctopusHomeDirectory = (Get-item (Get-ItemProperty HKLM:\SOFTWARE\Octopus\OctopusServer\OctopusServer).configurationFilepath).Directory
return "$OctopusHomeDirectory\Packages"
You can’t perform that action at this time.