Converting the FileSystemObject's DriveExists Method
Definition: Given a specified drive letter or path, returns True if that drive exists.
DriveExists
You can use the Test-Path cmdlet to test for a drive as well as a path:
Test-Path c:
If you’re checking PowerShell drives, you can also use the Get-PSDrive cmdlet to return a list of all the drives, then check each of those drives to see if the drive letter matches the drive you’re looking for.
$letter = "C"
$d = Get-PSDrive
foreach($dr in $d)
{
if($dr.Name -eq $letter){Write-Host "drive exists"}
}
See conversions of other FileSystemObject methods and properties.
Return to the VBScript to Windows PowerShell home page