Skip to content

Instantly share code, notes, and snippets.

@jrotello
jrotello / Export-PfxCertificateFromKeyVault.ps1
Created September 8, 2021 18:33
Export a PFX (certificate and key) from Azure Key Vault
function Export-PfxCertificateFromKeyVault {
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]$KeyVaultName,
[Parameter(Mandatory)]
[string]$Name,
[Parameter(Mandatory)]
@jrotello
jrotello / Get-Hash.ps1
Last active April 2, 2021 19:14
PowerShell function to compute hashes of string values. Use built-in Get-FileHash for hashing the contents of files.
function Get-Hash {
[CmdletBinding()]
param (
[Parameter(Mandatory, ValueFromPipeline)]
[string]$Value,
[Parameter()]
[ValidateSet('sha1', 'sha256', 'sha384', 'sha512', 'md5')]
[string]$Algorithm = 'sha256',
@jrotello
jrotello / Get-RandomPassword.ps1
Last active November 7, 2019 17:30
Simple random password generator
function Get-RandomPassword {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[ValidateRange(8, 64)]
[int]$Length
)
$alphabet =
[char[]]'!@#$%^&*+?' +
@jrotello
jrotello / Convert-TemplateOutputsToPipelineVariables.ps1
Created October 31, 2019 13:28
Export ARM Template outputs as pipeline vars
$outputs= $env:ArmOutputs | convertfrom-json
$outputs
# Export pipeline variables for each ARM output value:
$props = ($outputs | Get-Member -MemberType NoteProperty)
foreach($p in $props) {
# this next line is to write one of these for each output value:
# --> "##vso[task.setvariable variable=websiteName]web-abcdefghi"
$name = $p.Name
[CmdletBinding()]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[string[]]$Hostname,
[Parameter()]
[string]$CloudflareEmail = "$env:CLOUDFLARE_EMAIL",
[Parameter()]
[string]$CloudflareApiKey = "$env:CLOUDFLARE_APIKEY"

Keybase proof

I hereby claim:

  • I am jrotello on github.
  • I am jrotello (https://keybase.io/jrotello) on keybase.
  • I have a public key ASAHkEijd7avxC-j5d0r0uXLUVnWxQgTetTqfdod4LYu8wo

To claim this, I am signing this object:

@jrotello
jrotello / DevelopmentCertificateAuthority.psm1
Last active December 15, 2023 20:15
A PowerShell module to ease creating a certificate authority and intermediate authority for development purposes
function New-SelfSignedRootCertificate {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string] $Name,
[Parameter(Mandatory = $true)]
[string] $CertStoreLocation,
[Parameter()]
@jrotello
jrotello / ConvertTestProjects.ps1
Last active October 13, 2017 21:56
Script to mark '*.Tests.csproj' as C# test projects.
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$BasePath
)
Push-Location $BasePath
$Namespace = 'http://schemas.microsoft.com/developer/msbuild/2003'
$ProjectTypeGuids = '{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}' # TestProject;C#
@jrotello
jrotello / AddResharperToggle.ps1
Last active June 22, 2022 11:45
Script to add a toolbar and button for toggling the suspended state of ReSharper.
$cmdbar_name = 'ReSharper (Custom)'
$ctrl_caption = 'Toggle ReSharper'
$cmdbar = $DTE.CommandBars[$cmdbar_name]
if (-not $cmdbar) {
Write-Host "Creating '$cmdbar_name' toolbar..."
$cmdbar = $DTE.Commands.AddCommandBar($cmdbar_name, [EnvDTE.vsCommandBarType]::vsCommandBarTypeToolbar)
}
if (-not ($cmdbar.Controls | Where-Object Caption -eq $ctrl_caption)) {
@jrotello
jrotello / README.md
Last active January 5, 2021 13:07
Scripts for automating a Let's Encrypt certificate on a Ubiquiti CloudKey

Usage