database-tools

Sorting Arrays

Let's assume you have an array of items which you would like to sort. Here is the PowerShell way: $array = 1,5,32,5,7$array | Sort-Object$array...

Analyzing URLs

URLs contain a lot of information which can be automatically parsed by PowerShell. Simply convert a URL to the System.URI type. Once you did this,...

Escaping Text Strings

HTML on web pages uses tags and other special characters to define the page. To make sure text is not misinterpreted as HTML tags, you may want to...

Checking Host Name Type

To check whether a string contains a valid host name, you can use the CheckHostName() method provided by the System.URI type. It will return...

Validating a URL

To make sure user input is a valid URL, you can use the System.URI type. Try to convert the raw string into this type. If it works, the string is a...

Reversing Array Order

To reverse the order of elements in an array, the most efficient way is to use the [Array] type and its static method Reverse(): # Create an array...

Limiting Variables to a set of values

By adding a ValidateSetAttribute to a variable, you can force it to accept only values that match a given set. Once you add this attribute in the...

Validating IP-Addresses

To check for a valid IP-address, use the .NET Framework type System.Net.IPAddress and test whether the data can be converted into this format:...

Validating Email-Addresses

To check for valid email addresses, you can use the .NET Framework type System.Net.Mail.MailAddress and test whether the data can be converted into...

Exiting a Function

To exit a function immediately, use the return statement. The next function expects a name (including wildcards) and lists all matching processes....

Quick Drive Info

Want to quickly get a number of interesting details for any drive? Use the .NET System.IO.DriveInfo class like this: New-Object System.io.DriveInfo...