Skip to content

Instantly share code, notes, and snippets.

View chelnak's full-sized avatar
👀
What's cooking?

Craig Gumbley chelnak

👀
What's cooking?
View GitHub Profile
@chelnak
chelnak / CustomPowerShellProfilePrompt.ps1
Created June 24, 2019 21:10
Custom prompt for PowerShell that displays your current Az subscription in the tile bar
function Prompt {
$CurrentTitle = $Host.UI.RawUI.WindowTitle
$Host.UI.RawUI.WindowTitle = "Loading Az ..."
Set-Location -Path $ENV:USERPROFILE/code -ErrorAction stop
$IsElevated = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
if ($IsElevated) {
Write-Host "$([char]9788) " -ForegroundColor Red -NoNewline
@chelnak
chelnak / New-CosmosDBRESTAuthToken.ps1
Last active November 28, 2017 14:58
Generate a CosmosDB REST API Auth token with PowerShell See here for more information https://docs.microsoft.com/en-us/rest/api/documentdb/access-control-on-documentdb-resources
function New-CosmosDBRESTAuthToken {
[CmdletBinding()]
Param(
[Parameter()]
[String]$Verb,
[Parameter()]
[String]$ResourceType,
[Parameter()]
[String]$ResourceId,
[Parameter()]
@chelnak
chelnak / o11nExecuteAction.ps1
Created May 4, 2017 10:53
o11n-gateway-service API execute action example
$Body = @"
{
"entries": [
{
"key": "name",
"value": {
"type": "string",
"value": "craig"
}
}
@chelnak
chelnak / o11nExecuteWorkflow.ps1
Created May 4, 2017 10:29
o11n-gateway-service API execute workflow example
$Body = @"
{
"requestHeader": null,
"requestData": {
"entries": [
{
"key": "host",
"value": {
"type": "string",
"value": "b89d15b9-b954-4046-9d76-778edd791b99"
@chelnak
chelnak / escapeDataString.ps1
Last active April 5, 2017 09:07
Escape URI String with PowerShell
$EscapedBusinessGroupName = [URI]::EscapeDataString($BusinessGroupName)
$URI = "/identity/api/tenants/$($TenantId)/subtenants?`$filter=name%20eq%20'$($EscapedBusinessGroupName)'"
$Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference
@chelnak
chelnak / Get-AzureRMResourceTypeAPIVersion.ps1
Created March 10, 2017 10:24
Small profile function to easily retrieve a list of API versions for a given Resource Type
function Get-AzureRMResourceTypeAPIVersion {
<#
.SYNOPSIS
Retrieve a list of API versions for a given ResourceTypeName
.DESCRIPTION
Retrieve a list of API versions for a given ResourceTypeName
.PARAMETER ProviderNamespace
@chelnak
chelnak / ConfigureVMDiskEncryption.ps1
Last active March 11, 2017 19:19
Encrypt Azure VM Disks with PowerShell
<#
.SYNOPSIS
Enables disk encrption on a VM
.DESCRIPTION
Enables disk encryption on a VM. The script will create a new Key Vault, Azure Active Directory Application and Service principal
.PARAMETER ResourceGroupName
The name of the resource group that contains the key vault and virtual machine
@chelnak
chelnak / setVirtualMachineState.js
Created February 7, 2017 09:54
Update IaaS Virtual Machine State
/*
- Update IaaS Virtual Machine State
- Input: virtualMachineName [String]
*/
var state = "Off";
var vCACVirtualMachine = Server.findAllForType("vCAC:VirtualMachine", "VirtualMachineName eq '" + virtualMachineName + "'");
@chelnak
chelnak / vco-cli.jar-help.md
Last active August 12, 2019 02:20
vco-cli.jar help

vCO Package import/export command line tool

Description:

Command line tool, that provides basic vCO package import and export operations. As source or target it can have either .package file, or directory.

Usage:

java <java-parameters> -jar PackageToolCli.jar <command> <command-parameters>