Skip to content

Instantly share code, notes, and snippets.

$VMHosts = Get-Cluster "Test01" | Get-VMHost
[INT]$Time = "86400" #24 Hours
$Report = @()
#Start running through all hosts in the vCenter
foreach($VMhost in $VMHosts){
#$Resp is used to get responed from try/catch command for getting vlan stats status
$Resp = ""
#Test if vmnic0 is enabled for vlan stats – if true it presumed that all vmnic’s on the host is enabled
try { ($esxcli = $VMHost | Get-EsxCli).network.nic.vlan.stats.get("vmnic0")| Out-Null } catch { $Resp = $_.Exception }
#Created by Michael Ryom
#Version 0.1
#2017
#Source: https://michaelryom.dk/export-settings-from-vrops/
#Variables
$username = "user"
$password = "password"
$vRopsFQDN = "vrops.MichaelRyom.dk"
$PageSize = "5000" #Maximum is 5000
#!/bin/bash
#Source https://michaelryom.dk/custom-ddns-on-ubiquiti-usg/
cat << 'EOF' > /etc/cron.hourly/ddns
#!/bin/bash
IP=$(curl -s -L "http://ipv4.myip.dk/api/info/IPv4Address" | sed -e 's/^"//' -e 's/"$//')
curl -s -L "https://api.unoeuro.com/ddns.php?apikey=<API key>&domain=<Domain>&hostname=<Sub domain>&myip=$IP" | logger
EOF
chmod +x /etc/cron.hourly/ddns
#User varables
$LIhost = "10.10.10.10" #IP or FQDN
$Provider = "Local" #Local, ActiveDirectory
$Username = "admin"
$Password = "VMware1!"
#SSL certificate trust - Trust all certs
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Agent config API
PUT /api/v1/agent/config controllers.agents.AgentConfigController.set()
GET /api/v1/agent/config/:agentId controllers.agents.AgentConfigController.get(agentId :String, hash :String ?= "")
# Agent status API
PUT /api/v1/agent/status/:agentId controllers.agents.AgentStatusController.set(agentId :String)
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Agent config API
PUT /api/v1/agent/config controllers.agents.AgentConfigController.set()
GET /api/v1/agent/config/:agentId controllers.agents.AgentConfigController.get(agentId :String, hash :String ?= "")
# Agent status API
PUT /api/v1/agent/status/:agentId controllers.agents.AgentStatusController.set(agentId :String)
$usernameHost = Read-Host -Prompt 'Host Username'
$secPwHost = Read-Host -Prompt 'Host Password' -AsSecureString
$credHost = New-Object PSCredential -ArgumentList $usernameHost,$secPwHost
$VMHosts = "Host01","Host02","Host03"
foreach($Vmhost in $Vmhosts){
Connect-VIServer $Vmhost -Credential $credHost
$esxcli = Get-EsxCli $VMHost
#Source: https://michaelryom.dk/auto-create-nano-server-for-esxi-with-powershell
#Created by Michael Ryom @MichaelRyom.dk
#Https://MichaelRyom.dk
#Go to https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-technical-preview and download Windows Server TP 5 - Nano ISO
#Link that might work ? http://care.dlservice.microsoft.com/dl/download/B/3/3/B33F3810-EE82-4C20-B864-394A2C4B6661/Nano-WindowsServerTechnicalPreview5.vhd
#Windows Server TP5 Licnese Key MFY9F-XBN2F-TYFMP-CCV49-RMYVH
#Download image if link works: wget http://care.dlservice.microsoft.com/dl/download/B/3/3/B33F3810-EE82-4C20-B864-394A2C4B6661/Nano-WindowsServerTechnicalPreview5.vhd -OutFile C:\temp\Windows-Nano-Server-TP5.VHD
#http://care.dlservice.microsoft.com/dl/download/8/9/2/89284B3B-BA51-49C8-90F8-59C0A58D0E70/14300.1000.160324-1723.RS1_RELEASE_SVC_SERVER_OEMRET_X64FRE_EN-US.ISO
#Variables that can be chnaged
{
"name":"Custom vRops Content Pack",
"namespace":"MichaelRyom.dk",
"contentPackId":"MichaelRyom.dk",
"framework":"#9c4",
"version":"2.4",
"extractedFields":[ {
"displayName":"MichaelRyom_vRops_API_Call",
"preContext":" \\- ",
"postContext":" elapsed time in ms: ",
Get-VMHost | Get-VMHostNetwork | Select HostName,`
@{Name="vmk0";Expression={($_.VirtualNic | where {$_.Name -eq "vmk0"}).mac}},`
@{Name="vmk1";Expression={($_.VirtualNic | where {$_.Name -eq "vmk1"}).mac}},`
@{Name="vmnic0";Expression={($_.PhysicalNic | where {$_.Name -eq "vmnic0"}).mac}},`
@{Name="vmnic1";Expression={($_.PhysicalNic | where {$_.Name -eq "vmnic1"}).mac}}`
| Export-Csv c:\temp\Mac_Address_List.csv