Skip to content

Instantly share code, notes, and snippets.

View norman-bauer's full-sized avatar

Norman Bauer norman-bauer

View GitHub Profile
$bootevents = Get-WinEvent -FilterHashtable @{logname="Microsoft-Windows-Diagnostics-Performance/Operational"; id=100}
$bootevent = [xml]$bootevents[0].ToXml()
$bootevent.Event.EventData.Data
$shutdownevents = Get-WinEvent -FilterHashtable @{logname="Microsoft-Windows-Diagnostics-Performance/Operational"; id=200}
$shutdownevent = [xml]$shutdownevents[0].ToXml()
$shutdownevent.Event.EventData.Data
@norman-bauer
norman-bauer / Convert-CertificateToPEM
Created April 11, 2022 11:20
Converts certificate installed in machine store to pem file
Install-Module -Name PSPKI
Import-Module -Name PSPKI
$cert = @(Get-ChildItem cert:\LocalMachine\My | Where-Object {$_.Subject -like "*CertificateSubject*"})[0]
Convert-PfxToPem -Certificate $cert -OutputFile "c:\temp\output.pem"
$username = "typeusernamehere"
[datetime]::FromFileTime((Get-ADDomainController -Filter * | foreach {Get-ADUser $username -Properties LastLogon -Server $_.Name | select LastLogon} | Measure-Object -Property LastLogon -Maximum).Maximum)
@norman-bauer
norman-bauer / Connect-Azure.ps1
Created May 3, 2023 20:21
Install and import Azure Module, then connect to Azure.
Install-Module -Name Az -AllowClobber -Scope CurrentUser
Import-Module Az
Connect-AzAccount
@norman-bauer
norman-bauer / AzureToFritzBoxVPN.cfg
Created May 3, 2023 19:33
Configuration file for FRITZ!Box to create a site-to-site VPN with Azure.
vpncfg {
connections {
enabled = yes;
conn_type = conntype_lan;
name = "AzureToFritzBoxVPN";
always_renew = no;
reject_not_encrypted = no;
dont_filter_netbios = yes;
localip = 0.0.0.0;
local_virtualip = 0.0.0.0;
@norman-bauer
norman-bauer / Create-AzureLocalNetworkGatewayUsingFQDN.ps1
Last active May 3, 2023 19:11
Create a Local Network Gateway in Azure using FQDN. Doing so in the portal leads to an error.
New-AzLocalNetworkGateway -Name AzureToFritzBoxVPN-LNG -ResourceGroupName AzureToFritzBoxVPN-RG -Location "West Europe" -fqdn "argq6adasd23ruo.myfritz.net" -AddressPrefix "10.1.1.0/24"
@norman-bauer
norman-bauer / Install-VMM2022UR1.ps1
Created March 20, 2023 10:58
Stops VMM Services, installs UR1 update and checks file version.
Stop-Service SCVMMService
Stop-Service SCVMMAgent
C:\temp\kb5019202_vmmserver_amd64.msp
C:\temp\kb5019203_AdminConsole_amd64.msp
(Get-Item "C:\Program Files\Microsoft System Center\Virtual Machine Manager\bin\vmmservice.exe").VersionInfo
@norman-bauer
norman-bauer / Raise-FsrmReportLimits.ps1
Last active January 11, 2023 09:35
This script helps raising certain File Server Resource Manager Report limits.
$fsrm = New-Object -ComObject "Fsrm.FsrmReportManager"
enum FsrmReportLimit {
MaxFiles = 1
MaxFileGroups = 2
MaxOwners = 3
MaxFilesPerFileGroup = 4
MaxFilesPerOwner = 5
MaxFilesPerDuplGroup = 6
MaxDuplicateGroups = 7
@norman-bauer
norman-bauer / Configure-DHCPOption119OnScope.ps1
Last active December 31, 2022 08:24
Asks for a list of semicolon separated domain suffixes and a Windows Server DHCP Scope Id on which Option 119 will be configured accordingly
$domainSearchList = Read-Host "Please enter a list of domain suffixes separated by semicolons (e.g. domain.local;domain.tld;int.domain.tld)"
$scopeToConfigure = Read-Host "Please enter the scope id of the scope to be configured (e.g. 192.168.1.0)"
$splittedDomainSearchList = $domainSearchList -split "\;"
$domainSearchListHexArray = @();
Foreach ($domain in $splittedDomainSearchList)
{
$splittedDomainParts = $domain -split "\."
Foreach ($domainPart in $splittedDomainParts)
@norman-bauer
norman-bauer / Unarchive-Certificate.ps1
Last active January 10, 2022 08:47
PowerShell script to unarchive a previously archived certificate in the local machine my store
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store "My","LocalMachine"
$store.Open(9) #ReadWrite + IncludeArchived
$store.Certificates |? Archived -eq $true
$store.Certificates |? Archived -eq $true |% {$_.Archived = $false} #Unarchive all certificates
$store.Certificates |? Subject -eq "CN=archivedcert" |% {$_.Archived = $false} #Unarchive certificates with given subject
$store.Close()