Skip to content

Instantly share code, notes, and snippets.

@filipnet
filipnet / ps-wsus-export.ps1
Last active November 6, 2024 17:19
Export list of subscribed WSUS products and categories
# Export subscribed
$wsusServer = Get-WsusServer -Name $WSUS_HOSTNAME -Port 8530
$wsusSubscription = $wsusServer.GetSubscription()
$selectedProducts = $wsusSubscription.GetUpdateCategories() | Select Title
$selectedCategories = $wsusSubscription.GetUpdateClassifications() | select Title
# Export full list
(Get-WsusServer | Get-WsusClassification).Classification.Title
(Get-WsusServer | Get-WsusProduct).Product.Title
@filipnet
filipnet / remove_moto_bloatware.bat
Last active July 30, 2025 12:47
ADB Command to Uninstall Bloatware and Remove its Data
# Enable Devoloper Options
# Download E5 USB-Driver http://www.motorola.com/getmdmwin
# Minimal and Install minimal ADB and fastboot https://androidmtk.com/download-minimal-adb-and-fastboot-tool
# ADB command to search for packages
pm list packages | grep "moto"
# ADB command to uninstall Bloatware but keep data
pm uninstall -k --user 0 <package name>
# ADB command to uninstall Bloatware and remove its data
pm uninstall --user 0 <package name>
@filipnet
filipnet / export_wineventlog.ps1
Created April 14, 2023 09:02 — forked from iomoath/export_wineventlog.ps1
Powershell script to export Windows Events logs
# Logs to extract from server
$logArray = @("System","Security","Application", "Setup")
# Grabs the server name to append to the log file extraction
$servername = $env:computername
# Provide the path with ending "\" to store the log file extraction.
$destinationpath = "C:\WindowsEventLogs\"
# Checks the last character of the destination path. If it does not end in '\' it adds one.
# Script Description:
# This script safely deletes temporary files from the Windows partition, clears the Recycle Bin,
# removes the Windows Update cache, and cleans up the user's temp folder.
# Run with "powershell -ExecutionPolicy Bypass -File .\Clean-SystemDrive.ps1"
# Requires administrative privileges
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Error "Please run this script as an Administrator."
exit
}
@filipnet
filipnet / fix_deprecated_mysql_tools.sh
Last active February 16, 2025 10:25
This script updates the deprecated MySQL commands used in the automysqlbackup tool to their MariaDB equivalents. It replaces mysqldump with mariadb-dump, mysqlshow with mariadb-show, and mysql with mariadb, ensuring compatibility with newer MariaDB installations. A timestamped backup of the original file is created before applying the changes, p…
#!/bin/bash
# Script to update deprecated MySQL commands in the automysqlbackup file.
# The automysqlbackup project can be found at: https://sourceforge.net/projects/automysqlbackup/
#
# The following warnings have been observed when using automysqlbackup:
#
# mysqldump: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb-dump' instead
# mysqlshow: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb-show' instead
# mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead
@filipnet
filipnet / sync_remote_to_local.sh
Created October 31, 2024 19:55
This Bash script automates the process of synchronizing files from a remote server to a local directory using rsync. It includes options for preserving file permissions, ownership, and group ownership, while also providing options for compression, deletion of old files, and recursive copying of directories.
#!/bin/bash
# Parameters
REMOTE_PATH="/home" # Source path on the remote server
LOCAL_PATH="/mnt/sdb/" # Destination path on the local system "DO NOT REPEAT" destination folder
CERT_PATH="/root/id_rsa_root_hostname.priv.crt" # Path to the SSH certificate
REMOTE_SERVER="host.domain.com" # Hostname or IP address of the remote server
CHECK_MODE="--dry-run" # Use "--dry-run" for a dry run, leave empty for normal operation
# File permission options
@filipnet
filipnet / set_homedir_permissions.sh
Created October 31, 2024 20:26
This Bash script scans the system's /etc/passwd file to list user accounts with their real names, associated groups, and home directories. It allows filtering based on home directory names and user groups. Additionally, it can modify the ownership and permissions of home directories recursively.
#!/bin/bash
# Filter parameter for the home directory
filter_string="home"
# Optional filter parameter for the user group (default is empty)
group_filter="users"
# Default dry-run flag (true)
dry_run=true
# Function to display usage information
@filipnet
filipnet / set_temporary_password.sh
Created November 1, 2024 11:51
The set_temporary_password.sh script is designed to set a temporary password for a specified user account on a Linux system. The password will be valid for a predefined duration, after which it will expire. Users can define parameters such as the username, expiration time in minutes, and the desired password length. The script also verifies the …
#!/bin/bash
# Define parameters at the top
USERNAME="max.mustermann" # Username for which to set the password
USER_PASSWORD="" # Leave empty to generate a password automatically
EXPIRATION_MINUTES=60 # Password expiration time in minutes
PASSWORD_LENGTH=6 # Length of the generated password
USE_SPECIAL=false # Set to false to exclude special characters in the password
# Function to check if the user exists and provide output
@filipnet
filipnet / generate-pkg-report.sh
Created November 17, 2024 17:48
This script checks for available system updates, reports if a reboot is required, lists enabled repositories, and sends an email notification to specified recipients with the update details.
#!/bin/bash
# Configuration: Define recipients (space-separated emails)
RECIPIENTS="administrator@example.com"
# Constants
DASHES="##############################"
# Function: Check for updates
check_updates() {
@filipnet
filipnet / check_service_syntax.sh
Last active December 11, 2024 21:16
This script checks the configuration syntax of various services on a Linux system. It executes predefined check commands for each service, verifies the output, and reports whether the service configuration is valid or not. The script supports common services like Nginx, Apache, SSH, and others. The script is easily expandable—services can be add…
#!/bin/bash
# ===========================
# Service Configuration
# ===========================
# Format: "<Service Name>;<Check Command>;<Expected String>"
SERVICES=(
"apache;apachectl configtest;Syntax OK"
#"haproxy;haproxy -c -f /etc/haproxy/haproxy.cfg;Configuration file is valid"
"nginx;nginx -t;syntax is ok"