Skip to content

Instantly share code, notes, and snippets.

@NiceRath
NiceRath / sphinx_create_modify_timestamps_git.sh
Last active April 8, 2025 14:15
Sphinx - Add Create/Modify Timestamps (GIT-REPO)
# SCRIPT 1:
# BUILDS LIST OF FILE-to-TIMESTAMP CSV
# EXECUTE IN GIT REPO
# NOTE: if you also build the docs on your source-system, you can merge it with script #2
#!/usr/bin/env bash
set -e
cd "$(dirname "$0")"
@NiceRath
NiceRath / sphinx_create_modify_timestamps.sh
Last active April 8, 2025 13:49
Sphinx - Add Create/Modify Timestamps (SEE LINK FOR GIT-REPO)
#!/usr/bin/env bash
# FOR GIT SUPPORT: https://gist.github.com/NiceRath/0f1e20bef3d0eea993f7439bc8fc96e6
# NOTE: you might need to change '/contentinfo\">' to whatever element you want to append the timestamps to
set -e
cd "$(dirname "$0")"
rm -rf build
@NiceRath
NiceRath / sendmail.py
Created January 21, 2025 17:01
Python3 sendmail cli with attachment
#!/usr/bin/env python3
import smtplib
from email.message import EmailMessage
from pathlib import Path
from os.path import basename
from argparse import ArgumentParser
REQUIRE_FROM_DOMAIN = '@test.com'
@NiceRath
NiceRath / mssql-agent-job-monitoring.txt
Created December 22, 2024 08:31
How to Monitor MSSQL Agent-Jobs
# discover all existing agent-jobs
SELECT name, step_name, jobs.job_id FROM msdb.dbo.sysjobsteps job_steps INNER JOIN msdb.dbo.sysjobs jobs ON jobs.job_id = job_steps.job_id
# get status for each job
SELECT subsystem, database_name, command, last_run_outcome, last_run_duration, last_run_date, last_run_time FROM msdb.dbo.sysjobsteps WHERE step_name = '{#STEP_NAME}' AND job_id = '{#JOB_ID}'
# check the status and trigger if not ok
## json query: $..last_run_outcome.first()
## error if last_run_outcome=0
@NiceRath
NiceRath / pve-shutdown-all-vms-cts.sh
Last active December 21, 2024 09:13
Proxmox - Shutdown all VMs and Containers
#!/bin/bash
vms="$(qm list | sed 's|^\s*||g' | cut -d ' ' -f1 | tail -n +2)"
for vm in $vms
do
echo "Shutdown vm $vm"
qm shutdown "$vm"
done
cts="$(pct list | sed 's|^\s*||g' | cut -d ' ' -f1 | tail -n +2)"
@NiceRath
NiceRath / windows-rds-temp-user-fw-rule-cleanup.ps1
Last active October 5, 2024 10:09
Windows RDS - Script to gracefully reboot the server (notify users)
# Task Scheduler
# General
# Use local service-user of SYSTEM
# Enable 'Run whether user is logged in or not'
# Enable 'Do not store password'
# Enable 'Run with highest privileges'
#
# Action
# Program: C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
# Arguments: -File C:\scripts\GracefulReboot.ps1
@NiceRath
NiceRath / windows-rds-temp-user-fw-rule-cleanup.ps1
Last active October 5, 2024 10:06
Windows RDS - Script to scheduled remove temporary user-firewall-rules
# Task Scheduler
# General
# Select user SYSTEM (admin user will not work correctly)
# Enable 'Run with highest privileges'
#
# Action
# Program: C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
# Arguments: -File C:\scripts\RemoveUserFWRules.ps1
# NOTE: to get the rule-names you need to execute 'Get-NetFirewallRule' as SYSTEM-USER - some rules have other display-names in that context..
@NiceRath
NiceRath / windows-rds-temp-profile-cleanup.ps1
Last active October 5, 2024 10:05
Windows RDS - Script to scheduled clean-up temporary user profiles
# Task Scheduler
# General
# Use local service-user of SYSTEM
# Enable 'Run whether user is logged in or not'
# Enable 'Do not store password'
# Enable 'Run with highest privileges'
#
# Action
# Program: C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
# Arguments: -File C:\scripts\rds\RemoveTmpProfiles.ps1
@NiceRath
NiceRath / ssl-validate.sh
Last active October 14, 2024 20:26
Script to validate certificate of service
#!/bin/bash
if [ -z "$1" ]
then
echo 'Provide the target hostname!'
exit 1
fi
TARGET="$1"
@NiceRath
NiceRath / ssl-ocsp-check.sh
Created September 30, 2024 15:33
Script to check if website has OCSP enabled or issues with it
#!/bin/bash
if [ -z "$1" ]
then
echo 'Provide a hostname of a website to check!'
exit 1
fi
if [ -z "$2" ]
then