Skip to content

Instantly share code, notes, and snippets.

View nyanhp's full-sized avatar

Jan-Hendrik Peters nyanhp

View GitHub Profile
@nyanhp
nyanhp / FailoverFun.ps1
Created November 22, 2017 17:27
A small lab to set up two domain-joined cluster nodes with an installation of SQL Server 2016
New-LabDefinition -Name FailoverLab -DefaultVirtualizationEngine HyperV
Add-LabDomainDefinition -Name contoso.com -AdminUser Install -AdminPassword Somepass1
Set-LabInstallationCredential -Username Install -Password Somepass1
Add-LabIsoImageDefinition -Name SQLServer2016 -Path $labsources\ISOS\en_sql_server_2016_enterprise_x64_dvd_8701793.iso
$PSDefaultParameterValues = @{
'Add-LabMachineDefinition:DomainName' = 'contoso.com'
'Add-LabMachineDefinition:Memory' = 1GB
@nyanhp
nyanhp / ALPkiOps.ps1
Created November 23, 2017 13:47
Working with the lab PKI environment
# To create a lab with a PKI, check out our sample scripts, e.g. "PKI Simple.ps1" in your $labsources
Import-Lab MyPkiLab
# One-liner to enable auto-enrollment for code signing certificates for all lab users and computers
Enable-LabCertificateAutoenrollment -Computer -User -CodeSigning
# Prepare for a new template
$splat = @{
TemplateName = "MyTemplate"
DisplayName = "My awesome template"
@nyanhp
nyanhp / InvokeDscConfigs.ps1
Created November 23, 2017 13:55
Simple DSC configuration of lab machines
configuration myConfig
{
node localhost
{
File f
{
DestinationPath = "C:\HelloIAmYour.File"
Contents = "It works so well, you gotta love AutomatedLab!"
}
}
@nyanhp
nyanhp / SqlCustomization.ps1
Created November 24, 2017 10:44
SQL Installation Customizations
$labName = 'Test5'
#create an empty lab template and define where the lab XML files and the VMs will be stored
New-LabDefinition -Name $labName -DefaultVirtualizationEngine Azure
Add-LabAzureSubscription -Path D:\myazuresettings.json -DefaultLocationName 'west europe'
#make the network definition
Add-LabVirtualNetworkDefinition -Name $labName -AddressSpace 192.168.71.0/24
#and the domain definition with the domain admin account
@nyanhp
nyanhp / LabConnections.ps1
Created November 24, 2017 12:24
Interacting with lab machines
Import-Lab 'Your lab name here'
# Whether your are on Azure, Hyper-V or VMWare - one Cmdlet to rule them all!
# Enters an RDP connection to the machine of your choice
# Connection details for Azure will automatically be used: Load balancer Public IP and RDP Port
Connect-LabVm (Get-LabMachine | Select -First 1)
# Enters an interactive PSSession to your machine
# Connection details for Azure will automatically be used: Load balancer Public IP and WinRM Ports
function Get-SongOfTime()
{
[Console]::Beep("440","500") #Kammerton a, 0,5s
[Console]::Beep("293.228","1000")
[Console]::Beep("349.228","500")
[Console]::Beep("440","500")
[Console]::Beep("293.228","1000")
[Console]::Beep("349.228","500")
[Console]::Beep("440","250")
[Console]::Beep("523.251","250")
@nyanhp
nyanhp / ParamSync.ps1
Created November 29, 2017 21:33
Synchronize parameter sets
# Use AutomatedLabs little helpers in your own code aka steal our stuff
$parameterTable = @{
Name = 'PowerShell'
WeirdParameter = 'Does not compute :('
}
$nicerParameters = Sync-Parameter -Command (Get-Command Get-Process) -Parameters $parameterTable
Get-Process @nicerParameters
@nyanhp
nyanhp / Inception.ps1
Last active December 14, 2017 09:07
AutomatedLabINCEPTION
$labname = 'Inception'
New-LabDefinition -Name $labname -DefaultVirtualizationEngine HyperV
Add-LabMachineDefinition -Name DreamLayer1 -Memory 8GB -OperatingSystem 'Windows Server 2016 SERVERSTANDARDCORE'
Install-Lab
Get-Vm DreamLayer1 | stop-Vm -Passthru | Set-VMProcessor -ExposeVirtualizationExtensions $true
Start-LabVm DreamLayer1
@nyanhp
nyanhp / adreplication_part1.ps1
Last active February 22, 2018 09:36
Making sense of AD Replication Schedules
$site = Get-ADReplicationSite -Identity Toronto
$site.ReplicationSchedule.RawSchedule # Our boolean values
foreach ( $day in 0..6) # Iterate over each day of the week, starting with Sunday
{
foreach ( $hour in 0..23) # Iterate over each hour
{
foreach ( $interval in 0..3) # Iterate over each 15-min interval
{
@nyanhp
nyanhp / adreplication_part2.ps1
Created February 22, 2018 09:42
Making sense of AD Replication schedules pt 2
function Get-ADReplicationSchedule
{
[CmdletBinding()]
param
(
[Parameter(ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
[System.DirectoryServices.ActiveDirectory.ActiveDirectorySchedule]$ReplicationSchedule,
[Parameter(ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
[string]$DistinguishedName