Codebase
The Codebase category is a curated repository of scripts, snippets, and programming insights designed to automate the mundane and solve the complex. Rather than generic examples, these posts focus on functional logic in PowerShell, PHP, Python, and Batch—tailored for system administrators and DevOps engineers who need code that works in production environments.
From deep-dives into regular expressions and API integrations to optimizing legacy scripts for modern kernels, this section serves as a technical reference for building more efficient workflows. Whether you are refactoring a deployment script or debugging a niche environment variable, you’ll find the practical code blocks and logic needed to bridge the gap between development and operations.
Use PowerShell with SSL client certificates for HTTPS GET requests
Use a specific TLS certifictate or thumbprint for outgoing HTTPS connections because of endpoint restrictions using PowerShell.
Test open TCP ports with PowerShell
Learn how to use PowerShell Test-NetConnection to test if a TCP port is open
Send email with PowerShell
Easily send your DevOps reporting by email with this PowerShell function, because the Send-MailMessage cmdlet is obsolete. Of course you'll be using StartTLS and authenticated SMTP as additional security.
Removing phantom application folders from website configuration in IIS
Remove application folders from the website configuration in IIS whose physical path on the filesystem was removed, using PowerShell
How to fix System.Collections.Generic.KeyNotFoundException “The given key was not present in the dictionary” Exception with MySQL Connector/NET and utf8mb4 character set
MySQL Connector/NET and utf8mb4 character set can cause an exception System.Collections.Generic.KeyNotFoundException "The given key was not present in the dictionary".
ASP and ASP.NET connectionstring examples for Microsoft SQL Server and MySQL
Modern connection string examples for ASP.NET Core, Legacy ASP.NET, and Classic ASP. Learn how to use MSOLEDBSQL, ODBC 18, and fix MySQL UTF-8/Emoji support.
MySQL Connector/ODBC C# test script
Whenever you need to test your ASP.NET connection to your MySQL database, using ODBC, you can use the following C# test script. Currently it uses MySQL ODBC 8.0 Unicode Driver, but you can easily change the version used
Get current number of FTP client connections (NonAnonymous) with PowerShell and Get-Counter
Get the current number of active FTP client connections on your Windows Server IIS FTP Service using the Get-Counter cmdlet and the Microsoft FTP Service Current NonAnonymous Users performance counter.
Simple PowerShell introduction for Windows Server administration, automation and scripting
Windows PowerShell is an important tool in Windows Server for administrators. You can use PowerShell for Windows Server administration, software installation, automation, and shell/command-prompt scripting.
PowerShell return value, exit code, or ErrorLevel equivalent
Here is how you can verify whether an external command in PowerShell was executed successfully or not by checking its errorlevel. Simply by verifying the PowerShell exit code using the $? operator or $LASTEXITCODE.
Use authenticated SMTP over TLS encrypted connections, in PHP, ASP and ASP.NET
Send mail over authenticated SMTP using TLS, in PHP, ASP and ASP.NET. Send email securely from your website. Ready to use examples!
Find all files owned by a particular user using PowerShell
Sometimes you need to find all files owned by a specific user, recursively on your Windows Server NTFS file system. PowerShell has some neat cmdlets to automate this task for you and here is how.
Test SMTP authentication and StartTLS
Investigate SMTP authentication issues like a boss! When using TLS encrypted SMTP connections, it's always handy if you are able to create a SMTP logon credentials and test SMTP authentication over a TLS/StartTLS connection. Preferably from your command-prompt.
Set or remove the read-only attribute assigned to files with PHP chmod
Change file attributes with PHP chmod to make files read-only or normally accessible on Windows Server IIS.
Add (custom) headers to MailMessage class
The System.Net.Mail Namespace leaves out the required Message-ID header in email. Here is how you can add this important header to your email, to make sure email arrives.
Connect to multiple MySQL servers in a for and foreach loop
Check the connectivity of multiple MySQL servers, and connect to the servers in a loop. Here are two example code snippets
Test MySQL database connectivity with MySql.Data.MySqlClient
MySql.Data.MySqlClient ASP.NET test script
Optimize all MySQL tables with MySQLi multi_query
PHP MySQLi extension supports multiple queries which are concatenated by a semicolon. We can use this to optimize all MySQL tables in one single multi_query statement.
Add websites and application pools to IIS with PowerShell, in a for loop
How to use PowerShell to add websites and application pools in IIS