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 / script.ps1
Last active January 12, 2016 19:07
Script for alan
function GetScriptDirectory
{
Split-Path $script:MyInvocation.MyCommand.Path
}
function GetResultsPath
{
$parent = join-path -path $(GetScriptDirectory) -childpath $OctopusReleaseNumber
return Join-Path -Path $parent -ChildPath "TestResult.html"
}
@Dalmirog-zz
Dalmirog-zz / template.json
Created January 11, 2016 19:32
Stop app pool template
{
"Id": "ActionTemplates-21",
"Name": "IIS AppPool - Stop",
"Description": "Stops an IIS Application Pool",
"ActionType": "Octopus.Script",
"Version": 2,
"Properties": {
"Octopus.Action.Script.ScriptBody": "# Load IIS module:\nImport-Module WebAdministration\n\n# Get AppPool Name\n$appPoolName = $OctopusParameters['appPoolName']\n# Get the number of retries\n$retries = $OctopusParameters['appPoolCheckRetries']\n# Get the number of attempts\n$delay = $OctopusParameters['appPoolCheckDelay']\n\n# Check if exists\nif(Test-Path IIS:\\AppPools\\$appPoolName) {\n\n # Stop App Pool if not already stopped\n if ((Get-WebAppPoolState $appPoolName).Value -ne \"Stopped\") {\n Write-Output \"Stopping IIS app pool $appPoolName\"\n Stop-WebAppPool $appPoolName\n \n $state = (Get-WebAppPoolState $appPoolName).Value\n $counter = 1\n \n # Wait for the app pool to the \"Stopped\" before proceeding\n do{ \n $state = (Get-WebAppPoolState $appPoolN
@Dalmirog-zz
Dalmirog-zz / script.ps1
Last active January 6, 2016 18:35
GetAppPools
Import-Module WebAdministration
Write-Output "Running on $env:COMPUTERNAME"
Get-ChildItem IIS:\AppPools
$PoolName = "YOU_APP_POOL_NAME" <- UPDATE THIS
$pool = Get-Item "IIS:\AppPools\$PoolName"
@Dalmirog-zz
Dalmirog-zz / resultexample.txt
Created December 15, 2015 17:54
Getting Nuget packages of latest deployments
ProjectName EnvironmentName ReleaseVersion packages
----------- --------------- -------------- --------
ConfigFiles Development 0.0.16 {@{Name=TestConfig; Version=2.0.42}}
ConsoleApp Development 0.0.1 {@{Name=Testapp; Version=1.0.13}}
Powershell1 Development 0.0.6 {@{Name=Testapp; Version=1.0.15}}
#Importing IIS module to make the IIS:\ Drive available
Import-Module WebAdministration -ErrorAction SilentlyContinue
#Make sure to put the name of your deploy step name inside the Brackets.
$appPool = "IIS:\\AppPools\" + $OctopusParameters['Octopus.Action[YOURDEPLOYSTEPNAME].IISWebSite.ApplicationPoolName']
#Setting the .NET CLR Runtime of the app pool to "" which is the same as "No Managed Code"
Set-ItemProperty $appPool managedRuntimeVersion "" -verbose
$ServiceConfigFileName = "ServiceConfiguration.Cloud.cscfg"
$CscfgFile = Get-Item $ServiceConfigFileName
If (Test-Path $CscfgFile){
Write-Output "File $ServiceConfigFileName was found on $($cscfgfile.FullName)"
}
else{
Write-Error "File $ServiceConfigFileName was not found"
}
@Dalmirog-zz
Dalmirog-zz / GetMachines.ps1
Created November 16, 2015 18:42
GetAllMachinesFromDeployment
$APIKey = "" <-#API Key to authenticate to your Octopus server. This is the only parameter you must fill manually.
function GetMachines([string]$APIKey){
$OctopusURL = $OctopusParameters["Octopus.web.baseurl"]
$IDs = $OctopusParameters["Octopus.Deployment.Machines"]
$MachineIds = $IDS.Split(",")
function Get-FromOctopus([string]$relUrl) {
$uri = "$OctopusUrl$relUrl`?apiKey=$ApiKey"
$usernameToFind = "DOMAIN\USERNAME"
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$contextType = [System.DirectoryServices.AccountManagement.ContextType]::Domain
$context = New-Object System.DirectoryServices.AccountManagement.PrincipalContext -argumentlist ($contextType)
$user = [System.DirectoryServices.AccountManagement.UserPrincipal]::FindByIdentity($context, $usernameToFind)
Write-Output $user
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true,Position=1)]
[string]$OctopusUrl = "http://localhost:80",
[Parameter(Mandatory=$true,Position=2)]
[string]$ApiKey,
[Parameter(Mandatory=$false,Position=3)]
[switch]$Delete
@Dalmirog-zz
Dalmirog-zz / process.json
Created October 23, 2015 00:10
example deployment process
{
"Id": "deploymentprocess-Projects-2",
"ProjectId": "Projects-2",
"Steps": [
{
"Id": "cfd737a4-ad3d-4702-b841-a88f9f2c5271",
"Name": "Script",
"RequiresPackagesToBeAcquired": false,
"Properties": {
"Octopus.Action.TargetRoles": "webserver"