Skip to content

Instantly share code, notes, and snippets.

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

Mike Pfeiffer mikepfeiffer

🏠
Working from home
View GitHub Profile
@mikepfeiffer
mikepfeiffer / newVM.sh
Created March 8, 2020 18:09
Quick Azure CLI script to create a Windows VM
#!/bin/bash
az group create --name WebServers --location westus2
az vm create \
--resource-group WebServers \
--name WEB1 \
--image win2016datacenter \
--admin-username sysadmin \
--size Standard_DS2_v2
@mikepfeiffer
mikepfeiffer / utils.ps1
Last active November 13, 2022 21:45
PS Function that creates an Azure Service Principal
function New-Sp {
param($Name, $Password)
$spParams = @{
StartDate = Get-Date
EndDate = Get-Date -Year 2030
Password = $Password
}
$cred= New-Object Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential -Property $spParams
@mikepfeiffer
mikepfeiffer / IIS.ps1
Created March 8, 2020 17:56
Simple DSC Configuration for IIS Web Server
Configuration IIS
{
# This will generate three .mof files; web1.mof, web2.mof, web3.mof
Node ('web1', 'web2', 'web3')
{
#ensure IIS is installed
WindowsFeature IIS
{
Name = 'web-server'
Ensure = 'Present'
#!/bin/bash
az group create --name MySonarServer --location westus2
az container create -g MySonarServer \
--name sonarqubeaci \
--image sonarqube \
--ports 9000 \
--dns-name-label cssonar \
--cpu 2 --memory 3.5
#!/bin/bash
az group create --name cs-aks-prod-rg --location westus2
az aks create \
--resource-group cs-aks-prod-rg \
--name cs-prod \
--node-count 1 \
--generate-ssh-keys
# set or increment the ForceUpdateTag using a string value
$PropertiesObject = @{
ForceUpdateTag = 3;
}
# update the extention on an existing VM
Set-AzureRmResource -PropertyObject $PropertiesObject `
-ResourceGroupName DemoVM `
-ResourceType Microsoft.Compute/virtualMachines/extensions `
-ResourceName DemoVM/CustomScriptExtension `
@mikepfeiffer
mikepfeiffer / Program.cs
Created October 27, 2019 06:19
Service Bus Console App .NET Core Sample
using Microsoft.Azure.ServiceBus;
using System;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace SBQuickStart
{
class Program
{
@mikepfeiffer
mikepfeiffer / CreateAKSCluster.sh
Created October 27, 2019 05:04
CreateAKSCluster.sh
#Create a resource group for the serivces we're going to create
az group create --name "AKS-Demo" --location westeurope
az group show --name "AKS-Demo"
#Get a list of the versions available
az aks get-versions --location westeurope -o table
#Check out some of the options available to us when creating our managed cluster
az aks create -h | more
@mikepfeiffer
mikepfeiffer / DemoModule.psm1
Created September 18, 2019 18:16
Demo that shows how to use a utility function inside a PS Module
#private function
function new-baseEncode ($pat) {
$encoded = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes((":{0}" -f $pat)))
Write-Output $encoded
}
#public function
function New-EncodedMessage ($name, $data) {
$encoded = new-baseEncode $data
@mikepfeiffer
mikepfeiffer / ProtectedPage.cshtml.cs
Created September 6, 2019 15:31
Query email address from claims after sign in - ASP.NET Core Razor Pages
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Security.Claims;
namespace CloudSkills.Pages