Skip to content

Instantly share code, notes, and snippets.

View Dalmirog-zz's full-sized avatar

Dalmiro Granas Dalmirog-zz

View GitHub Profile
@Dalmirog-zz
Dalmirog-zz / GetEnabledTentacles.ps1
Last active October 6, 2016 19:34
GetEnabledTentacles
$OctopusAPIkey = ""#Octopus API Key
$OctopusURL = ""#Octopus Server URL
$header = @{ "X-Octopus-ApiKey" = $octopusAPIKey }
(Invoke-WebRequest $OctopusURL/api/machines/all -Headers $header).content | ConvertFrom-Json | ?{$_.isdisabled -eq $true}
@Dalmirog-zz
Dalmirog-zz / script.ps1
Last active November 28, 2016 13:51
Set App Pool Managed Pipeline Mode
$AppPoolName = "" #Name of your app pool
$Mode = "" #For "Integrated" set this value to "0" and for "Classic" set it to "1"
Import-Module WebAdministration
Get-ChildItem IIS:\AppPools | ?{$_.Name -eq $AppPoolName} | Select-Object -ExpandProperty PSPath | %{ Set-ItemProperty $_ managedPipelineMode $mode -Verbose}
@Dalmirog-zz
Dalmirog-zz / GetOctopusMachineOutputExample
Created September 22, 2016 14:54
GetOctopusMachineOutputExample
Name : NY-Tentacle2
ID : Machines-541
Thumbprint : 1F8BA8ABBCD253940D33DD26E4B803622371F21B
URI : https://ny-tentacle1:10934/
IsDisabled : False
EnvironmentName : {Staging}
Roles : {WebServer}
HasLatestCalamari : False
CommunicationStyle : Listening
Status : CalamariNeedsUpgrade
@Dalmirog-zz
Dalmirog-zz / ChannelExample.json
Created September 21, 2016 18:34
ChannelExample
{
"Id": "Channels-221",
"Name": "App 1 Channel",
"Description": null,
"ProjectId": "Projects-128",
"LifecycleId": null,
"IsDefault": true,
"Rules": [
{
"Id": "ba895979-5b6f-4a43-a3f6-ee8375ad40a9",
@Dalmirog-zz
Dalmirog-zz / ProjectExample.json
Created September 21, 2016 18:32
ProjectExample
[
{
"Id": "Projects-821",
"VariableSetId": "variableset-Projects-821",
"DeploymentProcessId": "deploymentprocess-Projects-821",
"IncludedLibraryVariableSetIds": [],
"DefaultToSkipIfAlreadyInstalled": false,
"TenantedDeploymentMode": "Untenanted",
"VersioningStrategy": {
"DonorPackageStepId": null,

SCE 2

Release 1.4.1 (2016/06/24)
NEW FEATURES:
* None

BBDD CHANGES:
* Not needed

OCTOPUS CHANGES:
@Dalmirog-zz
Dalmirog-zz / getmachinenamesbyrole.ps1
Last active September 6, 2016 15:23
get machine names using the roles of the current step
<#
This script should run from:
- A script step
- That's executed on the Octopus Server
- With a Window size of 1
It'll create an output variable called "MachineNames" Which will have the names of the machines (in octopus, so not the same as $env:computername).
To learn more about the usage of output variables read http://octopusdeploy.com/blog/fun-with-output-variables
@Dalmirog-zz
Dalmirog-zz / GetMachineInRolesNames.ps1
Created August 25, 2016 19:10
Get names of machines in role
##CONFIG##
$Role = "" #Role you want to look for
$OctopusAPIkey = "" #API Key for the API calls to get the machine names. Recommended to use a Sensitive Project variable for this.
##PROCESS##
$OctopusURL = $OctopusParameters['Octopus.Web.BaseUrl']
$header = @{ "X-Octopus-ApiKey" = $octopusAPIKey }
$MachineIDs = ($OctopusParameters["Octopus.Environment.MachinesInRole[$Role]"]).Split(',')
if not exists (select column_name from INFORMATION_SCHEMA.columns where TABLE_SCHEMA = 'dbo' and table_name = 'Deployment' and column_name = 'ChannelId')
BEGIN
ALTER TABLE dbo.Deployment ADD ChannelId nvarchar(50) NULL
END
GO
-- Update column from json blob. Try to extract rather than joining on Release since it may have changed.
UPDATE dbo.Deployment
SET ChannelId = c.Id
FROM dbo.Deployment d INNER JOIN dbo.Channel c ON d.[JSON] LIKE '%"ChannelID":"' + c.Id + '"%'
/*
Glossary:
- "Octopus user": A user created by the Octopus server. This user can be created when the Octopus server is in either "User/Password" or "Active Directory" authentication method. These users can be found in the table "Users"
- "AD User": An active directory user. This is the one sitting on the AD domain database
- "UserPass User": An Octopus user created when a user logs in while the Octopus Server is in User/Password authentication method.
When an "AD User" or a "UserPass User" log into the web portal for the first time, Octopus creates an "Octopus User" for them on the database. This user will have its own ID, which will grant him access to the teams. You can see this on the "Team" table on the column "MemberuserIds"
The goal of this script is to help users map an "Octopus user" to another "Octopus user". Both could have been created based on an "AD user" or as a "UserPass User"