Here is how you can verify whether an external command in PowerShell was executed successfully or not by its errorlevel. Simply by verifying PowerShell’s return value, or exit code…Read More »PowerShell return value, exit code, or ErrorLevel equivalent
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…Read More »Get Hyper-V guest serial number with PowerShell
How to tunnel Remote Desktop (RDP) over SSH with PuTTY.
Have you ever been in a situation where you needed to perform remote administration on a Windows Server, and the RDP port 3389 is blocked on a firewall? Did you know you can tunnel RDP over SSH with PuTTY? This particularly comes in handy when there is no VPN available to the remote network… Here is how to set up a RDP SSH tunnel with PuTTY.Read More »Tunnel RDP through SSH & PuTTY
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…Read More »Monitor Windows services with PowerShell
To get and set File Server Resource Manager NTFS quota, you now have to use PowerShell‘s FileServerResourceManager cmdlets. In the past, I used to get and set NTFS directory quota with the
dirquota command, which is deprecated. A behavioral change for me (and you?) I can live with: it’s pretty easy to get directory information with
Get-FsrmQuota and change dirquota using
By default, an IIS application pool (or “AppPool”) recycles on a regular time interval of 1740 minutes, or 29 hours. One reason for this time interval is that application pools don’t recycle at the same moment every day (every day at 07.00 for example). However, sometimes you want to change this regular time interval to a specific time schedule. And when you try to configure this in IIS Manager, it gives you an error. Luckily, AppCmd and PowerShell come to the rescue!Read More »Set IIS Application Pool recycle defaults to Specific Times, not Regular Time Interval
In my environment, I had to set up a new Windows Deployment Services (WDS) configuration for Windows 8.1 Enterprise. To roll out in our office (some 20+ workstations). I wanted to install some additional software at the same time, without using Microsoft Deployment Workbench, because I find the interface too slow. The solution? Read on…Read More »Software deployment through WDS
Find all files from one owner in Windows using PowerShell
In Windows, you sometimes need to find all files owned by a specific user. Recursively on your Windows Server NTFS file system. PowerShell has some nice cmdlets and features to automate this task for you. Here you’ll find example PowerShell scripts to find and list files owned by a specific user…Read More »PowerShell: find all files owned by a particular user
Over time, as your Windows Server runs longer, more and more disk space is eaten. Simply gone! Investigating the disk usage leaves you clueless; there are no large log files, crash dumps, or there is no software to be removed. Where did that space go?
The answer: Windows Updates, Service Pack, and hotfix installations.Read More »Disk Cleanup in Windows Server
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.
When a Windows Communications Foundation (WCF) web service returns a 404 Not Found error, after installing the HTTP-Activation feature in IIS, you might need to add an extra Handler to your IIS configuration.Read More ».svc WCF web service returns 404 Not Found on IIS 8
Simple MySQL connection test from your website with ASP.NET, PHP & classic ASP. Whenever you need a MySQL connectivity test from a website or server, it’s handy to have various test scripts nearby. Whether it is because you are setting up a new website or you have just installed a new server and are running your tests.Read More »How to: Test MySQL database connectivity in ASP.NET, PHP, ASP
The Forfiles command on Windows selects and executes a command on a file or set of files. Forfiles is ideal for batch processing through scripts. For instance on Windows Server systems. With Forfiles, you can run a command on or pass arguments to multiple files. For example, you could run the
type command on all files in a tree with the
.txt extension. Or you could execute every batch file (
*.bat) on drive C, with the file name “Myinput.txt” as the first argument.
How to use PowerShell to create websites and application pools in IIS… A client of the company I work for wanted to quickly add 60 sub-domains to his website. But, the sub-domains had to be created as self contained IIS websites, and running in their own application pools. Luckily, the client wanted 60 consecutive sub-domain names, e.g. “sub01.example.com”, “sub02.example.com”, …, … up till “sub60.example.com”. This made our task a bit easier, because we could easily script this in PowerShellRead More »Add websites and application pools to IIS with PowerShell, in a for loop