Skip to content

Instantly share code, notes, and snippets.

View JaekelEDV's full-sized avatar
🎯
Focusing

@JaekelEDV JaekelEDV

🎯
Focusing
View GitHub Profile
filter Get-InstalledSoftware {
<#
.SYNOPSIS
Get all installed from the Uninstall keys in the registry.
.DESCRIPTION
Read a list of installed software from each Uninstall key.
This function provides an alternative to using Win32_Product.
.EXAMPLE
Get-InstalledSoftware
<#
.SYNOPSIS
Function New-LabNCSI configures a server as IIS and DNS to support
Network Connectivity Status Indicator (NCSI) scenarios for lab environments.
.DESCRIPTION
In some lab environments some machines really need to think they're on the internet,
e.g. a Direct Access scenario. Most of my labs won't have internet access b/c I like to keep the VMs "sandboxed".
This function helps you to turn a machine into a IIS- and DNS-
Server simulating Microsofts Network Connectivity Status Indicator technique.
To avoid touching the registry of the clients that will use this machine, the default MS
#requires -Version 3.0
Function Get-PublicIP {
Invoke-RestMethod -Uri http://ipinfo.io/json | Select-Object -ExpandProperty 'ip'
}
#THX, @ipinfoio, https://ipinfo.io/developers
@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 | [email protected] | @JaekelEDV
@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-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 / 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 / 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 [email protected] Jasper Beardley Jasper Beardley [email protected] Retired Retired
Patty Bouvier Patty [email protected] Patty Bouvier Patty Bouvier [email protected] Bouvier Bouvier
Selma Bouvier Selma [email protected] Selma Bouvier Selma Bouvier [email protected] Bouvier Bouvier
Kent Brockman Kent [email protected] Kent Brockman Kent Brockman [email protected]
Charles Montgomery Burns Charles Montgomery [email protected] Charles Montgomery Burns Charles Montgomery Burns [email protected] Powerplant Powerplant
Carl Carlson Carl [email protected] Carl Carlson Carl Carlson [email protected] Powerplant Powerplant
Maude Flanders Maude [email protected] Maude Flanders Maude Flanders [email protected] Flanders Flanders
Ned Flanders Ned [email protected] Ned Flanders Ned Flanders [email protected] Flanders Flanders
Rod Flanders Rod [email protected] Rod Flanders Rod Flanders [email protected] Flanders Flanders
@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 / 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