Skip to content

Instantly share code, notes, and snippets.

View tomtorggler's full-sized avatar

Thomas Torggler tomtorggler

View GitHub Profile
@tomtorggler
tomtorggler / Add-ExchangeOnlineAlias.ps1
Last active July 16, 2018 07:39
Adds Exchange Online email address to Mailboxes
if(-not(Get-PSSession)) {
. 'D:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1'
Connect-ExchangeServer -auto -ClientApplication:ManagementShell
}
$Mailboxes = Get-Content .\shared.txt | Get-Mailbox
$ExOSuffix = "<tenant>.mail.onmicrosoft.com"
# check if a new release of PowerShell Core is available on GitHub
function Test-PSVersionGitHub {
try {
# get latest release from github atom feed
$Release = Invoke-RestMethod https://github.com/PowerShell/PowerShell/releases.atom -ErrorAction Stop | Select-Object -First 1
} catch {
Write-Warning "Could not check for new version. $_ `n"
break
}
# extract information from atom response
@tomtorggler
tomtorggler / api-posts.html
Created March 31, 2017 15:56
Create JSON objects for all posts on a Jekyll site
---
# Requires Front Matter
---
{"items":[{% for post in site.posts %}{
"title": {{post.title | jsonify}},
"url": {{ post.url | prepend: site.baseurl | prepend: site.url | jsonify }},
"date": {{ post.date | date: '%B %-d, %Y' | jsonify }},
"category": {{ post.category | jsonify }},
"tags": {{ post.tags | jsonify }},
"author": {{ post.author | jsonify }},

Keybase proof

I hereby claim:

  • I am tomtorggler on github.
  • I am tomt (https://keybase.io/tomt) on keybase.
  • I have a public key ASDkspxaIxbg8tpKYocXMOINXISsNHKy95ujOT-fqEAtXwo

To claim this, I am signing this object:

function Set-VmNestedHVStatus {
param($VM,[bool]$NestedHVStatus)
foreach ($item in $VM) {
try {
$vm = Get-VM $item
$spec = New-Object -TypeName VMware.Vim.VirtualMachineConfigSpec
$spec.ChangeVersion = $vm.ExtensionData.Config.ChangeVersion
$spec.NestedHVEnabled = $NestedHVStatus
$vm.ExtensionData.ReconfigVM($spec)
} catch {
function Get-VmNestedHVStatus {
param($VM)
foreach ($item in $VM) {
try {
Get-VM $item -ErrorAction Stop | Select-Object -ExpandProperty extensiondata | Select-Object -ExpandProperty config | Select-Object Name,NestedHVEnabled
} catch {
Write-Warning -Message $_
}
}
}
# Configure virtual Switches on the Hyper-V Hosts
$vmSwitchParams = @{
CimSession = $cimSessions;
Name = "sw-ext";
NetAdapterName = "Ethernet";
AllowManagementOS = $true
}
New-VMSwitch @vmSwitchParams
# Configure paths for VMs and VHDs
$vmHostParams = @{
# Create VMs on a host and add them to the cluster
1..4 | ForEach-Object {
# create differencing VHD for the VM
$vhdParams = @{
Differencing = $true;
ParentPath = "c:\clusterstorage\volume1\hyper-v\vhd\win2012r2.vhdx";
Path = "c:\clusterstorage\volume1\hyper-v\vhd\hcvm0$_.vhdx";
ComputerName = "n01"
}
New-VHD @vhdParams
# Create Volume
Invoke-Command -ComputerName n01.vdi.local -ScriptBlock {
$params = @{
Size = 50GB;
StoragePoolFriendlyName = "s2d-pool";
FriendlyName = "mirror-disk";
FileSystem = "CSVFS_ReFS";
PhysicalDiskRedundancy = 2
}
New-Volume @params
# Create Storage Pool
Invoke-Command -ComputerName n01.vdi.local -ScriptBlock {
$params = @{
StorageSubSystemFriendlyName = "Cluste*";
FriendlyName = "s2d-pool";
PhysicalDisks = (Get-PhysicalDisk -StorageSubSystem (Get-StorageSubSystem -FriendlyName cluster*) -CanPool $true)
}
New-StoragePool @params
}