Skip to content

Instantly share code, notes, and snippets.

View PatrickTerlisten's full-sized avatar

Patrick Terlisten PatrickTerlisten

View GitHub Profile
@PatrickTerlisten
PatrickTerlisten / Get-iovDisableIRSetting.ps1
Last active March 19, 2017 07:18
This script checks if the iovDisableIR setting is set to FALSE.
<#
.SYNOPSIS
This script checks if the iovDisableIR setting is set to FALSE.
.DESCRIPTION
The script checks the current setting of the Intel IOMMU interrupt remapper (iovDisableIR).
The script needs a single parameter:
- vSphere Cluster
@PatrickTerlisten
PatrickTerlisten / Get-iovDisableIRSetting.ps1
Last active April 4, 2017 07:15
This script checks if the iovDisableIR setting is set to FALSE.
<#
.SYNOPSIS
This script checks if the iovDisableIR setting is set to FALSE.
.DESCRIPTION
The script checks the current setting of the Intel IOMMU interrupt remapper (iovDisableIR).
The script needs a single parameter:
- vSphere Cluster
@PatrickTerlisten
PatrickTerlisten / Get-ScreenshotFromVM.ps1
Last active March 18, 2017 15:35
This script retrieves a console screenshot of one or more virtual machines.
<#
.SYNOPSIS
This script retrieves a console screenshot of one or more virtual machines.
.DESCRIPTION
The script needs four parameters:
- the name of the VM (name from the inventory)
- the hostname of a vCenter or ESXi host
- username, and
@PatrickTerlisten
PatrickTerlisten / Deploy-AzureLab.ps1
Created January 15, 2017 19:09
v0.1 of my Deploy-AzureLab script
<#
.SYNOPSIS
No parameters needed. Just execute the script.
.DESCRIPTION
The script deploys a couple of VMs to Azure.
History
v0.1: Under development
@PatrickTerlisten
PatrickTerlisten / GetTemperatureSensorData.py
Last active May 10, 2017 11:08
Monitoring hardware status with Python and vSphere API calls
from pyVim.connect import SmartConnect, Disconnect
import ssl
s = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
s.verify_mode = ssl.CERT_NONE
try:
c = SmartConnect(host='vcenter.lab.local', user='root', pwd='Passw0rd')
print('Valid certificate\n')
except:
@PatrickTerlisten
PatrickTerlisten / vsphereconnect.py
Created May 9, 2016 10:24
Connect to vSphere using SmartConnect
import ssl
from pyVim.connect import SmartConnect
s = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
s.verify_mode = ssl.CERT_NONE
c = SmartConnect(host="192.168.20.1", user="root", pwd='Passw0rd', sslContext=s)
h = c.content.sessionManager.currentSession.key
print (h)
###
# VMware PowerCLI
###
# Create a new entry in the credential store
New-VICredentialStoreItem -Host vcenter.domain.tld -User Username -Password Passw0rd
# Connect to vCenter server (credential store item exist for this vCenter server)
@PatrickTerlisten
PatrickTerlisten / disable_dhcp_inform.vbs
Created April 17, 2016 08:32
Disable DHCPINFORM on Windows 2000, 2003, XP, Vista, 7
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT Name,DeviceID FROM Win32_NetworkAdapter WHERE NetConnectionStatus=2", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
strName = objItem.Name
Set colNicConfigs = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_NetworkAdapter.DeviceID='" & objItem.DeviceID & "'} WHERE AssocClass=Win32_NetworkAdapterSetting")
@PatrickTerlisten
PatrickTerlisten / Get-CpuRatio
Last active May 8, 2018 21:33
This script outputs the pCPU/ vCPU ratio for each ESXi host.
#requires -Version 1
#requires -PSSnapin VMware.VimAutomation.Core
function Get-CpuRatio {
<#
.SYNOPSIS
No parameters needed. Just execute the script.
.DESCRIPTION
@PatrickTerlisten
PatrickTerlisten / Shutdown-vSphereCluster.ps1
Created December 1, 2015 16:21
A script to shutdown a vSphere Cluster.
<#
.SYNOPSIS
No parameters needed. Just execute the script.
.DESCRIPTION
This script will shut down all VMs, the ESXi hosts that were running the VMs, the vCenter VM
and, at the end, the ESXi host that was running the vCener VM.
Please modify all necessary variables. Make sure that you read the comments!