Answer the question
In order to leave comments, you need to log in
Access denied when counting the volume of pictures in the Windows directory, although there were none before, how to fix it?
You need to get the total volume of all bmp, jpg files in the Winodws directory and all its subdirectories.
$sum=0; ForEach ($f in dir C:\Windows\* -include *.bmp, *.jpg -recurse){$sum+=$f.length} $sum
Answer the question
In order to leave comments, you need to log in
See what permissions are on the files, from which user you are running the script.
Using Adjusting Token Privileges in Powershell , you increase administrator privileges and count without errors:
Set-ExecutionPolicy Unrestricted Process
Import-Module .\Set-LHSTokenPrivilege.ps1
Set-LHSTokenPrivilege SeBackupPrivilege
Set-LHSTokenPrivilege SeRestorePrivilege
$sum=0; ForEach ($f in dir C:\Windows\* -include *.bmp, *.jpg -recurse){$sum+=$f.length} $sum
dir /q C:\Windows\System32\LogFiles\WMI
показывает, у папки нет владельца, то есть14.05.2019 13:10 <DIR> NT AUTHORITY\СИСТЕМА .
14.05.2019 13:10 <DIR> NT AUTHORITY\СИСТЕМА ..
11.05.2019 15:20 <DIR> ... RtBackup
надо его восстановить takeown /F C:\Windows\System32\LogFiles\WMI\RtBackup /A
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question