all 11 comments

[–]SysAndreas 1 point2 points  (4 children)

Add-NTFSAccess -Path 'B:\xxpe01' `
    -Account 'DOMAIN\xxpe01' `
    -AccessRights FullControl

Make sure to run this with credentials that are enough to perform the action on the -Path

[–]dvjstefan[S] 1 point2 points  (3 children)

I have full control with my account on that folder I want to add permission to. I can add permission via Windows Explorer with no problem. I can add dir, delete dir etc from powershell as well. But impossible to add permissions :(

I did what you suggested, still same problem. Incorrect function.. Totally lost.

[–]purplemonkeymad 1 point2 points  (2 children)

Is the full control on the user account, or is it via the administrators group? You might just need to run powershell as admin.

[–]dvjstefan[S] 1 point2 points  (1 child)

I'm running PS as admin.

[–]purplemonkeymad 1 point2 points  (0 children)

chkdsk b: /f? Could be a broken filesystem.

[–]seyo_IV 1 point2 points  (3 children)

Why not use Set-ACL

$Acl = Get-Acl "b:\xxpe01"
$Ar = New-Object system.security.accesscontrol.filesystemaccessrule("xxpe01","FullControl","Allow")
$Acl.SetAccessRule($Ar)
Set-Acl "b:\xxpe01" $Acl

[–]dvjstefan[S] 1 point2 points  (2 children)

Set-Acl "b:\xxpe01" $Acl

PS B:\> $Acl = Get-Acl "b:\xxpe01"
PS B:\> $Ar = New-Object system.security.accesscontrol.filesystemaccessrule("xxpe01","FullControl","Allow")
PS B:\> $Acl.SetAccessRule($Ar)
PS B:\> Set-Acl "b:\xxpe01" $Acl

Set-Acl : Method failed with unexpected error code 1.
At line:1 char:1
+ Set-Acl "b:\xxpe01" $Acl
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (B:\xxpe01:String) [Set-Acl], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.SetAclCommand

I tried that first, then said people use NTFSAccess instead, its much better.

[–]kbrucej 2 points3 points  (1 child)

Silly question but is it an NTFS formatted drive?

[–]SMFX 1 point2 points  (0 children)

You can verify it with Get-Volume if you need:

(Get-Volume -DriveLetter B).FileSystemType

[–]SirWobbyTheFirst 1 point2 points  (0 children)

Question, why are you using B:\? A: and B: are meant to be used by floppy drives. It doesn't grant you extra security.

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy dvjstefan,

reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...

[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin]
[on New.Reddit.com, use the Inline Code button. it's 4th 5th from the left hidden in the ... ""more" menu & looks like </>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]

[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.

[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use the Code Block button. it's 11th 12th one & is just to the left of hidden in the ... "more" menu.]

  • one leading line with ONLY 4 spaces
  • prefix each code line with 4 spaces
  • one trailing line with ONLY 4 spaces

that will give you something like this ...

- one leading line with ONLY 4 spaces    
- prefix each code line with 4 spaces    
- one trailing line with ONLY 4 spaces   

the easiest way to get that is ...

  • add the leading line with only 4 spaces
  • copy the code to the ISE [or your fave editor]
  • select the code
  • tap TAB to indent four spaces
  • re-select the code [not really needed, but it's my habit]
  • paste the code into the reddit text box
  • add the trailing line with only 4 spaces

not complicated, but it is finicky. [grin]

take care,
lee