Loyall
asked on
Powershell NTFSsecurity () parentheses issues
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-SomeFold er (read)" to type "Security2.IdentityReferen ce2". Error: "Some or all identity references could not be translated."
At C:\Temp\Set_Permissions\Se tPermissio ns.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:
Thanks in advance !
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-SomeFold
At C:\Temp\Set_Permissions\Se
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
}
Thanks in advance !
ASKER
Hi, Raheman Mohammed Abdul
Major Minor Build Revision
----- ----- ----- --------
3 0 -1 -1
Major Minor Build Revision
----- ----- ----- --------
3 0 -1 -1
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 ...
ASKER
Hi, Qlemo
I downloaded the version that is currently available on Technet and https://ntfssecurity.codeplex.com/
I downloaded the version that is currently available on Technet and https://ntfssecurity.codeplex.com/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I should have suggested that. I have been positive about it being an issue with the module itself ...
ASKER
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.
what version you are using ?