# File server permissions

**URL:** <https://forums.powershell.org/t/file-server-permissions/4330>\
**Category:** PowerShell Help\
**Created:** [June 8, 2015, 8:59pm UTC](https://forums.powershell.org/t/file-server-permissions/4330 "2015-06-08T20:59:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![harish-m](https://avatars.discourse-cdn.com/v4/letter/h/278dde/32.png) [@harish-m](https://forums.powershell.org/u/harish-m)\
**Post date:** [June 8, 2015, 8:59pm UTC](https://forums.powershell.org/t/file-server-permissions/4330/1 "2015-06-08T20:59:40Z")

</div>

I’m very new to PowerShell, I need a help to fix my business solution.  
I have file server in my network it has a shared folder(D:\Users - \fileserver\Users) this folder has users folders with user account names. I need to assign only modify permissions to users on their respective folders.

---

<div class="post-metadata">

**Author:** ![harish-m](https://avatars.discourse-cdn.com/v4/letter/h/278dde/32.png) [@harish-m](https://forums.powershell.org/u/harish-m)\
**Post date:** [June 8, 2015, 10:41pm UTC](https://forums.powershell.org/t/file-server-permissions/4330/2 "2015-06-08T22:41:50Z")

</div>

```
$usersfolders = "C:\Users\hmunagapati\Desktop\Users"
$foldername = Get-ChildItem -Name -Path $usersfolders
Add-NTFSAccess -Account indigo\$foldername -AccessRights Modify -Path $usersfolders\$foldername
```

Error -  
Add-NTFSAccess : Cannot bind parameter ‘Account’. Cannot convert value “mydomain\usr1 usr2 usr3” to type  
“Security2.IdentityReference2”. Error: “Some or all identity references could not be translated.”  
At C:\Users\harish\Desktop\Permissions.ps1:3 char:25

- Add-NTFSAccess -Account indigo$foldername -AccessRights Modify -Path $usersfold …
- 

```
                    ~~~~~~~~~~~~~~~~~~

```

  - CategoryInfo : InvalidArgument: (🙂 [Add-NTFSAccess], ParameterBindingException
  - FullyQualifiedErrorId : CannotConver

Here I’m unable to pass the values from “Get-ChildItem -Name -Path $usersfolders”, help me how to pass one by one value from this.

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [June 8, 2015, 11:32pm UTC](https://forums.powershell.org/t/file-server-permissions/4330/3 "2015-06-08T23:32:44Z")

</div>

Get-ChildItem is going to return a collection of folders as a PSObject, which contains multiple properties for each folder. You need to loop through each returned folder and use the Name and FullName properties to build the command for Add-NTFSAccess:

```
$usersfolders = "C:\Users\hmunagapati\Desktop\Users"
$folders = Get-ChildItem -Name -Path $usersfolders
foreach ($folder in $folders) {
    Add-NTFSAccess -Account indigo\$folder.Name -AccessRights Modify -Path $folder.FullName
}
```

Keep in mind that the command is attempting to resolve the user in Active Directory, so if the user doesn’t exist, you will still receive an error. This can be handled using a Try\Catch if required.

---

<div class="post-metadata">

**Author:** ![harish-m](https://avatars.discourse-cdn.com/v4/letter/h/278dde/32.png) [@harish-m](https://forums.powershell.org/u/harish-m)\
**Post date:** [June 9, 2015, 2:04am UTC](https://forums.powershell.org/t/file-server-permissions/4330/4 "2015-06-09T02:04:02Z")

</div>

Thank you for your help Rob,

I’m getting the below error.

Add-NTFSAccess : Cannot bind parameter ‘Account’. Cannot convert value “indigo\usr1.Name” to type  
“Security2.IdentityReference2”. Error: “Some or all identity references could not be translated.”  
At C:\Users\hmunagapati\Desktop\Permissions.ps1:11 char:29

- 

```
Add-NTFSAccess -Account indigo\$folder.Name -AccessRights Modify -Path $user ...

```

- 

```
                        ~~~~~~~~~~~~~~~~~~~

```

  - CategoryInfo : InvalidArgument: (🙂 [Add-NTFSAccess], ParameterBindingException
  - FullyQualifiedErrorId : CannotConvertArgumentNoMessage,NTFSSecurity.AddAccess

Here I’m not able to use Name and FullName properties. so,made some changes to code it worked.

```
$usersfolders = "C:\Users\hmunagapati\Desktop\Users"
$folders = Get-ChildItem -Path $usersfolders
foreach ($folder in $folders) {
    Add-NTFSAccess -Account indigo\$folder -AccessRights Modify -Path $usersfolders\$folder
}
```

I’m using powershell 3.0 will it make any difference.

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [June 9, 2015, 4:10am UTC](https://forums.powershell.org/t/file-server-permissions/4330/5 "2015-06-09T04:10:35Z")

</div>

I didn’t catch the -Name parameter in the Get-ChildItem command, which only returns the name of the file. This is more what I was thinking:

```
$folders = Get-ChildItem -Path "C:\Test" -Directory
foreach ($folder in $folders) {
    "Setting permissions on {0} for user {1}" -f ("indigo\{0}" -f $folder.Name), $folder.FullName    
    #Add-NTFSAccess -Account ("indigo\{0}" -f $folder.Name) -AccessRights Modify -Path $folder.FullName
}
```

Output:

```
Setting permissions on indigo\User1 for user C:\Test\User1
Setting permissions on indigo\User2 for user C:\Test\User2
```

If your issue is resolved, please mark the post as resolved. Thanks.

---

<div class="post-metadata">

**Author:** ![harish-m](https://avatars.discourse-cdn.com/v4/letter/h/278dde/32.png) [@harish-m](https://forums.powershell.org/u/harish-m)\
**Post date:** [June 9, 2015, 12:53pm UTC](https://forums.powershell.org/t/file-server-permissions/4330/6 "2015-06-09T12:53:34Z")

</div>

This is cool Rob, I’m looking to improve this code to write out put to a “html” and to execute only it its a directory"if ($folder.Attributes -eq “Directory”)".

Changed the status to resolved, I’ll come back If I need any help.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:45pm UTC](https://forums.powershell.org/t/file-server-permissions/4330/7 "2024-05-16T20:45:11Z")

</div>


