PS H:\downloads\temp2> .\Fails.ps1
DriveLetter FileSystemLabel FileSystem DriveType HealthStatus OperationalStatus SizeRemaining Size
Windows Recovery NTFS Fixed Healthy OK 1000.34 MB 1023.87 MB
DiskPath: \?\scsi#disk&ven_msft&prod_virtual_disk#2&1f4adffe&0&000004#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
PartitionNumber DriveLetter Offset Size Type
1 F 65536 1023.88 MB Recovery
Out-File : Cannot find drive. A drive with the name ‘F’ does not exist.
At H:\downloads\temp2\Test.psm1:22 char:18
Get-ChildItem : Cannot find drive. A drive with the name ‘F’ does not exist.
At H:\downloads\temp2\Test.psm1:23 char:5
-
Get-ChildItem $file
-
~~~~~~~~~~~~~~~~~~~
- CategoryInfo : ObjectNotFound: (F:String) [Get-ChildItem], DriveNotFoundException
- FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
PS H:\downloads\temp2> .\Always-Work.ps1
DriveLetter FileSystemLabel FileSystem DriveType HealthStatus OperationalStatus SizeRemaining Size
Windows Recovery NTFS Fixed Healthy OK 1000.34 MB 1023.87 MB
DiskPath: \?\scsi#disk&ven_msft&prod_virtual_disk#2&1f4adffe&0&000005#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
PartitionNumber DriveLetter Offset Size Type
1 F 65536 1023.88 MB Recovery
Directory: F:\
Mode LastWriteTime Length Name
-a---- 8/20/2015 11:58 AM 22 temp.txt
PS H:\downloads\temp2> .\Fails.ps1
DriveLetter FileSystemLabel FileSystem DriveType HealthStatus OperationalStatus SizeRemaining Size
Windows Recovery NTFS Fixed Healthy OK 1000.34 MB 1023.87 MB
DiskPath: \?\scsi#disk&ven_msft&prod_virtual_disk#2&1f4adffe&0&000006#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
PartitionNumber DriveLetter Offset Size Type
1 F 65536 1023.88 MB Recovery
Directory: F:\
Mode LastWriteTime Length Name
-a---- 8/20/2015 11:59 AM 22 temp.txt