Hi there,
I’m running this line to search all ISO files on all drives:
(GET-WMIOBJECT -query “SELECT * from win32_logicaldisk where DriveType = ‘3’”).DeviceID| %{Get-ChildItem -path $_ -Include *.ISO -Recurse -Force -ea 0 |Select-Object FullName}
It runs through some drives and list the ISOs that it finds along the way but then exits with this error:
Get-ChildItem : Access is denied
At line:1 char:92
- … ").DeviceID| %{Get-ChildItem -path $_ -Include *.ISO -Recurse -Force -ea 0 |Sele …
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: ( [Get-ChildItem], UnauthorizedAccessException
- FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetChildItemCommand
If I expand the error:
PS C:> $error[0]|format-list -force
Exception : System.UnauthorizedAccessException: Access to the path ‘P:\System Volume Information’ is
denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator`1.CommonInit()
at System.IO.FileSystemEnumerableIterator`1…ctor(String path, String originalUserPath,
String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean
checkHost)
at System.IO.FileSystemEnumerableFactory.CreateDirectoryInfoIterator(String path, String
originalUserPath, String searchPattern, SearchOption searchOption)
at Microsoft.PowerShell.Commands.FileSystemProvider.Dir(DirectoryInfo directory, Boolean
recurse, Boolean nameOnly, ReturnContainers returnContainers)
TargetObject : P:\System Volume Information
CategoryInfo : PermissionDenied: (P:\System Volume Information:String) [Get-ChildItem],
UnauthorizedAccessException
FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at , : line 1
at , : line 1
PipelineIterationInfo : {0, 1, 0}
PSMessageDetails :
I can see that I’m not allowed access to “P:\System Volume Information” which I’d expect, but I also expect the ErrorAction of SilentlyContinue to sail past this problem. Any idea why this happens?
Thanks
Kieran.