Skip to content

Instantly share code, notes, and snippets.

@TScalzott
TScalzott / Set-ClaimRules.ps1
Last active January 27, 2016 16:24
vSphere Claim Rules
$esxCred = Get-Credential
Connect-VIServer $esx -Credential $esxCred
$esxcli = Get-ESXcli
# Add the claim rule and test for its existence. This also fails if the claim rule
# is already present.
try {
$esxcli.storage.nmp.satp.rule.add($null,"tpgs_on",
"HP 3PAR Custom ALUA Rule", $null, $null, $null, "VV",
@TScalzott
TScalzott / esxcli-claim-rule.txt
Last active August 29, 2015 14:12
esxcli claim rule addition
# esxcli storage nmp satp rule add -s "VMW_SATP_ALUA" -P "VMW_PSP_RR" –O "iops=1" -c "tpgs_on" -V "3PARdata" -M "VV" -e "HP 3PAR Custom Rule"
@TScalzott
TScalzott / Get-MailboxSizes.ps1
Created January 5, 2015 19:41
Get-MailboxSizes
# Get-MailboxSizes.ps1
#
# Requires Microsoft Active Directory module
If ((Get-Module | Where { $_.Name -eq "ActiveDirectory"}) -eq $null) {
Import-Module ActiveDirectory;
If ((Get-Module | Where { $_.Name -eq "ActiveDirectory"}) -eq $null) { throw "ActiveDirectory Module is required." }
}
$colServers = @("Server1", "Server2") # array of Exchange Servers to poll
# Our XAML for the WPF-based GUI.
$inputXAML = @"
<Window x:Name="Pick_Console" x:Class="LetUsWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LetUsWPF"
mc:Ignorable="d"
Title="MainWindow" Height="275" Width="410">
# Load WPF support and our XML into a form
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
try {
$Form = [Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader $xaml))
}
catch {
Write-Host "Failed to load Windows.Markup.XamlReader. Invalid XML?"
exit
}
# Load XAML Objects into variables
$xaml.SelectNodes("//*[@Name]") |
Where-Object { $_.Name -notlike "label_*" } |
ForEach-Object { Set-Variable -Name "WPF_$($_.Name)" -Value $Form.FindName($_.Name) }
#
# Event Handlers for our WPF controls
#
# WPF form is loaded
$Form.Add_Loaded({
# Connect to vCenter and populate the list of clusters
Connect-VIServer $vCenter
Get-Cluster | ForEach-Object { $WPF_cluster.Items.Add($_.Name) }
#
# Variables that you can/should change
#
$vCenter = "my-vcsa"
# Present!
$form.ShowDialog() | Out-Null
# Our XAML for the WPF-based GUI.
$inputXAML = @"
<Window x:Name="Pick_Console" x:Class="LetUsWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LetUsWPF"
mc:Ignorable="d"
Title="MainWindow" Height="275" Width="410">
@TScalzott
TScalzott / gist:c420a5f85bedb6bc5f4e
Created October 29, 2015 00:03
Not-So-Elegant Template Info
$Templates = @()
$Hosts = Get-VMHost
foreach ($h in $hosts) {
$HostTemplates = Get-Template -Location $h
foreach ($t in $HostTemplates) {
$TemplateInfo = New-Object PSObject
$TemplateInfo | Add-Member -MemberType NoteProperty Name -Value $t.Name
$TemplateInfo | Add-Member -MemberType NoteProperty Host -Value $h.Name
$Templates += $TemplateInfo
}