I tried this command, it's working fine:
$path = "C:\sometext.txt"
[System.IO.File]::ReadAllBytes("$path")
But when I tried to read all bytes of file in PowerShell with unique ID like this code it doesn't work:
$path = "\\.\Volume{3386ab07-0000-0000-0000-501f00000000}\sometext.txt"
[System.IO.File]::ReadAllBytes("$path")
I take unique ID with:
$listdrive = ""
$drivelistuniqueID = Get-Volume
foreach ($item in $drivelistuniqueID)
{
$listdrive += $item.UniqueId + "DriveLetterSplIttEr"
}
$listdrive=$listdrive.Replace("?",".")
$listdrive
If I don't replace ?
with .
PowerShell says:
Exception calling "ReadAllBytes" with "1" argument(s): "Illegal characters in path." At line:3 char:1 + [System.IO.File]::ReadAllBytes("$path") + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ArgumentException
Any idea about how I could fix this error? I need only read file with GUID (Unique ID).
actually when you want to read all byte you can do it directly . test this on your computer make new file wile using GUID then try to open file . you will see you can't . if you want to use readallbyte you should hook this.