Skip to content

Instantly share code, notes, and snippets.

View vMarkusK's full-sized avatar

Markus Kraus vMarkusK

View GitHub Profile
@vMarkusK
vMarkusK / iLOSignCertv2-31.ps1
Created January 27, 2016 12:26
HP iLO bulk SSL Generation & Installation via PowerShell
#############################################################################
# iLO Bulk SSL Generation & Installation Script
# Written by Ben Short
# Modified by Markus Kraus
# Version 3.1, September 2015
#
# Released under Creative Commons BY,SA
# http://creativecommons.org.au/learn/licences/
#
# Script enumerates iLO devices from text file and generates
@vMarkusK
vMarkusK / esxi-Base-konfig-10.ps1
Last active February 20, 2016 17:58
ESXi Basis-Konfiguration mit HP 3PAR
$ESXiHostList = Get-VMHost
$syslog = "udp://syslog.test.lan:514"
$NTP1 = "192.168.2.1"
$NTP2 = "192.168.2.2"
foreach ($ESXiHost in $ESXiHostList)
{
#Enable SSH and disable SSH Warning
$SSHService = $ESXiHost | Get-VMHostService | where {$_.Key -eq 'TSM-SSH'}
Start-VMHostService -HostService $SSHService -Confirm:$false
@vMarkusK
vMarkusK / PortGroup-Creator.ps1
Last active July 12, 2016 20:57
Creates PortGroups on Standard vSwitches on all Hosts in a vSphere Cluster
# Load VMware Snapin (if not already loaded)
if (!(Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue)) {
if (!(Add-PSSnapin -PassThru VMware.VimAutomation.Core)) {
# Error out if loading fails
Write-Error "ERROR: Cannot load the VMware Snapin. Is the PowerCLI installed?"
Exit
}
}
# Start Global Definitions
$vSwitches = New-Object System.Collections.ArrayList
@vMarkusK
vMarkusK / scsi-unmap.ps1
Last active June 2, 2017 15:08
Runs VAAI UNMAP on a group of VMware Datastores
# Start Load VMware Snapin (if not already loaded)
if (!(Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue)) {
if (!(Add-PSSnapin -PassThru VMware.VimAutomation.Core)) {
# Error out if loading fails
Write-Error "ERROR: Cannot load the VMware Snapin. Is the PowerCLI installed?"
Exit
}
}
# End Load VMware Snapin (if not already loaded)
@vMarkusK
vMarkusK / Clear-Eventlog.ps1
Last active July 12, 2016 20:40
Clears the whole Windows Eventlog
foreach ($log in (get-eventlog -list).Log) {
clear-eventlog -log $log
}
# Alternative way
$logs = get-eventlog -list; $logs.foreach{clear-eventlog -log $_.Log}
@vMarkusK
vMarkusK / ESXi-Image_v2.ps1
Last active February 9, 2016 14:57
Creates a ESXi Image from Online Depot and adds additional packages
# Load ImageBuilder Snapin (if not already loaded)
if (!(Get-PSSnapin -name VMware.ImageBuilder -ErrorAction:SilentlyContinue)) {
if (!(Add-PSSnapin -PassThru VMware.ImageBuilder)) {
# Error out if loading fails
write-host "`nFATAL ERROR: Cannot load the ImageBuilder Snapin. Is the PowerCLI installed?`n"
exit
}
}
cls
# Definde Global
@vMarkusK
vMarkusK / Align-NetworkName-VM.ps1
Last active July 13, 2016 13:33
Align Windows Network Name to VM PortGroup Name
if (!(get-pssnapin -name VMware.VimAutomation.Core -erroraction silentlycontinue)) {
add-pssnapin VMware.VimAutomation.Core
}
$i = 1
$GCred = Get-Credential
$VMtoProcess = Get-VM -Name MY-VEEAM-01
Write-Host -foregroundcolor DarkGreen -backgroundcolor white "vSphere Network Config of the VM:"
$VMtoProcess | Get-NetworkAdapter | Select Parent, NetworkName, MacAddress | ft -AutoSize
@vMarkusK
vMarkusK / Align-NetworkName-Uni.ps1
Created February 9, 2016 16:16
Set Windows Network Name by MAC from CSV
# Importing the CSV-file containing the NIC configuration.
$NICs = Import-Csv "C:\Scripts\NICs.csv" | Where-Object {$_.computername -eq $env:COMPUTERNAME}
foreach ($NIC in $NICs) {
$NetAdapter = Get-NetAdapter | Where-Object {$_.MacAddress -eq $NIC.MAC}
if ($NetAdapter) {
Write-Verbose "Found NIC $($NIC.NIC)"
@vMarkusK
vMarkusK / vm-hardening_v1.2.ps1
Last active November 22, 2016 11:28
VM Hardening Script
#############################################################################
# VM Hardening Script
# Written by Markus Kraus
# Version 1.2
#
# http://mycloudrevolution.com/
#
# Changelog:
# 2016.01 ver 1.0 Base Release
# 2016.02 ver 1.1 Added more Error Handling
@vMarkusK
vMarkusK / vm-hardening_v1.0.js
Created February 12, 2016 09:17
VMware vRO Scriptable Task for VM Hardening
var VcVMConfigSpec = new VcVirtualMachineConfigSpec();
var changeValue = new Array();
System.log ("Config From Array:");
for (var i = 0; i < VcVmConfig.length; i++) {
System.log ("Name: " + VcVmConfig[i].key + " - " + "Value: " + VcVmConfig[i].value);
changeValue[i] = new VcOptionValue();
changeValue[i].key = VcVmConfig[i].key;
changeValue[i].value = VcVmConfig[i].value;
}