Skip to content

Instantly share code, notes, and snippets.

@skunkie
skunkie / MyPSObject.ps1
Last active November 25, 2019 14:18
PSObject with op_Addition
Class MyPSObject : PSObject {
static [MyPSObject] op_Addition ([MyPSObject] $Object1, [MyPSObject] $Object2) {
<#
$obj1 = [mypsobject] @{a = 1}
$obj2 = [mypsobject] @{b = 2; c = 3}
$obj3 = [mypsobject] @{c = 0; d = 4}
$obj1 + $obj2 + $obj3
a c b d
@skunkie
skunkie / Extend Disks of Virtual Machine.js
Created July 31, 2019 12:27
VMware vRealize Orchestrator Workflow: Extend Disks of Virtual Machine
/**
* For vRO/VRA 7.0+
*
* Workflow Inputs:
* payload - Properties - vRA Payload
*
* Workflow Outputs:
* virtualMachineAddOrUpdateProperties - Properties
*/
@skunkie
skunkie / validateTcpUdpPortNumber.js
Created July 31, 2019 06:32
VMware vRealize Orchestrator Action: Test an string for a valid TCP/UDP port number or a TCP/UDP port range
/**
* Test an array of strings for a valid TCP/UDP port number or a TCP/UDP port range.
*
* For vRO/VRA 7.0+
*
* Action Inputs:
* values - Array/string - TCP/UDP port number
*/
function formatError(value) {
@skunkie
skunkie / validateIPv4Address.js
Created July 31, 2019 06:23
VMware vRealize Orchestrator Action: Test an array of strings for valid IPv4 Addresses
/**
* Test an array of strings for valid IPv4 Addresses.
*
* For vRO/VRA 7.0+
*
* Action Inputs:
* values - Array/string - IPv4 Addresses
*/
if (values === null) return "A value must be specified.";
@skunkie
skunkie / convertObjectToProperties.js
Created July 31, 2019 06:21
VMware vRealize Orchestrator Action: Create Properties from Object
/**
* Create Properties from Object
* @param {Object} obj Object
* @return {Properties} Properties
*/
function createProperties(obj) {
var props = new Properties();
for (var key in obj) {
// process Array
if (obj[key] instanceof Array) {
@skunkie
skunkie / Get-LoggedOnUser.ps1
Last active March 28, 2019 15:16
Get Logged On Users with 'query.exe USER' in PowerShell
function Get-LoggedOnUser {
param(
[string[]] $ComputerName=$env:COMPUTERNAME
)
Begin {
$ErrorActionPreference = 'Stop'
& cmd /c ver | Out-Null
$encoding = [Console]::OutputEncoding
[Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding('utf-8')
}
@skunkie
skunkie / Get-FolderPath.ps1
Last active February 11, 2019 07:13
This cmdlet retrieves the path to the folder on a vCenter Server system.
function Get-FolderPath {
<#
.NAME
Get-FolderPath
.SYNOPSIS
This cmdlet retrieves the path to the folder on a vCenter Server system.
.DESCRIPTION
This cmdlet retrieves the path to the folder on a vCenter Server system.
.PARAMETER Folder
a folder on a vCenter Server system
@skunkie
skunkie / Invoke-WmiMethodAsync.ps1
Last active December 21, 2018 06:24
Run a command async on a set of computers
#Requires -Version 3.0
<#
.SYNOPSIS
Wraps Invoke-WmiMethod to run a command async
.DESCRIPTION
Wraps Invoke-WmiMethod to run asynchronously on a number of computers
.PARAMETER Computer
An array of computers
.PARAMETER Command
@skunkie
skunkie / check_mk_script.iss
Created July 3, 2018 07:31
InnoSetup config file for Check_MK Agent
#define VERSIONFULL '1.4.0p26';
#define VERSIONSHORT '1.4.0.26';
#define WAITTIME 300;
;check the key 'only_from' in the section [global] of the file 'check_mk.ini':
#define only_from '127.0.0.1 10.0.0.8';
[Setup]
AppName=Check_MK Agent
AppVerName=Check_MK Agent v{#VERSIONFULL}
@skunkie
skunkie / routing.py
Created June 28, 2018 10:08
This script adds rules to the routing policy database
#!/usr/bin/env python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
#
# This script adds rules to the routing policy database
#
import ConfigParser
import os
import socket
import sys
from pyroute2 import IPRoute