Category Archives: Scripting

PowerShell Random Password Function

Generating a password with PowerShell is relatively easy if you leverage a particular method of .Net, System.Web.Security.Membership. Add-Type -AssemblyName System.Web[System.Web.Security.Membership]::GeneratePassword(8,2) Simple and to the point. But below is a pretty good function to do something similar, if you are curious about string operations with PowerShell. function Get-RandomPassword($length){    $length-=1    $lower = ‘abcdefghijklmnopqrstuvwxyz’    $upper = $lower.ToUpper()    $number = 0..9    $special=’~!@#$%^&*()_+|}{[]\’    $chars = “$lower$special$upper”.ToCharArray() $pass = Get-Random -InputObject… Read More »

8 Useful PowerShell Quickies

In my current position, I use PowerShell quite a bit, but not just for automation of repetitive tasks. I thought I would take a few minutes to jot down a few one-offs that might be of use to other folks. Some of these might even be useful in larger scripts.

Resolving IP to Hostname with PowerShell

Getting the hostname from an IP address (or vice versa) is no great magic, and can be done easily with PowerShell, by simply leveraging .Net to do the work. We’ve all done something like this to get resolve an IP address: [System.Net.Dns]::GetHostEntry(“69.69.95.133”).HostName Or this to get an IP address from a hostname: [System.Net.DNS]::GetHostAddresses(“www.fortypoundhead.com”).IPAddressToString But did you ever notice… Read More »