added ErrorAction SilentlyContinue to Get-ChildItem

Sometimes you will have a denied access to a directory.
"ErrorAction SilentlyContinue" will continue searching recursively in \SYSVOL even when it encounters a directory where access is denied.
This commit is contained in:
hajdbo 2013-08-12 12:04:38 +02:00
parent 98be62a03a
commit c623814116
1 changed files with 2 additions and 2 deletions

View File

@ -64,8 +64,8 @@
if (((Get-WmiObject Win32_ComputerSystem).partofdomain) -eq $False) {throw 'Machine is not joined to a domain.'}
if (($Env:USERDNSDOMAIN) -eq $Null) {throw 'Account is not a domain account.'}
#discover potential files containing passwords
$XMlFiles = Get-ChildItem -Path "\\$Env:USERDNSDOMAIN\SYSVOL" -Recurse -Include 'groups.xml','services.xml','scheduledtasks.xml','datasources.xml'
#discover potential files containing passwords ; not complaining in case of denied access to a directory
$XMlFiles = Get-ChildItem -Path "\\$Env:USERDNSDOMAIN\SYSVOL" -Recurse -ErrorAction SilentlyContinue -Include 'groups.xml','services.xml','scheduledtasks.xml','datasources.xml'
foreach ($File in $XMLFiles) {