Solved

Powershell NTFSsecurity () parentheses issues

Posted on 2014-12-18
7
418 Views
Last Modified: 2015-01-10
Hi,

I'm using the NTFSsecurity module ( https://gallery.technet.microsoft.com/scriptcenter/1abd77a5-9c0b-4a2b-acef-90dbb2b84e85) to set permissions to a lot of folders.
The security groupnames at the company i'm working at contain parentheses like: "DLFS-SomeFolder (read)"
When i'm running the script, it gives me this error:

Add-NTFSAccess : Cannot bind parameter 'Account'. Cannot convert value "contoso.lan\DLFS-SomeFolder (read)" to type "Security2.IdentityReference2". Error: "Some or all identity references could not be translated."
At C:\Temp\Set_Permissions\SetPermissions.ps1:29 char:35

Is there a way to work around this ?

The script works fine with groupname that do not contain parentheses.

Here is the script:
#$ErrorActionPreference = "SilentlyContinue"
Import-Module ActiveDirectory
import-module ntfssecurity

#Read Users and folders from CSV
import-CSV "C:\Temp\Set_Permissions\Permissions.csv" -Delimiter ';' | foreach{

$Group = ("contoso.lan\" + $_.Groups)
$Folder = $_.Folder
$Permissions = $_.Permissions
$Folderexists = Test-Path $Folder

If ($_.inherit -eq "No"){
$Inherit = "ThisFolderOnly"
} else {
$Inherit = "ThisFolderSubfoldersAndFiles"
}

#Test if path exists
If ($Folderexists -eq $False){
    Write-Host "Folder: $Folder does not exsist." -ForeGroundColor Red
	} else { 
        Write-host "Folder:" $Folder "is available. Permissions for:" $Group "are set " -ForeGroundColor Cyan
		#Get-Item $folder | Add-Ace -Account $Group -AccessRights $Permissions -AppliesTo $Inherit
		Add-NTFSAccess $Folder -Account $Group -AccessRights $Permissions -AppliesTo $Inherit 
    } 

write-host "-------------------------------------------------------------------------" -ForeGroundColor Yellow
}

Open in new window


Thanks in advance !
0
Comment
Question by:Loyall
  • 4
  • 2
7 Comments
 
LVL 18

Expert Comment

by:Raheman M. Abdul
ID: 40506897
Try the same code in Powershell v3 or higher.
what  version you are using ?
0
 
LVL 2

Author Comment

by:Loyall
ID: 40507017
Hi, Raheman Mohammed Abdul

Major  Minor  Build  Revision
-----  -----  -----  --------
3      0      -1     -1
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 40507185
Are you using the most recent NTFSSecurity module? The discussion thread tells about some similar issues with german umlauts, which are "special" characters as the parens and stuff ...
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 2

Author Comment

by:Loyall
ID: 40512431
Hi, Qlemo

I downloaded the version that is currently available on Technet and https://ntfssecurity.codeplex.com/
0
 
LVL 2

Accepted Solution

by:
Loyall earned 0 total points
ID: 40532016
I contacted the author of the module and he updated the module the same day.
So, now it works fine.
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 40532030
I should have suggested that. I have been positive about it being an issue with the module itself ...
0
 
LVL 2

Author Closing Comment

by:Loyall
ID: 40541768
The issue was in the module was a limitation of the module itself. I emailed the author and he edited the module so it can handle parenthesis now.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now