Skip to content

Instantly share code, notes, and snippets.

View lmoxiel's full-sized avatar

Christopher Jackson lmoxiel

View GitHub Profile
@lmoxiel
lmoxiel / chmod-400.cmd
Last active July 24, 2020 15:40 — forked from jaskiratr/chmod-400.cmd
Set permission of file equivalent to chmod 400 on Windows.
# Source: https://stackoverflow.com/a/43317244
$path = ".\aws-ec2-key.pem"
# Reset to remove explict permissions
icacls.exe $path /reset
# Give current user explicit read-permission
icacls.exe $path /GRANT:R "$($env:USERNAME):(R)"
# Disable inheritance and remove inherited permissions
icacls.exe $path /inheritance:r
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
name: Sandy_Build_$(date:yyyyMMdd)$(rev:.r)
trigger:
- none
pool:
#name: 'Self-Hosted VS2017' (Self-hosted build agent)
vmImage: 'ubuntu-latest' # (use this for the Microsoft-hosted build agent)
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
name: Hubble_Build_$(date:yyyyMMdd)$(rev:.r)
trigger:
- none
pool:
#name: 'Self-Hosted VS2017' (Self-hosted build agent)
vmImage: 'ubuntu-latest' # (use this for the Microsoft-hosted build agent)
@lmoxiel
lmoxiel / export-certificate-with-password.ps1
Created June 11, 2020 13:46
This code accesses a Key Vault certificate and certificate password and creates a new exported certificate based on a certificate password which is also stored in Key Vault
# Christopher Jackson (@azurejackson; @ethicaljeans)
# May, 2020
#
# This code accesses a Key Vault certificate and certificate password and creates a new
# exported certificate based a certificate password which is also stored in Key Vault
#
# export-certificate-with-password.ps1
Connect-AzAccount
@lmoxiel
lmoxiel / bitcoinfees.ps1
Created January 14, 2018 02:21
BitcoinFees for Azure Functions and Slack Bot Integration
# Christopher Jackson
# Generate a range of Bitcoin Transaction fees based on speed
# 1/7/2018
$satoshi = 0.00000001
$size = 226
$btcprice = 16750
$json = $(Invoke-WebRequest -Uri https://bitcoinfees.earn.com/api/v1/fees/list -UseBasicParsing).Content | ConvertFrom-Json
$fees = $json.fees
@lmoxiel
lmoxiel / New-EncryptedVM.ps1
Last active February 20, 2023 10:47
This PowerShell script creates a new Resource Group where it deploys a new Windows VM, a Keyvault with an AD App and KeyEncryptionKey which is uses to encrypt the VM
# Author: Christopher Jackson <[email protected]>
# 4/5/2017
# New-EncryptedVM.ps1
#
# This PowerShell script creates a new Resource Group where it deploys a new Windows VM, a Keyvault with an AD App and KeyEncryptionKey which is uses to encrypt the VM
# Please login to your Azure Environment before running this script. This script create all new resources
# For more info: https://docs.microsoft.com/en-us/azure/security/azure-security-disk-encryption
$ResourceGroupName = "EncryptRG"
$VMName = "EncryptWin1"
@lmoxiel
lmoxiel / initializeDisk.ps1
Last active April 12, 2017 16:14
After adding a Data Disk, this script Initializes the Disk on a virtual machine
# Christopher Jackson
# March 1, 2017
Get-PhysicalDisk | Where-Object CanPool -eq $true
$PhysicalDisk = Get-PhysicalDisk | Where-Object CanPool -eq $true
New-StoragePool -FriendlyName "StoragePool1" -StorageSubsystemFriendlyName "Storage Spaces*" -PhysicalDisks $PhysicalDisk
$virtualDisk = New-VirtualDisk -StoragePoolFriendlyName "StoragePool1" -UseMaximumSize -ProvisioningType Fixed -ResiliencySettingName "Simple" -FriendlyName "DataDisk"
$virtualDisk | Initialize-Disk -PassThru | New-Partition -AssignDriveLetter -UseMaximumSize | Format-Volume -Force -Confirm:$false
@lmoxiel
lmoxiel / unUsedNetworkResources.ps1
Created March 11, 2017 05:22
These are a few commands you may run one at a time to find unused Network Interfaces and PublicIP Addr
# Christopher Jackson
# Feb 23, 2017
# List all NICs that are not attached to a VM
Get-AzureRmNetworkInterface | where { !$_.VirtualMachine } | Select Name,ResourceGroupName,Primary
# Remove all NICs that are not attached to a VM
Get-AzureRmNetworkInterface | where { -Not $_.VirtualMachine } | Remove-AzureRmNetworkInterface
# Get a list of all Azure PublicIP addresses and the NIC they are associated with.
@lmoxiel
lmoxiel / unUsedStorage.ps1
Created March 11, 2017 05:06
Script used to help track unused storage accounts.
# Christopher Jackson
# 3/10/2017
# This script gives you storage accounts that are not used by a Virtual Machine's OS disk, hinting that perhaps you may want to delete the storage upon closer inspection.
# One could possibly pipe the output to Remove-AzureRmStorageAccount for deletion.
# Warning: Some accounts are diagnostic accounts which could be used by a VM. Also this scripts currently only looks at OS disk storage accounts and not Data disk,
# since it is more likely that data disks reside in the same storage account as OS disks.
 
Function Get-AllVmStorageAccount
{