Skip to content

Instantly share code, notes, and snippets.

View peterhynes's full-sized avatar

Peter Hynes peterhynes

View GitHub Profile
@peterhynes
peterhynes / snapshotManager.ps1
Created November 21, 2018 09:18
Powercli script to take delete or revert snapshots
#Script to manage snapshots - take snaps - delete snaps - revert to snaps
#By Peter Hynes 06-11-2018
#Comment out any section you do not want to run
#Replace vcentername with the name of the vcenter you are working in.
#Replace vm1 vm2 vm3 with the name of the vms you are working with - you can add as many vms as needed here
#Replace snapshotname and shapshot description with an appropriate name and description
connect-viserver vcentername
$vms = ("vm1", "vm2", "vm3",)
#Script to add disk to VMs by Peter Hynes
#Version 1.0
#Created on the 27\09\2018
#Connect to the vCenter or vcenters and Run within PowerCLI
#You will need to create a txt file called vms.txt and place it in the same folder as this script. Put the list of VMs you are working with in this txt file.
$vcenter = Read-Host "Enter name of the vcenter you are working in"
#Connect to vcenter
connect-viserver $vcenter
#Script to get provisioned state for clusters in a vc by Peter Hynes
#Needs vSphere overcommit module located at https://blogs.vmware.com/PowerCLI/2015/01/powercli-module-check-cpu-memory-storage-overcommitment.html
#Script asks for a vcenter name
$Vcenter = read-host "please enter the name of the vcenter you will be working in"
#Connects to the vcenter
Connect-viserver $Vcenter
#get all clusters
@peterhynes
peterhynes / Get-Cluster-Hardware-Bios-Esxi-Version.ps1
Created April 17, 2018 08:27
Get hardware and esxi details for clusters
#Script to get bios version by Peter Hynes
#Version 1.0
#Created on the 11/04/2018
#Connect to the vCenter or vcenters and Run within PowerCLI
#You will need to create a txt file called clusters.txt and place it in the same folder as this script. Put the list of clusters you want to pull info from in to this txt file.
$clusters = get-content .\clusters.txt
try {
get-cluster $clusters |
@peterhynes
peterhynes / Get-Cluster-Bios-Version.ps1
Last active April 11, 2018 13:08
Get vmware cluster/host bios version
#Script to get bios version of esxi host VMs by Peter Hynes
#Version 1.0
#Created on the 11/04/2018
#Connect to the vCenter or vcenters and Run within PowerCLI
#You will need to create a txt file called clusters.txt and place it in the same folder as this script. Put the list of clusters you want to pull info from in to this txt file.
$clusters = get-content .\clusters.txt
ForEach($cluster in $clusters){
#Python script to test connection to vcenter api and pull vm information
from pyVim.connect import SmartConnect, Disconnect
import ssl
username = input("Please enter your username: ")
password = input("Please enter your password: ")
s =ssl.SSLContext(ssl.PROTOCOL_TLSv1_1)
s.verify_mode = ssl.CERT_NONE
#Script to pull local permissions on esxi hosts
#Version 1.0
#@Peter Hynes
#Created on Nov 9th 2017
#You will need to create 3 txt files and populate them hosts.txt, vcs.txt and ilos.txt. Place these files in the same folder as this script.
#Load powercli modules
Get-Module -Name VMware* -ListAvailable | Import-Module
Add-PSSnapin vmware*
/*
ClothesShopCalc.java
@ Peter Hynes
28th Sept
*/
//Scanner class - Utility package import
import java.util.*;
//class signature
#Script to Pull logs from ESXi host by Peter Hynes
#Version 1.0
#Created on the 03\03\2017
#Run within PowerCLI
#Script will ask for Vcenter name and hosts name
#vCenter you are working in
$vcenter = read-host "Please enter the name of the vCenter you will be working in"
#Host you are pulling logs from
#Script to delete VMs by Peter Hynes
#Version 1.10
#Created on the 16\03\2017
#Connect to the vCenter or vcenters and Run within PowerCLI
#You will need to create a txt file called vms.txt and place it in the same folder as this script. Put the list of VMs you want to delete in to this txt file.
#Load powercli modules
Get-Module -Name VMware* -ListAvailable | Import-Module
Add-PSSnapin vmware*