Skip to content

Instantly share code, notes, and snippets.

View jbirley's full-sized avatar
🏠
Working from home

Jim Birley jbirley

🏠
Working from home
View GitHub Profile
@jbirley
jbirley / ParenthesizeLine.ps1
Created September 9, 2020 16:44
PsReadlineKeyHandler to put parenthesis around the entire line and move the cursor to the end of line.
$ScriptBlock = {
param($Key, $Arg)
$Line = $null
$Cursor = $null
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$Line, [ref]$Cursor)
[Microsoft.PowerShell.PSConsoleReadLine]::Replace(0, $Line.Length, '(' + $Line + ')')
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
}
@jbirley
jbirley / Get-vNumaInfo.ps1
Created August 28, 2018 18:03
This function gives Virtual Machine vCPU and vNuma rightsizing recommendations based on Rules of Thumb from this popular VMWare blog post: https://blogs.vmware.com/performance/2017/03/virtual-machine-vcpu-and-vnuma-rightsizing-rules-of-thumb.html#comment-117062 This function assumes that each VM is part of a vSphere cluster and will therefore ev…
#Requires -Version 3.0
function Get-vNumaInfo {
<#
.SYNOPSIS
Gets the current resource (vCPU and vRAM) information about one or more VMs and makes a recommendation based on best practice for vNuma.
.DESCRIPTION
This function gives Virtual Machine vCPU and vNuma rightsizing recommendations based on Rules of Thumb from this popular VMWare blog post:
https://blogs.vmware.com/performance/2017/03/virtual-machine-vcpu-and-vnuma-rightsizing-rules-of-thumb.html#comment-117062
@jbirley
jbirley / Set-VMToolsUpgradePolicy.ps1
Last active March 8, 2018 00:13
A PowerShell function that sets the VM Tools Upgrade Policy on a VM. This function assumes you are using PowerCLI modules and are connected to a vCenter.
#Requires -Version 3.0
function Set-VMToolsUpgradePolicy {
<#
.SYNOPSIS
Updates the Tools Upgrade Policy on VMware VM.
.DESCRIPTION
This function uses get-view to get a managed object reference to a VM, and updates its 'ToolsUpgradePolicy'
@jbirley
jbirley / Get-Percentile.ps1
Last active March 5, 2024 14:16
A percentile function for PowerShell
# MIT License
# Copyright (c) 2022 Jim Birley
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions: