This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get SQL services and path to executable | |
$services = Get-CimInstance -query 'select * from win32_service where name="sqlbrowser" or name="mssqlserver"' | |
# Create Firewall Rule for each of the services executables | |
# use splatting for better readability | |
foreach ($service in $services) { | |
$params = @{ | |
DisplayName = $service.Name; | |
Action = "Allow"; | |
Description ="Allow $($service.name)"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set Location to my working directory and import helper module for Nano Server image generation | |
Set-Location C:\Nano | |
Import-Module .\NanoServerImageGenerator.psm1 | |
# Harvest four domain join blobs for the Nano Servers. | |
# Servernames will be n01 through n04 | |
1..4 | ForEach-Object { | |
djoin /Provision /Domain vdi.local /Machine n0$_ /SaveFile n0$_.txt | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import the VHD files as WDS Install Images | |
1..4 | ForEach-Object { | |
$params = @{ | |
Path= "C:\Nano\Nano_compute_n0$_.vhd"; | |
NewImageName = "Nano-n0$_-10.0.10586" | |
} | |
Import-WdsInstallImage @params | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create CIM Sessions to the Nano Servers | |
$cimSessions = New-CimSession -ComputerName n01,n02,n03,n04 | |
# Get system uptime via CIM to verify the servers | |
$params = @{ | |
CimSession = $cimSessions; | |
ClassName = "Win32_OperatingSystem" | |
} | |
Get-CimInstance @params | Select-Object PsComputerName,@{Name='UpTime';Expression={$_.LocalDateTime - $_.LastBootUpTime}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create CimSessions to each of the servers to be configured | |
$cimSessions = New-CimSession -ComputerName n01,n02,n03,n04 | |
# foreach CimSession configure an IPv4 Address on the interface with Alias Ethernet 2 | |
# the IP Address is derived from the ComputerName property of the CimSession | |
$cimSessions | ForEach-Object { | |
$params = @{ | |
IPAddress = "192.168.1."+$PSItem.ComputerName.Substring(2,1); | |
InterfaceAlias = 'Ethernet 2'; | |
PrefixLength = '24'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 = @{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 $_ | |
} | |
} | |
} |
OlderNewer