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 / 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
@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
@mikepfeiffer
mikepfeiffer / gist:53453a98d62991dfdb5da40beb6229d5
Created April 27, 2020 12:08
PowerShell Script to Create Azure Custom RBAC Role
CD $HOME
wget https://gist.github.com/mikepfeiffer/176776a8758b4e2910554a5c33392c12/raw/e48369b8aa73348606e76cbebc603d9e89c56666/customRoleDefinition.json
$subscription_id = (Get-AzContext).Subscription.id
(Get-Content -Path $HOME/customRoleDefinition.json) -Replace 'SUBSCRIPTION_ID', $subscription_id |
Set-Content -Path $HOME/customRoleDefinition.json
New-AzRoleDefinition -InputFile ./customRoleDefinition.json
#!/bin/bash
# Tutorial: Install a LAMP web server on the Amazon Linux AMI
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html
# ensure that all of your software packages are up to date
sudo yum update -y
# install related dependencies
sudo yum install -y httpd24 php72 mysql57-server php72-mysqlnd
@mikepfeiffer
mikepfeiffer / acrTask.sh
Created November 12, 2020 13:09
Create ACR Task to Build Docker Image on GitHub Commit
az acr task create -t node-demo:{{.Run.ID}} -n node-demo -r <acr name> \
-f Dockerfile -c https://github.com/mikepfeiffer/node-docker-demo.git \
--pull-request-trigger-enabled true \
--git-access-token <token>
#!/bin/bash
yum update -y
yum install -y httpd24 php56 mysql php56-mysqlnd
service httpd start
chkconfig httpd on
echo "fs-56fc251e.efs.us-east-1.amazonaws.com:/ /var/www/html nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 0 0" >> /etc/fstab
mount -a
@mikepfeiffer
mikepfeiffer / apache.sh
Last active June 20, 2021 15:35
Setup Apache on Amazon Linux
#!/bin/bash
yum update -y
yum install -y httpd24 php70 mysql php70-mysqlnd
service httpd start
chkconfig httpd on
usermod -a -G apache ec2-user
sudo chown -R ec2-user:apache /var/www
sudo chmod 2775 /var/www
@mikepfeiffer
mikepfeiffer / wordpress.sh
Created April 10, 2018 18:45
Download and Deploy WordPress Application Code for Apache
#!/bin/bash
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
cp -r wordpress/* /var/www/html/