Skip to content

Instantly share code, notes, and snippets.

View techdecline's full-sized avatar

Cornelius Schuchardt techdecline

View GitHub Profile
@techdecline
techdecline / Resolve-DnsLogEntry.ps1
Created December 7, 2020 08:02
Parse DNS Debug Log File and return PSCustomObject with given Property List
function Resolve-DnsLogEntry {
param (
[String]$DnsLogLine
)
$PropertyList = @{
Date = 0
Time = 1
ThreadID = 2
Context = 3
function Get-DockerInfo {
$rtnObj = New-Object PSCustomObject
if (Get-Command "docker" -ErrorAction SilentlyContinue) {
$dockerArr = (docker version 2>0) -split '\n' | Select-Object -First 2 | ForEach-Object {($_ -replace "^.*:").trim()}
foreach ($dockerProp in $dockerArr) {
switch -regex ($dockerProp) {
"^Docker.*" {
$rtnObj | Add-Member -MemberType NoteProperty -Name "DockerName" -Value $dockerProp
}
"^\d{2}\.\d{2}\.\d{2}" {
# Variables
###########
$siteServerName = "CMTP_Server1"
$domainLDAP = "dc=decline,dc=lab"
# System Management Container
#############################
New-ADObject -Name "System Management" -Type Container -Path ("Cn=system," + $domainLDAP)
function Get-ThumbprintFromCertFile {
param (
[Parameter(Mandatory)]
[ValidateScript({Test-Path $_})]
[ValidatePattern(".*\.cer")]
[String]$CertificatePath
)
$CertificatePath = (Get-Item $CertificatePath).FullName
try {
#Requires -Version 3.0
# Configure a Windows host for remote management with Ansible
# -----------------------------------------------------------
#
# This script checks the current WinRM (PS Remoting) configuration and makes
# the necessary changes to allow Ansible to connect, authenticate and
# execute PowerShell commands.
#
# All events are logged to the Windows EventLog, useful for unattended runs.
[CmdletBinding()]
param (
# Path to share
[Parameter(Mandatory=$True)]
[string]
$FilePath,
# Log File Path
[Parameter(Mandatory=$false)]
[ValidateScript({Test-Path $_ })]
param (
[Parameter(Mandatory)]
[String]$Pkcs12String,
[Parameter(Mandatory=$false)]
[ValidateSet("CurrentUser","LocalMachine")]
[String]$CertificateStoreLocation = "LocalMachine",
[Parameter(Mandatory=$false)]
[String]$CertificateStoreName = "My"
#Requires -RunAsAdministrator
param (
# ISO Path
[Parameter(Mandatory)]
[ValidateScript({Test-Path $_})]
[String]
$IsoPath,
# Language Pack ISO
param (
# Log File Location
[Parameter(Mandatory=$false)]
[ValidateScript({Test-Path $_})]
[string]
$LogFilePath = $env:TEMP,
# Policy ID
[Parameter(Mandatory=$false)]
[string]
function New-AzureUniqueName {
param ($prefix,$NameLength = 24)
$length = $prefix.length
if ($length -ge $NameLength) {
throw "Name prefix too long"
}
else {
$fillUnique = ((New-Guid).toString() -replace "-","").Substring(0,($NameLength-$length))
}