Skip to content

Instantly share code, notes, and snippets.

View RichardSlater's full-sized avatar
🏠
Working from home

Richard Slater RichardSlater

🏠
Working from home
View GitHub Profile
@RichardSlater
RichardSlater / Initialize-SharedAssemblyInfo.ps1
Last active February 10, 2019 09:31
Initialize-SharedAssemblyInfo
function Initialize-SharedAssemblyInfo {
Param(
[Parameter(Mandatory=$False)]
[Switch]$RemoveComments = $False
)
process {
$crlf = [System.Environment]::NewLine;
$current = $PSScriptRoot;
while ((-Not (Test-Path "$current\Solutions")) -Or ($current.Length -lt 4)) {
@RichardSlater
RichardSlater / X509CertificateRepository.cs
Created March 5, 2014 22:01
X.509 Certificate Repository
public class X509CertificateRepository {
public IEnumerable<X509Certificate2> FindBySubjectName(StoreName storeName, StoreLocation storeLocation, string subject) {
  var store = new X509Store(storeName, storeLocation);
  store.Open(OpenFlags.ReadOnly);
  var certificates = store.Certificates.Find(X509FindType.FindBySubjectName, subject, validOnly: false);
  foreach (var certificate in certificates) {
   yield return certificate;
  }
  store.Close();
}
@RichardSlater
RichardSlater / aws-datacenter-ip-ranges.xml
Created January 31, 2014 10:46
All AWS IP address ranges
<!-- AWS Region: US East (Northern Virginia) -->
<add ipAddress="72.44.32.0" subnetMask="255.255.224.0" allowed="true" />
<add ipAddress="67.202.0.0" subnetMask="255.255.192.0" allowed="true" />
<add ipAddress="75.101.128.0" subnetMask="255.255.128.0" allowed="true" />
<add ipAddress="174.129.0.0" subnetMask="255.255.0.0" allowed="true" />
<add ipAddress="204.236.192.0" subnetMask="255.255.192.0" allowed="true" />
<add ipAddress="184.73.0.0" subnetMask="255.255.0.0" allowed="true" />
<add ipAddress="184.72.128.0" subnetMask="255.255.128.0" allowed="true" />
<add ipAddress="184.72.64.0" subnetMask="255.255.192.0" allowed="true" />
<add ipAddress="50.16.0.0" subnetMask="255.254.0.0" allowed="true" />
@RichardSlater
RichardSlater / azure-datacenter-ip-ranges.xml
Created January 30, 2014 16:53
All Azure IP address ranges from all regions.
<!-- Azure Region: europewest -->
<add ipAddress="157.55.9.112" subnetMask="255.255.255.240" allowed="true" />
<add ipAddress="157.55.12.0" subnetMask="255.255.255.240" allowed="true" />
<add ipAddress="157.55.10.0" subnetMask="255.255.255.224" allowed="true" />
<add ipAddress="157.55.10.32" subnetMask="255.255.255.224" allowed="true" />
<add ipAddress="157.55.10.64" subnetMask="255.255.255.192" allowed="true" />
<add ipAddress="65.52.128.0" subnetMask="255.255.224.0" allowed="true" />
<add ipAddress="94.245.97.0" subnetMask="255.255.255.0" allowed="true" />
<add ipAddress="137.116.192.0" subnetMask="255.255.224.0" allowed="true" />
<add ipAddress="157.55.8.64" subnetMask="255.255.255.192" allowed="true" />
@RichardSlater
RichardSlater / JsonExtractionRule.cs
Created January 28, 2014 15:31
Visual Studio Test Tools JSON Extraction Rule using JSON.net
using System;
using System.ComponentModel;
using System.Globalization;
using Microsoft.VisualStudio.TestTools.WebTesting;
using Newtonsoft.Json.Linq;
namespace Amido.PerformanceTests.Common {
[DisplayName("JSON Extraction Rule")]
[Description("Extracts the specified JSON value from an object.")]
public class JsonExtractionRule : ExtractionRule {
@RichardSlater
RichardSlater / MongoDB.ps1
Created January 16, 2014 17:37
Desired State Configuration to Install MongoDB on Windows Server 2013
configuration MongoDB {
param (
[string[]]$ComputerName = $env:ComputerName
)
node $ComputerName {
File SetupFolder {
Type = 'Directory'
DestinationPath = "C:\setup"
Ensure = 'Present'
}
@RichardSlater
RichardSlater / Get-AzureRemoteDesktopFileFromSubscription.ps1
Created May 30, 2013 15:28
Download RDP Files from All Instances
Get-AzureService |
Get-AzureRole -Slot Production -InstanceDetails |
ForEach-Object {
Get-AzureRemoteDesktopFile `
-Name $_.InstanceName `
-ServiceName $_.ServiceName `
-LocalPath (Join-Path "C:\RDP" ($_.InstanceName + ".rdp"))
}
@RichardSlater
RichardSlater / Set-AzureMinimumInstanceCount.ps1
Created April 25, 2013 15:27
Set's all Web and Worker roles in a subscription to a single instance.
$deployments = Get-AzureService |
Select-Object ServiceName |
Get-AzureDeployment
$instances = $deployments |
Select-Object ServiceName,Slot -ExpandProperty RoleInstanceList
$instances |
Select-Object ServiceName,Slot,RoleName |
Group-Object RoleName,ServiceName,Slot -NoElement |
Where-Object {$_.Count -gt 1} |
Select-Object Count,@{Name="RoleName"; Expression={$_.Name.Split(',')[0].Trim()}},@{Name="ServiceName";Expression={$_.Name.Split(',')[1].Trim()}},@{Name="Slot";Expression={$_.Name.Split(',')[2].Trim()}} |
@RichardSlater
RichardSlater / Configure-CapacityMetrics.ps1
Created February 11, 2013 11:03
Retrieve the latest storage capacity metrics for multiple storage accounts and display in a range of units.
# *************************************************************************************************
# * Configure-CapacityMetrics *
# *************************************************************************************************
# * Description: Configures Capacity metrics *
# * Author: Richard Slater <richard.slater@amido.co.uk> *
# * Date: 2013.02.02 *
# * Prerequisites: WAPPSCmdlets (https://www.windowsazure.com/en-us/manage/downloads/) *
# *************************************************************************************************
Set-StorageServicePropertiesForAnalytics -ServiceName "Blob" -StorageAccountName "<Storage Account Name>" -StorageAccountKey "<Storage Account Key>" -MetricsEnabled -MetricsRetentionPolicyDays 7 -MetricsRetentionPolicyEnabl
@RichardSlater
RichardSlater / FindAndReplaceInAzureBlob.cs
Created November 24, 2012 16:42
Find any string and replace with any other string in an Azure Table Storage Blob
var accountName = Properties.Settings.Default.StorageAccountName;
var accountKey = Properties.Settings.Default.AccessKey;
var containerName = Properties.Settings.Default.ContainerName;
var blobName = Properties.Settings.Default.Blob;
var credentials = new StorageCredentials(accountName, accountKey);
var account = new CloudStorageAccount(credentials, useHttps: true);
var client = account.CreateCloudBlobClient();
var container = client.GetContainerReference(containerName);