Skip to content

Instantly share code, notes, and snippets.

@trondhindenes
trondhindenes / ConfigureRubyOnRails.sh
Last active October 22, 2015 15:13
Configure Ruby + Rails
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev -y
sudo apt-get install libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev -y
sudo apt-get install libcurl4-openssl-dev python-software-properties libffi-dev -y
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev -y
#Note that this key may changes
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
#if this command fails, you should get a message containing the correct gpg command to run instead of the above
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {
},
"resources": [
{
"type": "Microsoft.Compute/availabilitySets",
"name": "{{ avset_name }}",
Login-AzureRmAccount -Credential $Creds
$Params = @{"Param1" = "Value1";"Param2" = "Value2"}
$job = Start-AzureRmAutomationRunbook -Name $Name -ResourceGroupName $ResourceGroupName -AutomationAccountName $AutomationAccountName -Parameters @params
Error:
"Start-AzureRmAutomationRunbook : Missing an argument for parameter 'Parameters'. Specify a parameter of type 'System.Collections.I
Dictionary' and try again."
@trondhindenes
trondhindenes / AnsibleModuleWIthAsyncAndAlternateCreds.ps1
Created October 4, 2015 14:23
Example of a module supporting using a scheduled job with support for alternate credentials
#!powershell
# This file is part of Ansible.
#
# Copyright 2015, Trond Hindenes <trond@hindenes.com>
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@trondhindenes
trondhindenes / AnsibleModuleWithAsync.ps1
Created October 4, 2015 13:11
Example module which uses scheduled jobs to invoke
#!powershell
# This file is part of Ansible.
#
# Copyright 2015, Trond Hindenes <trond@hindenes.com>
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@trondhindenes
trondhindenes / ExecuteSelfAsScheduledTask.ps1
Created October 4, 2015 10:43
Script that will execute itself as a scheduled task
Function Exit-Json($obj)
{
# If the provided $obj is undefined, define one to be nice
If (-not $obj.GetType)
{
$obj = New-Object psobject
}
echo $obj | ConvertTo-Json -Compress -Depth 99
Exit
@trondhindenes
trondhindenes / Unzip-file.ps1
Created October 4, 2015 09:51
Unzips file using .net 4.5 with fallback to COM
function Unzip-File {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true,
ValueFromPipeline=$true)]
[ValidateScript({
If ((Test-Path -Path $_ -PathType Leaf) -and ($_ -like "*.zip")) {
$true
}
@trondhindenes
trondhindenes / test-get-AnsibleParam.ps1
Created October 1, 2015 20:21
My test scripts for get-AnsibleParam
Set-StrictMode -Version 2
$params = "" | Select Firstname, Lastname, ensure
$params.Lastname = "Hindenes"
$params.Ensure = "present"
$returnobj = ""
. "D:\trond.hindenes\Documents\Scripts\Ansible\fork\trondhindenes\ansible\lib\ansible\module_utils\powershell.ps1"
#simple - should succeed
Get-AnsibleParam -obj $params -name Firstname
#Use alias
#Release when less than 4 moves are in progress
Function WaitForMoves
{
Do {
$moves = Get-moverequest | Get-moverequeststatistics | where {$_.StatusDetail -ne "COmpleted"}
if (($moves.count) -gt 3)
{
$movescount = $moves.count
Write-Progress -Activity "Moving $movescount" -Status "Moving $movescount" -PercentComplete 100
Start-sleep -seconds 10
@trondhindenes
trondhindenes / downloadurl.txt
Created August 19, 2015 16:27
Windows Server 2016 TP3 download URL
http://care.dlservice.microsoft.com/dl/download/7/3/C/73C250BE-67C4-440B-A69B-D0E8EE77F01C/10514.0.150808-1529.TH2_RELEASE_SERVER_OEMRET_X64FRE_EN-US.ISO