Skip to content

Instantly share code, notes, and snippets.

View Digiover's full-sized avatar
💭
☕️

Jan Reilink Digiover

💭
☕️
View GitHub Profile
@Digiover
Digiover / add-aspnet-gctrimcommitonlowmemory.ps1
Created February 22, 2024 09:19
Add gcTrimCommitOnLowMemory runtime Aspnet configuration
# https://www.saotn.org/aspnet-performance-what-to-keep-in-mind/#highdensitywebhosting
$bitness = @("64", "")
foreach ($bits in $bitness) {
$xml = New-Object xml
$xml.Load("C:\Windows\Microsoft.NET\Framework${bits}\v4.0.30319\Aspnet.config")
# Check whether the runtime control gcTrimCommitOnLowMemory is already registered
$nodeGcTrimCommitOnLowMemory = $xml.SelectSingleNode("configuration/runtime/gcTrimCommitOnLowMemory")
@Digiover
Digiover / add-aspnet-highdensitywebhosting-performancescenario.ps1
Last active February 22, 2024 09:07
Add Aspnet.config HighDensityWebHosting performanceScenario
# https://www.saotn.org/aspnet-performance-what-to-keep-in-mind/#highdensitywebhosting
$bitness = @("64", "")
foreach ($bits in $bitness) {
$xml = New-Object xml
$xml.Load("C:\Windows\Microsoft.NET\Framework${bits}\v4.0.30319\Aspnet.config")
# Check whether HighDensityWebHosting performanceScenario is already registered
$nodePerformanceScenario = $xml.SelectSingleNode("configuration/performanceScenario")
@Digiover
Digiover / iis-discover-websites.ps1
Created February 6, 2024 09:34
Zabbix auto discovery for IIS websites
# Query Win32_PerfRawData_W3SVC_WebService for all metric labels (names), including all website names hosted in IIS
#
# The Web Service object includes counters specific to the World Wide Web Publishing Service.
(Get-CimInstance -EA SilentlyContinue -Query "select * from Win32_PerfRawData_W3SVC_WebService" -Namespace root\cimv2).Name
# https://www.saotn.org/monitor-website-performance-in-iis-with-zabbix/
@Digiover
Digiover / Get-RandomString.ps1
Created June 7, 2023 08:27
Easily create a random string (or secure password) using PowerShell. Add to your PS profile
# Add to your PS profile to create random strings / secure passwords
# from within your PowerShell shell.
#
# Source / Author: Daniel Kåven
# https://teams.se/powershell-script-generate-a-random-password/
function Get-RandomString {
param (
[CmdletBinding(PositionalBinding=$false)]
[Parameter(Position=0)]
[ValidateRange(8, 256)]
@Digiover
Digiover / Import-PfxCertificateAutomation.ps1
Created June 7, 2023 08:21
Import a PFX certificate into Windows Server and change its FriendlyName property in PowerShell
# Import a PFX certificate into Windows Server and change its
# FriendlyName property in PowerShell.
#
# Using Get-Credential here ensures the password doesn't get saved
# into PowerShell's history file.
# -- see https://www.saotn.org for more PowerShell goodness :)
#
$CommonName = "CHANGEME"
$CertFileName = "CHANGEME.pfx"
@Digiover
Digiover / Ansible: Use a custom ssh config file
Created April 12, 2023 22:08
Configure and use a custom ssh config file with Ansible in Windows WSL 2
# Ansible can use a custom ssh config file if you configure its
# ANSIBLE_SSH_ARGS environment variable. Add to your `~/.bashrc`
#
# source: Windows 11/10 and WSL 2 DevOps environment
# - Sysadmins of the North
# https://www.saotn.org/windows-11-10-and-wsl-2-devops-environment/
#
export ANSIBLE_SSH_ARGS="-F ~/.ssh/wsl_config"
@Digiover
Digiover / cleanup-wordpress-database.sql
Created March 8, 2023 10:48
Clean up WordPress meta data, like comment and post meta. Don't forget to set your table prefix
-- Clean WordPress Post Meta Data
SELECT * FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;
DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;
-- Clean WordPress Comment Meta Data
SELECT * FROM wp_commentmeta WHERE comment_id NOT IN ( SELECT comment_id FROM wp_comments );
DELETE FROM wp_commentmeta WHERE comment_id NOT IN ( SELECT comment_id FROM wp_comments );
SELECT * FROM wp_commentmeta WHERE meta_key LIKE '%akismet%';
DELETE FROM wp_commentmeta WHERE meta_key LIKE '%akismet%';
@Digiover
Digiover / README.md
Last active December 4, 2021 09:26 — forked from emnavarro02/README.md
Re-index the WSUS Database

The performance of large Windows Server Update Services (WSUS) deployments will degrade over time if the WSUS database is not maintained properly. The WSUSDBMaintenance script is a T-SQL script that can be run by SQL Server administrators to re-index and defragment WSUS databases. It should not be used on WSUS 2.0 databases.This script contributed by the Microsoft WSUS team.

If you are using Windows Internal Database, you will need to use the sqlcmd utility, which can be downloaded from docs.microsoft.com page for SQLCMD. This page will also contain additional information about the sqlcmd utility.

To use this script with Windows Internal Database, you should run the following command:

sqlcmd -S np:\\.\pipe\MSSQL$MICROSOFT##WID\sql\query –i <scriptLocation>\WsusDBMaintenance.sql
@Digiover
Digiover / use-http11-in-wordpress.php
Created April 30, 2020 09:24
Forces HTTP/1.1 for outgoing connections in WordPress instead of HTTP 1.0
<?php
/**
* Plugin Name: Use HTTP/1.1 in WordPress
* Plugin URI: https://www.saotn.org/
* Donate URI: https://www.paypal.me/jreilink
* Description: MU Plugin. Forces HTTP/1.1 for outgoing connections in WordPress instead of HTTP 1.0
* Network: True
* Version: 1.0
* Author: Jan Reilink
* Author URI: https://www.saotn.org
@Digiover
Digiover / saotn-flush-memcached.php
Last active November 12, 2018 12:50
Flush PHP memcacheD cache in WordPress - Flushes PHP memcached cache upon publish_post action. By clearing the opcode cache in memory you immediately can see a new or changed post
<?php
/**
* Plugin Name: Flush MemcacheD cache
* Plugin URI: https://www.saotn.org/
* Donate URI: https://www.paypal.me/jreilink
* Description: Flushes PHP memcached cache upon publish_post action. By clearing the opcode cache in memory you immediately can see a new or changed post. Use as a Must-Use Plugin.
* Network: True
* Version: 1.2
* Author: Jan Reilink
* Author URI: https://www.saotn.org