Skip to content

Instantly share code, notes, and snippets.

View JaekelEDV's full-sized avatar
🎯
Focusing

@JaekelEDV JaekelEDV

🎯
Focusing
View GitHub Profile
@JaekelEDV
JaekelEDV / New-LabVM.ps1
Last active August 28, 2018 13:27
Powershell Script Create Lab VM based on Master VHDx
<#
.SYNOPSIS
Function New-LabVM quickly creates VM on Hyper-V for Lab Environments
.DESCRIPTION
This Script creates a Windows Server 2016, Windows Server 2012 R2 or Windows 10 Generation 2 VM
with differencing disk based on existing Master-VHDx you have to create before executing this one.
Be sure to adjust paths in the "Parameter Section Region" according to your environment.
It connects to an existing external vSwitch to activate the License.
The VM starts automatically.
.PARAMETER OSType
@JaekelEDV
JaekelEDV / New-LabCert.ps1
Last active February 9, 2018 07:36
Powershell Script Create Selfsigned Certificate for Labs
<#
.SYNOPSIS
Function New-LabCert creates a selfsigned computercertificate for lab environments
.DESCRIPTION
This script creates a selfsigned computercertificate for lab environments. It is stored in cert:\localmachine\my
and from there it is exported as a pfx-file to c:\. This file then gets imported in 'Trusted Roots' to make it trustworthy.
Finally some cleanup is performed, e.g. the pfx-file will be deleted.
Please consider to run it with the -verbose parameter to receive some informative output.
.PARAMETER DNSName
This is the only but mandatory parameter. Please enter the DNSHostname of the machine you want this certificate for.
@JaekelEDV
JaekelEDV / Get-MACVendor.ps1
Last active January 30, 2018 20:36
Powershell Script to get Vendor of given MAC-Address via WebAPI
<#
.SYNOPSIS
Function Get-MACVendor returns the vendor for a given MAC-Address.
.DESCRIPTION
This script uses the API of https://macvendors.co. With Invoke-WebRequest (hence Version 3.0 is needed) it generates an output as xml.
.PARAMETER MAC
This is the only but mandatory parameter. Please enter a valid MAC-Address.
It works both with colons or hyphens - you decide.
.EXAMPLE
Execute Get-MACVendor.ps1 directly from shell with dot sourcing
@JaekelEDV
JaekelEDV / Get-Sysinternals.ps1
Created December 14, 2017 21:43
Powershell Script to download SysinternalsSuite
<#
.SYNOPSIS
Function Get-Sysinternals downloads Sysinternals Suite to a local folder.
.DESCRIPTION
Get-Sysinternals will
- download the SysinternalsSuite.zip
- unblock it
- and decompress it to c:\sysinternals
Check the Parameter Section for your desired paths!
Using the .NET Class System.Net.WebClient for faster download.
@JaekelEDV
JaekelEDV / LabUser.csv
Last active February 22, 2018 21:23
Powershell Script to create LabUsers based on csv-file
Name SamAccountName UPN GivenName Surname DisplayName EmailAddress Group Department
Jasper Beardley Jasper jasper@test.local Jasper Beardley Jasper Beardley jasper@test.local Retired Retired
Patty Bouvier Patty patty@test.local Patty Bouvier Patty Bouvier patty@test.local Bouvier Bouvier
Selma Bouvier Selma selma@test.local Selma Bouvier Selma Bouvier selma@test.local Bouvier Bouvier
Kent Brockman Kent kent@test.local Kent Brockman Kent Brockman kent@test.local
Charles Montgomery Burns Charles Montgomery monty@test.local Charles Montgomery Burns Charles Montgomery Burns monty@test.local Powerplant Powerplant
Carl Carlson Carl carl@test.local Carl Carlson Carl Carlson carl@test.local Powerplant Powerplant
Maude Flanders Maude maude@test.local Maude Flanders Maude Flanders maude@test.local Flanders Flanders
Ned Flanders Ned ned@test.local Ned Flanders Ned Flanders ned@test.local Flanders Flanders
Rod Flanders Rod rod@test.local Rod Flanders Rod Flanders rod@test.local Flanders Flanders
@JaekelEDV
JaekelEDV / Test-AdDnsRR.ps1
Created February 11, 2018 16:40
Powershell script checking for AD-relevant DNS Resource Records in DNS
#This script checks if all AD-relevant SRV-Records exist in DNS. Also it looks for netlogon.dns and the A-Record for the DC.
$Domain = (Get-ADDomain).DNSRoot
$DCName = (Get-ADDomainController).Name
$msdcs = (Get-DnsServerResourceRecord -ZoneName _msdcs.$Domain -RRType Srv)
$ARR = (Get-DnsServerResourceRecord -ZoneName $Domain -RRType A)
$PDC = [string] "_ldap._tcp.pdc"
$GC = [string] "_ldap._tcp.gc"
$KDC = [string] "_kerberos._tcp.dc"
$DC = [string] "_ldap._tcp.dc"
@JaekelEDV
JaekelEDV / New-ADSnapshot
Created February 13, 2018 15:31
Powershell Script to create daily scheduled task for AD snapshots
#region Check if System is DC and logged-on user is admin
$DomainRole = Get-WmiObject -Class Win32_ComputerSystem | Select-Object -ExpandProperty DomainRole
if( $DomainRole -match '4|5' )
#0=StandaloneWorkstation, 1=MemberWorkstation, 2=StandaloneServer, 3=MemberServer, 4=BackupDC, 5=PrimaryDC
{Write-Host 'Check: Machine is DC' -ForegroundColor Green}
else
@JaekelEDV
JaekelEDV / Export-MyVM.ps1
Created February 19, 2018 18:58
Powershell Script to export VMs with dynamic parameters
<#
.SYNOPSIS
The Function Export-MyVM extends the standard cmdlet Export-VM with dynamic parameters.
.DESCRIPTION
The Script makes the search for the VMs and the Export-Destination-Drive dynamic.
You can simply tab through the two mandatory parameters to get (a) all VMs on the Hyper-V-Host and (b) all connected drives.
Frankly, the main purpose was to learn dynamic parameters.
.PARAMETER VMName
Tab out all VMs on the Hyper-V-Host.
It's a positional (1) and mandatory parameter.
@JaekelEDV
JaekelEDV / New-LabRootCA.ps1
Created March 17, 2018 19:11
Powershell Script to install and configure a standalone RootCA for Lab-Environments
<#
.SYNOPSIS
Script to install and configure a standalone RootCA for Lab-Environments
.DESCRIPTION
This Script sets up a standalone RootCA. It's main purpose is to save time when building Labs in the classes I teach.
###It's not meant for production!###
First, it creates a CAPolicy.inf file. Then it deletes all default CDP and AIA and configures new ones.
It turns on auditing and copys (It's a Lab!!!, so obviously no real offline RootCA...) the crt and crl to an edge webserver.
.NOTES
Author: Oliver Jäkel | oj@jaekel-edv.de | @JaekelEDV
#requires -Version 3.0
Function Get-PublicIP {
Invoke-RestMethod -Uri http://ipinfo.io/json | Select-Object -ExpandProperty 'ip'
}
#THX, @ipinfoio, https://ipinfo.io/developers