Skip to content

Instantly share code, notes, and snippets.

@flandersen
flandersen / mikrotik-update-noip.md
Created March 8, 2024 12:44
Update DynDNS IP address with RouterOS (MikroTik router)

Update DynDNS IP address with RouterOS (MikroTik router)

API documentation of noip.com: https://www.noip.com/integrate/request

Creating the required base64-auth-string with Python:

import base64
auth_str = 'your-user:your-password'
byte_str = auth_str.encode('ascii')
auth_b64 = base64.b64encode(byte_str)
@flandersen
flandersen / boost-usb-mic.md
Created February 20, 2024 19:29
Boost USB Microphone Loudness
@flandersen
flandersen / CreateSMSA.md
Last active February 9, 2024 14:36
Creating a Secure standalone managed service account (sMSA)

Introcution

I want to run a scheduler task using an sMSA user. The user can only be used on the destination machine and the password is managed by the domain. Standalone managed service accounts (sMSAs) are managed domain accounts that help secure services running on a server.

This procedur describes how an sMSA user is created and how to assign it to a scheduler task.

Create and install sMSA user (Windows Server 2019 Version 1809)

  1. On the domain controller (DC), create the managed service account and assign it to the destination machine.
Import-Module ActiveDirectory
@flandersen
flandersen / CreateTrackGpoSchedulerTask.ps1
Last active February 12, 2024 11:41
Setup a Windows Scheduler Task for TrackGpo
#requires -RunAsAdministrator
# Note: Since the *-ScheduledTask* cmdlets are implemented as
# CDXML-based *script* modules, they only see preference vars.
# in the *global* scope - see https://github.com/PowerShell/PowerShell/issues/4568
$prevEaPref = $global:ErrorActionPreference
$global:ErrorActionPreference = 'Stop'
# Setup the scheduled task:
@flandersen
flandersen / DebugJobFailingAccessGitRepo.md
Last active February 9, 2024 09:04
Windows Task Scheduler job failed to access local git repository

Problem description

I was trying to run TrackGpo from the Windows Task Scheduler by executing the following:

Program/Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Parameter: -ExecutionPolicy Bypass -Command "Invoke-GpoTracking -GpoRepo C:\GPO_Repo -WorkingDir C:\GPO_WorkingDir"

Running the task resulted in the following error:
Task Scheduler successfully completed task "\Backup GPOs" , instance "{300bfea1-ba81-4a4a-9350-205a9fd27d76}" , action "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" with return code 2147942401.

Debugging

@flandersen
flandersen / pdfmargin.py
Created July 21, 2023 12:01
Adding printing margin to PDF files
#!/usr/bin/env python
"""
Adds a printing margin to pdf files by scaling down the content and moving it to the center.
Scale factor must be adapted to the needs.
Usage: pdfmargin.py file1.pdf file2.pdf ...
"""
import os
import sys
@flandersen
flandersen / oracle-database-recovery.txt
Created July 15, 2022 14:34
Oracle database recovery write-up
# ----------------------------------------------------------------------------------------
# Restoring the database of the development system with a backup from the live system.
# Using Trivadis BasEnv as standardization tool for setting Oracle environment variables.
# ----------------------------------------------------------------------------------------
# 1. Stop the database.
TYPE (Cluster|DG) : SID/PROCESS STATUS HOME [2021-03-18 10:01:34]
----------------------------------------------------------------------------------------
Dummy rdbms : OraDB19Home1 n/a D:\app\oracle\product\19.0.0a
@flandersen
flandersen / backup-git-repos.sh
Last active March 29, 2020 17:35
Backing up Git repositories by creating bundles and syncing them to a remote server using Rsync.
#!/bin/bash
# Author: flandersen
# Date: 29.03.2020
# https://gist.github.com/flandersen/6d33c609de80247c9059bf8c3e2ade05
#
# Backups the repositories to a backup directory and syncronizes
# the backup dir to a backup server using rsync.
#
# Example usage: