Skip to content

Instantly share code, notes, and snippets.

@MatthewJDavis
MatthewJDavis / New-DomainServicesDNSServer.ps1
Created July 27, 2017 20:40
Update the VNET DNS server settings
# config settings - get DNS Server addresses from the portal under the AAD Domain Services blade
$vnetName = 'northeurope-vnet'
$vnetRg = 'domain-services-rg'
$dnsServer1 = '10.0.0.4'
$dnsServer2 = '10.0.0.5'
$vnet = get-azurermvirtualnetwork -Name $vnetName -ResourceGroupName $vnetRg
# Add the DNS Server values to the VNET var
$vnet.DhcpOptions.DnsServers = $dnsServer1
@MatthewJDavis
MatthewJDavis / DSManagmentServerConfig.Tests.ps1
Created August 1, 2017 19:45
Pester Tests for RSAT install
Describe 'Management VM Config' {
Context 'Management Tools' {
It 'Should have the Remote Server Admin Tools AD feature installed' {
(Get-WindowsFeature -Name RSAT-AD-Tools).installed | Should Be $true
}
It 'Should have the Remote Server Admin Tools AD PowerShell feature installed' {
(Get-WindowsFeature -Name RSAT-AD-PowerShell).installed | Should Be $true
}
It 'Should have the Remote Server Admin Tools DNS feature installed' {
@MatthewJDavis
MatthewJDavis / Stop-MDAzureRmVMByTag.ps1
Last active August 7, 2017 19:49
Stops a VMs with powerOffTime tag in a certain subscription
workflow Stop-MDAzureRMVMByTag {
<#
Stop a VM based on the powerOffTime tag value of the VM and the powerOffTime value of the parameter passed to the script.
The time can be passed through via the schedule of the workbook or the default time of 23:00 will be used.
This runs against a specified subscription passed in via the automation variable 'subscriptionName'
Matt Davis 5th Aug 2017
#>
Param(
[Parameter (Mandatory = $false)]
[String] $powerOffTime = "23:00"
@MatthewJDavis
MatthewJDavis / kitchen.yml
Created August 16, 2017 19:12
Kitchen file with Pester as the verifier
---
driver:
name: ec2
instance_type: t2.micro
retryable_tries: 120
provisioner:
name: chef_zero
verifier:
@MatthewJDavis
MatthewJDavis / Dockerfile
Created August 23, 2017 19:44
Docker file to build a container with AWS module installed
FROM microsoft/powershell
Run powershell -Command Install-Module -Name AWSPowerShell.NetCore -Force
@MatthewJDavis
MatthewJDavis / simple-s3-bucket.yml
Created August 31, 2017 19:59
Simple S3 bucket yaml cloudformation
AWSTemplateFormatVersion: 2010-09-09
Description: Creates an S3 bucket given the owner full control.
Parameters:
BucketName:
Description: Name of the S3 bucket must be globally unique and can contain lowercase characters, numbers and hyphens
Type: String
ProjectTag:
Description: Tag value for the project
Type: String
Resources:
@MatthewJDavis
MatthewJDavis / basic-s3-bucket.yml
Created September 18, 2017 21:15
S3 bucket template
AWSTemplateFormatVersion: 2010-09-09
Description: Creates an S3 bucket giving the owner full control.
Parameters:
BucketName:
Description: Name of the S3 bucket must be globally unique and can contain lowercase characters, numbers and hyphens
Type: String
ProjectTag:
Description: Tag value for the project
Type: String
Resources:
@MatthewJDavis
MatthewJDavis / create-bucket-params.json
Created September 18, 2017 21:16
S3 parameter json file
[
{
"ParameterKey": "BucketName",
"ParameterValue": "matt-vsts-bucket",
"UsePreviousValue": false
},
{
"ParameterKey": "ProjectTag",
"ParameterValue": "vsts",
"UsePreviousValue": false
@MatthewJDavis
MatthewJDavis / ansible-install.sh
Last active March 10, 2018 11:20
Install Ansible ubuntu with PIP
#Distributor ID: Ubuntu
#Description: Ubuntu 14.04.5 LTS
#Release: 14.04
#Codename: trusty
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install python-pip -y
pip install --upgrade pip
sudo pip install markupsafe
<#
Gets the attached volumes of the specified instance and shows the latest snapshots for each volume
#>
# Case sensitive!
$InstanceName = 'AWS-IE-DC-01'
# Create an EC2 filter to find the instance with the corresponding Name tag (if you don't Name your instances, use another tag value)
$instanceFilter = New-Object Amazon.EC2.Model.Filter
$instanceFilter.Name = 'tag:Name'