Skip to content

Instantly share code, notes, and snippets.

@vmnomad
vmnomad / Validate-VTEP.ps1
Last active November 13, 2017 08:49
Validate VTEP connectivity and MTU size
# Author: Askar Kopbayev
#
# Description: Powershell script to automate validation of NSX-v VTEP connectivity and MTU size along the path.
# Blog post: https://vmnomad.blogspot.com/2017/11/validating-nsx-vtep-connectivity.html
#
# The script requires vCenter an NSX names and credentials and produces two reports: Detailed and Summary.
#
# clean up all variables
foreach ($i in (ls variable:/*)) {rv -ea 0 $i.Name}
@vmnomad
vmnomad / Get-NSXRestAPI.ps1
Last active September 22, 2017 04:06
Automating RestAPI calls in PowerCLI, using NSX as an example
# Get-AuthHeader function - used to collect vRO credentials and produce authorization header
function Get-AuthHeader($string) {
   $bytes  = [System.Text.Encoding]::UTF8.GetBytes($string);
   $encoded = [System.Convert]::ToBase64String($bytes);
  $cred = "Basic $($encoded)"
   return $cred;
}
Function Get-NSXRestAPI{
@vmnomad
vmnomad / ChangeMemReservations.ps1
Last active August 26, 2017 13:10
Changing Memory Reservations on all VMs, including those where ReconfigureVM_Task method is disabled
# Created by Askar Kopbayev
# Description: Changes VM Memory reservations on all VMs to 99%, including NSX Edges and Controllers where ReconfigureVM_Task method is disabled.
# Credit to William Lam for amazing functions to Enable and Disable Methods http://www.virtuallyghetto.com/2016/07/how-to-easily-disable-vmotion-cross-vcenter-vmotion-for-a-particular-virtual-machine.html
Function Enable-vSphereMethod {
param(
[Parameter(
Position=0,
Mandatory=$true,
ValueFromPipeline=$true,
@vmnomad
vmnomad / ReplaceUUID.ps1
Last active May 4, 2017 13:05
Replacing virtual machine disk UUID
<#
.SYNOPSIS
This script allows to create replica seeds for vSphere Replication without powering off the source VM and keeping identical UUID
.NOTES
File Name : xMove-VM.ps1
Author : Askar Kopbayev - @akopbayev
Version : 1.0
.LINK
http://vmnomad.blogspot.com/creatingreplicaseedsforpoweredOnVMs.html
.LINK
@vmnomad
vmnomad / scratch.ps1
Last active July 14, 2016 13:44
Automating configuration of scratch location for ESXi servers
#Collect the vCenter, Cluster and scratch_datastore
Param([String]$vCenter, [String]$Cluster, [String]$Datastore, [String]$Folder)
#Function to use multiple colors in one command
function Write-Color([String[]]$Text, [ConsoleColor[]]$Color) {
for ($i = 0; $i -lt $Text.Length; $i++) {
Write-Host $Text[$i] -Foreground $Color[$i] -NoNewLine
}
Write-Host
}
@vmnomad
vmnomad / ChangeIP.ps1
Last active March 20, 2021 19:25
Bulk IP Address and Portgroup change with PowerCLI
param([String]$Inventory, [String]$VC)
# Getting credentials
do {
$user = Read-Host -Prompt 'Enter username for source vCenter'
$pass = Read-Host -AsSecureString -Prompt 'Enter password for source vCenter'
$cont = Read-Host -Prompt 'Type y to continue'
} while($cont -ne 'y')
$cred = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $user, $pass