Skip to content

Instantly share code, notes, and snippets.

View tomtorggler's full-sized avatar
😁
gruntled

Thomas Torggler tomtorggler

😁
gruntled
View GitHub Profile
# 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';
# 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}}
# 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
}
# 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
}
@tomtorggler
tomtorggler / Create-NetFirewallRuleSQL.ps1
Last active February 17, 2016 08:16
Create NetFirewall Rules for SQL Server and SQL Browser executables
# 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)";