Code base

Code base for PowerShell scripting, PHP, ASP/VBScript, ASP.NET/C#, ASP.NET Core, Perl, code snippets and examples. Snippets are small pieces of reusable code.

AppCmd introduction and examples

AppCmd.exe is a command-line utility to manage Windows Server IIS 7+ web servers. The AppCmd command is your one-stop-shop for administering Windows Server IIS web servers. In combination with WinRM it’s your Swiss Army knife for your daily routine. This post introduces appcmd and provides you with a lot of helpful appcmd examples.

PowerShell 5.0

Get Hyper-V guest serial number with PowerShell

Learn how to retrieve the Hyper-V virtual machine’s serial number with PowerShell. Sometimes you need to have the serial number of a Hyper-V virtual machine (VM, or guest). We, for instance, use this serial number in our automatic, unattended deployment of the guest operating system. But then you need to know how to find this serial number…

Monitor Windows services with PowerShell

How to monitor Windows Servers with PowerShell. As a Windows Server and IIS administrator, you want your Windows services to run at all times. One can monitor Windows services in many, many, ways. Some of our customers websites may depend on certain services, which may be hard to monitor externally. For those Windows services that need local monitoring, I like to schedule a PowerShell script. Here is one…

Image of a phone book. Domain Name Servers (DNS) are the Internet's equivalent of a phone book

WMI/netsh to add DNS servers on network adapters

How to add DNS servers -or resolvers- to a Windows Server network adapter, or interface using WMI and the netsh command. This one is quite old but may come in handy sometimes. In this example we use Google’s Public DNS server addresses and localhost to add as DNS Servers on our server.

How to set a good PHP realpath_cache_size

Learn how to set a good PHP realpath_cache_size and optimize your PHP performance. . Increasing realpath_cache_size might greatly improve PHP performance, as PHP states: “this value should be increased on systems where PHP opens many files.” Setting a correct value for PHP realpath_cache_size can greatly improve PHP performance and optimize WordPress – and other CMS’s – websites.

black traffic light under blue sky

Redirect old URL to new URL or send 404 page with PHP

Redirect pages with PHP. If you’ve moved some old PHP pages, or URLs, to new pages and URLs, you can use the following PHP code snippet to easily redirect all visitors and incoming requests to the new location. This PHP code snippet uses a 301 Moved Permanently redirect, perfect for SEO.

Check website availability with PHP and cURL

Perform a PHP cURL request to check if your website is up or not. Verify your website’s online status and availability using just PHP. This script comes in handy because website uptime and availability is important, and you want your website to be always online available. If your website is down, it’ll send you an email to notify you about downtime.