Skip to content

Instantly share code, notes, and snippets.

import-module webadministration
$name = "Block API Help"
$site = 'IIS:\Sites\Default Web Site'
$root = '/system.webServer/rewrite/rules'
$filter = "{0}/rule[@name='{1}']" -f $root, $name
Add-WebConfigurationProperty -pspath $site -filter $root -name "." -value @{name='Block API Help'; patternSyntax='Wildcard'; stopProcessing='True'}
Set-WebConfigurationProperty -pspath $site -filter $filter/match -name "url" -value "*"
Add-WebConfigurationProperty -pspath $site -filter $filter/conditions -name "." -value @{logicalGrouping="MatchAll"; input="{URL}"; pattern='/api/help/*'}
Set-WebConfigurationProperty -pspath $site -filter $filter/action -name "type" -value "CustomResponse"
@kclinden
kclinden / Configure-SecureWinRM.ps1
Created December 1, 2020 17:54 — forked from bender-the-greatest/Configure-SecureWinRM.ps1
Configure WinRM to listen over SSL (port 5986) and use the web certificate generated by a certificate templated called 'WinRM'. Highly recommend reading Synopsis, Description, and Examples.
<#
.SYNOPSIS
Configures a secure WinRM listener over HTTPS to enable
SSL-based WinRM communications. This script has not been
tested on Windows Server 2003R2 or earier, and may not
work on these OSes for a variety of reasons.
If Windows Remote Management is disabled (e.g. service
stopped, GPO Policy, etc.), this script will likely fail.
.DESCRIPTION
@kclinden
kclinden / get_subnet_arns_by_tag.tf
Last active October 13, 2020 21:19
Get Subnet ARNs by Tag
#This was an interesting thing I was trying to figure out. I used this to pass into a IAM Policy Resource Limit
# Get all of the subents with tag packer; returns a set of ids
data "aws_subnet_ids" "this" {
vpc_id = var.vpc_id
tags = {
tag_name = "tag_value"
}
}
//Description: vRO Action to get the Create a virtual disk config spec
//Inputs: [Any] sizeInGb, [string] datastore, [number] controllerKey, [number] diskIndex, [VC:VirtualDiskMode] diskMode, [boolean] thinProvisioned, [string] sharingType, [number] diskKey
//Return Type: Any
// Create Disk BackingInfo
var diskBackingInfo = new VcVirtualDiskFlatVer2BackingInfo();
diskBackingInfo.diskMode = diskMode.value;
var datastorePath = "[" + datastore + "]";
diskBackingInfo.fileName = datastorePath;
diskBackingInfo.thinProvisioned = thinProvisioned;
@kclinden
kclinden / reconfigVM.js
Created January 29, 2019 13:08
vRO Action to execute a vm reconfig task
//Description: vRO Action to execute a vm reconfig task
//Inputs: [Array/Any] deviceConfigSpecs, [VC:VirtualMachine] vm
//Return Type: VC:Task
var configSpec = new VcVirtualMachineConfigSpec();
configSpec.deviceChange = deviceConfigSpecs;
return vm.reconfigVM_Task(configSpec);
@kclinden
kclinden / getScsiControllerNumber.js
Created January 29, 2019 13:07
vRO Action to get the SCSI Controller number for a vm and bus number
//Description: vRO Action to get the SCSI Controller number for a vm and bus number
//Inputs: [VC:VirtualMachine] vm, [Number] scsiBusNumber
//Return Type: number
//Inputs: vm, scsiBusNumber
//Outputs scsiControllerKey
scsiControllerKey = -1;
var devices = vm.config.hardware.device;
var isScsiBusNumberInvalid = true;
@kclinden
kclinden / getNextScsiBusNumber.js
Created January 29, 2019 13:05
vRO Action to get next SCSI bus number for a given VC:VirtualMachine
//Description: vRO Action to get next SCSI bus number for a given VC:VirtualMachine
//Inputs: [VC:VirtualMachine] virtualMachine
//Return Type: number
//Get next scsi bus number
var devices = virtualMachine.config.hardware.device;
if (devices != null) {
var highBusNumber = -1;
for each (device in devices){
System.debug(device);
@kclinden
kclinden / createParaVirtualScsiControllerConfigSpec.js
Created January 29, 2019 13:04
vRO Action to create a ParaVirtual SCSI Controller Config Spec
//Description Used by vRO to create a ParaVirtual SCSI Controller Config Spec
//Inputs: [string] type, [number] nextBusNumber
//Return Type: Any
// Create SCSI controller
var controller = null;
if ( type != null && "LSI".equalsIgnoreCase( type.toUpperCase() ) == true ) {
controller = new VcVirtualLsiLogicController();
}else if(type != null && "PARA".equalsIgnoreCase( type.toUpperCase() ) == true){
controller = new VcParaVirtualSCSIController();
@kclinden
kclinden / associateTag.js
Created December 11, 2018 20:03
Associate Tag
//Inputs: vapiEndpoint [VAPI:VAPIEndpoint], object_id_type [string], object_id_id [string], tag_id [string]
//Outputs: void
var object_id = new com_vmware_vapi_std_dynamic__ID()
object_id.type = object_id_type;
object_id.id = object_id_id;
var client = vapiEndpoint.client();
var service = new com_vmware_cis_tagging_tag__association(client);
service.attach(tag_id,object_id);
client.close();
@kclinden
kclinden / getTagCategories.js
Created December 11, 2018 20:01
Get Tag Categories
//Input: endpoint [VAPI:VAPIEndpoint]
//Return: Array/string
if(!endpoint){
return null
}
var client = endpoint.client();
var categories = new com_vmware_cis_tagging_category(client) ;
var catArray = [];