Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Bryan McClellan mccbryan3

🏠
Working from home
View GitHub Profile
@mccbryan3
mccbryan3 / create-dhcp-dns-for-vms.ps1
Last active Sep 16, 2020
Creates AD integrated DNS and DHCP records for vCenter based VMs. Uses runtime creds and assumes that DNS and DHCP are on the same server. Wild cards can be used for esx_vm_names.
View create-dhcp-dns-for-vms.ps1
param (
[Parameter(Mandatory=$true)]
[string]$esx_vm_name,
[Parameter(Mandatory=$true)]
[string]$vcenter_build,
[Parameter(Mandatory=$true)]
[string]$scope_id,
[Parameter(Mandatory=$true)]
[string]$dhcp_server,
[Parameter(Mandatory=$true)]
@mccbryan3
mccbryan3 / calm-unattend.xml
Created Jul 22, 2020
Nutanix Calm unattend.xml file for windows server with macros
View calm-unattend.xml
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="windowsPE">
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<UserData>
<AcceptEula>true</AcceptEula>
<FullName>@@{windows_admin.username}@@</FullName>
<Organization>Organization</Organization>
<ProductKey>
<Key>@@{PRODUCT_KEY}@@</Key>
View tkg-sa-priv-user-role-binding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: psp:vmware-system-privileged
roleRef:
kind: ClusterRole
name: psp:vmware-system-privileged
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
@mccbryan3
mccbryan3 / vro-get.vm-and-sdk-vm-name-exact.js
Last active May 16, 2020
This will take a VM input and search all vcenters added to vro and load the VC:Vm and VC:SdkConnection into output variables
View vro-get.vm-and-sdk-vm-name-exact.js
var reg = new RegExp("^"+ strVmName + "$", 'ig');
for each(vm in VcPlugin.getAllVirtualMachines(null,"xpath:name='" + strVmName + "'")) {
if(vm.name.match(reg)) {
vcenterSdk = vm.sdkConnection
vmOut = vm
System.log(vmOut.summary)
System.log(vcenterSdk)
}
}
@mccbryan3
mccbryan3 / format-svc-output-csv
Last active May 14, 2020
Take the SVC unformatted output for host to vdisk and use a name,capacity,FC_id vdisk list in anothe file to build the report.
View format-svc-output-csv
$basepath = 'C:\Storage-Migration'
$content = gc "$basepath\mc\mcsvc01vdisks.txt"
gc "$basepath\mc\mcsvc01vdisksbyhost.txt" | %{
$line = $_
if($line -match "^\d+") {
$match = [regex]::Matches($line, "\S*(?>\s+)")
$vol_match = $content | sls -Pattern $(($match[4].value).Trim())
try{
if($match) {
$vol_size = [regex]::Match($vol_match,'(?<=,)[\w\.\w]+(?=,[m\d])')
@mccbryan3
mccbryan3 / find-vmhost-lun-no-datastore.ps1
Last active May 12, 2020
This script will locate all luns on hosts that are not currently datastores and set output
View find-vmhost-lun-no-datastore.ps1
try{
$luns = get-vmhost | Get-Datastore | Get-ScsiLun -ErrorAction SilentlyContinue
# $luns.CanonicalName
} catch {
"Error getting lun info for one or more luns"
}
$array = @()
Get-VMHost | Get-ScsiLun | ?{$_.CanonicalName -notlike "mpx.*"} | %{
if(($luns.CanonicalName -notcontains $_.CanonicalName) -and ($array -notcontains $_.CanonicalName)) {
$array += $_.CanonicalName
View Openshift 4.2 on VMware using govc
curl https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/4.2/4.2.0/rhcos-4.2.0-x86_64-vmware.ova -o rhcos-4.2.0-x86_64-vmware.ova
govc import.ova -name=rhcos-4.2.0-x86_64-vmware ./rhcos-4.2.0-x86_64-vmware.ova
export GOVC_URL='vsphere.server.local
export GOVC_USERNAME='admin@vsphere.local'
export GOVC_PASSWORD='password
export GOVC_INSECURE=1
export GOVC_NETWORK='NETWORK'
@mccbryan3
mccbryan3 / openmanage-compute.py
Last active Feb 25, 2020
Dynamic inventory script for Ansible using the OME API to find device Type of 1000
View openmanage-compute.py
#!/usr/bin/env python
# Copyright: (c) 2018, Keiran Steele
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
import os
import sys
import argparse
try:
View getADGroupNamesFilterByNamePrefix-Exceptions.js
arr_groups = new Array()
System.log(nameStartsWith)
System.log("Running active Directory Search")
var groups = ActiveDirectory.search("UserGroup", nameStartsWith)
var arr_ExceptionList = exceptionList.split(",")
for (var i in groups) {
if(arr_ExceptionList.indexOf(groups[i].name) == -1) {
arr_groups.push(groups[i].name)
View getADGroupNamesFilterByNamePrefix.js
arr_groups = new Array()
System.log("Name Starts With: " + nameStartsWith)
System.log("Running active Directory Search")
var groups = ActiveDirectory.search("UserGroup", nameStartsWith)
for (var i in groups) {
System.log("building group array : " + groups[i].name)
arr_groups.push(groups[i].name)
}
return arr_groups
You can’t perform that action at this time.