PowerShell: Get First Open Drive Letter

Three lines of code to return the first in an array of available drive letters in the correct format for piping to New-PSDrive.

$letters = 65..90 | ForEach-Object{ [char]$_ + ":" }
$taken = Get-WmiObject Win32_LogicalDisk | select -expand DeviceID
$avail = ((Compare-Object -ReferenceObject $letters -DifferenceObject $taken)[1].InputObject).Replace(":","")
Previous
Previous

Connect Network Printer via WMI

Next
Next

PowerShell: Random Password Generator.