This script is currect or not

Ganesh Singh 0 Reputation points
2026-08-17T09:09:20.72+00:00

$Folders = @(

2

"C:\ProgramData\Tally",

3

"C:\Program Files\Tally.ERP9",

4

"C:\Program Files (x86)\Tally.ERP9"

5

)

6

 

7

foreach ($Folder in $Folders) {

8

if (Test-Path $Folder) {

9

Write-Output "Granting access to $Folder"

10

icacls $Folder /grant "Users:(OI)(CI)M" /T /C

11

}

12

else {

13

Write-Output "$Folder not found"

14

}

15

}

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

1 answer

Sort by: Most helpful
  1. Senthil kumar 2,080 Reputation points
    2026-08-17T09:44:43.87+00:00

    Hi @Ganesh Singh

    It will work. for the improvement add below line instead of icacls $Folder /grant "Users:(OI)(CI)M" /T /C this.

    icacls $Folder /grant:r "Users:(OI)(CI)M" /T /C

    Thanks.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.