Skip to content

Instantly share code, notes, and snippets.

View vMarkusK's full-sized avatar

Markus Kraus vMarkusK

View GitHub Profile
@vMarkusK
vMarkusK / CheckDatastoresConnected.ps1
Last active June 23, 2016 09:44
Check All VMFS Datastores connected on all VMware ESXi Hosts
# 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 / Set-ConsolidationFix.ps1
Last active June 15, 2016 21:25
Fix for Snapshot consolidation in VMware ESXi 5.5.x and ESXi 6.0.x
Function Set-ConsolidationFix {
[cmdletbinding()]
param (
#[parameter(Mandatory=$true)]
[parameter(Mandatory=$true,ValueFromPipeline=$true)]
[VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine]$myVM,
[parameter(Mandatory=$true)]
[string]$Fix = "Timeout" # Timeout or Stun
@vMarkusK
vMarkusK / vCheck-Report-LUNPath-ESXCLI.ps1
Created June 14, 2016 12:40
Checks ESXi LUNs that have to much Paths or Multiple LUN IDs
# Start of Settings
# Set the maximum number of paths per LUN
$MaxLUNPaths = 4
# End of Settings
$myHosts = $VMH | where {$_.ConnectionState -eq "Connected" -and $_.PowerState -eq "PoweredOn"}
$Report = @()
foreach ($myHost in $myHosts) {
$esxcli2 = Get-ESXCLI -VMHost $myHost -V2
@vMarkusK
vMarkusK / Report-LUNPath-ESXCLI.ps1
Last active June 14, 2016 08:06
Reports ESXi Path-Count from all Devices via PowerCLI GET-ESXCLI -V2
# 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)
<#
.SYNOPSIS
Tells you how to get Awsome.
.DESCRIPTION
Tells you how to get Awsome.
.EXAMPLE
Get-Awsome
@vMarkusK
vMarkusK / PSGallery-Test.Tests.ps1
Last active June 1, 2016 13:47
Basic Pesser Test
Describe 'Module Test' {
It 'Tests the Output of my Module' {
Install-Module -Name PSGallery-Test -Force; Import-Module -Name PSGallery-Test; Get-Awsome | Should Be 'Get Awsome, Learn PowerShell! (http://mycloudrevolution.com/)'
}
}
@vMarkusK
vMarkusK / Publish-PSModule.ps1
Created June 1, 2016 13:04
Publishes a PowerShell Module to PowerShell Gallery
$Path = 'C:\Users\mkraus\Documents\GitHub\PowerShell-Gallery-Test\PSGallery-Test'
$PublishParams = @{
NuGetApiKey = 'your-API-key' # Swap this out with your API key
Path = $Path
}
Publish-Module @PublishParams
Find-Module PSGallery-Test
@vMarkusK
vMarkusK / Create-PSModuleStructure.ps1
Created June 1, 2016 12:30
Creates a Structure for a PS Module for PowerShell Gallery
$GitPath = 'C:\Users\mkraus\Documents\GitHub\PowerShell-Gallery-Test'
$ModuleName = 'PSGallery-Test'
$Author = 'Markus Kraus'
$Description = 'PSGallery-Test is a Test'
$CompanyName = 'mycloudrevolution'
$Copyright = '(c) 2016 Markus Kraus. All rights reserved.'
$ProjectUri = 'https://github.com/mycloudrevolution/PowerShell-Gallery-Test/'
$LicenseUri = $ProjectUri + 'LICENSE'
$Tags = 'mycloudrevolution','test'
@vMarkusK
vMarkusK / Push-vLIMessage.ps1
Last active November 3, 2016 12:29
Push Messages to VMware vRealize Log Inisght
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
@vMarkusK
vMarkusK / ubuntu16-customization.sh
Created May 2, 2016 14:58
ubuntu 16.04 Guest Customization Shell Script
#!/bin/bash
HOSTNAME=$1
IP=$2
SUBNET=$3
GATEWAY=$4
DOMAIN=$5
SEARCH=$6
DNS1=$7
DNS2=$8