\nrrr<\/td>\n \\FS5\\F:\\rrr<\/td>\n FS5-users-Modify<\/td>\n ReadAndExecute,Synchronize<\/td>\n TRUE<\/td>\n 3<\/td>\n <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>foreach($item in $PermissionList){ \n$FolderName = $item.FolderName \n$Path = $item.Path \n$AccountName = $item.Group \n$AccessRight = $item.AccessRight \n$Inherit = $item.Inherited<\/p>\n
Get-Item $FolderName -Path $Path | Add-NTFSAccess -Account $AccountName -AccessRights $AccessRight \nWrite-Host -ForegroundColor Green “Folder $($item.count)!” \n}<\/p>\n
it dosent work and dosent even give me any error.<\/p>","upvoteCount":0,"datePublished":"2022-03-03T12:56:28.000Z","url":"https://community.spiceworks.com/t/powershell-share-folder-permission/826559/10","author":{"@type":"Person","name":"spiceuser-7oi8r","url":"https://community.spiceworks.com/u/spiceuser-7oi8r"}},{"@type":"Answer","text":"
and the groups are in a different domain. its a global group. I have tried Domain\\group format but it doesn’t work.<\/p>","upvoteCount":0,"datePublished":"2022-03-03T13:22:58.000Z","url":"https://community.spiceworks.com/t/powershell-share-folder-permission/826559/11","author":{"@type":"Person","name":"spiceuser-nue2s","url":"https://community.spiceworks.com/u/spiceuser-nue2s"}},{"@type":"Answer","text":"\n\n
<\/div>\n
spiceuser-7oi8r:<\/div>\n
\nThis is my new code It worked on my personal pc but it is not working in the server. I am trying to add this to the server.<\/p>\n
Name Path Group AccessRight Inherited count rrr \\FS5\\F:\\rrr FS5-Administration-Modify ReadAndExecute,Synchronize TRUE 1 rrr \\FS5\\F:\\rrr FS5-123-Modify ReadAndExecute,Synchronize TRUE 2 rrr \\FS5\\F:\\rrr FS5-users-Modify ReadAndExecute,Synchronize TRUE 3<\/p>\n
foreach($item in $PermissionList){ \n$FolderName = $item.FolderName \n$Path = $item.Path \n$AccountName = $item.Group \n$AccessRight = $item.AccessRight \n$Inherit = $item.Inherited<\/p>\n
Get-Item $FolderName -Path $Path | Add-NTFSAccess -Account $AccountName -AccessRights $AccessRight \nWrite-Host -ForegroundColor Green “Folder $($item.count)!” \n}<\/p>\n
it dosent work and dosent even give me any error.<\/p>\n<\/blockquote>\n<\/aside>\n
Looks like you need to use $item.Name instead of $item.FolderName<\/p>\n
Name \tPath \t Group \t AccessRight \t Inherited \tcount \t\nrrr \t\\\\FS5\\F:\\rrr FS5-Administration-Modify ReadAndExecute,Synchronize TRUE \t1\n<\/code><\/pre>\nYou can see this in your text. Name, Path,AccessRight, Inherited, and Count are valid properties. When pasting anything please use the </> at the top of the editor box so that it’s legible, This includes text and code.<\/p>","upvoteCount":0,"datePublished":"2022-03-03T13:34:15.000Z","url":"https://community.spiceworks.com/t/powershell-share-folder-permission/826559/12","author":{"@type":"Person","name":"saidbrandon","url":"https://community.spiceworks.com/u/saidbrandon"}},{"@type":"Answer","text":"
I don’t understand what is missing? I am still getting errors. Can you please fix the code?<\/p>\n
\n
\n\n\nName<\/th>\n Group<\/th>\n AccessRight<\/th>\n Inherited<\/th>\n count<\/th>\n<\/tr>\n<\/thead>\n \n\n\\FS5\\F:\\rrr<\/td>\n FS5-Administration-Modify<\/td>\n ReadAndExecute,Synchronize<\/td>\n TRUE<\/td>\n 1<\/td>\n<\/tr>\n \n\\FS5\\F:\\rrr<\/td>\n FS5-123-Modify<\/td>\n ReadAndExecute,Synchronize<\/td>\n TRUE<\/td>\n 2<\/td>\n<\/tr>\n \n\\FS5\\F:\\rrr<\/td>\n FS5-users-Modify<\/td>\n ReadAndExecute,Synchronize<\/td>\n TRUE<\/td>\n 3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>PS C:\\Users***> $PermissionList = Import-Csv -Delimiter “;” -Path ‘C:\\Users\\GhoshG\\Desktop\\test1.csv’<\/p>\n
\n\nforeach($item in $PermissionList){ \n$FolderName = $item.Name \n$AccountName = $item.Group \n$AccessRight = $item.AccessRight \n$Inherit = $item.Inherited<\/p>\n
Get-Item -LiteralPath $FolderName | Add-NTFSAccess -Account $AccountName -AccessRights $AccessRight \nWrite-Host -ForegroundColor Green “Folder $($item.count)!” \n}<\/p>\n<\/blockquote>\n<\/blockquote>\n
Get-Item: \nLine | \n10 | Get-Item -LiteralPath $FolderName | Add-NTFSAccess -Account $Acc … \n| ~~~~~~~~~~~ \n| Cannot bind argument to parameter ‘LiteralPath’ because it is null. \nFolder 1! \nGet-Item: \nLine | \n10 | Get-Item -LiteralPath $FolderName | Add-NTFSAccess -Account $Acc … \n| ~~~~~~~~~~~ \n| Cannot bind argument to parameter ‘LiteralPath’ because it is null. \nFolder 1! \nGet-Item: \nLine | \n10 | Get-Item -LiteralPath $FolderName | Add-NTFSAccess -Account $Acc … \n| ~~~~~~~~~~~ \n| Cannot bind argument to parameter ‘LiteralPath’ because it is null. \nFolder 1! \nGet-Item: \nLine | \n10 | Get-Item -LiteralPath $FolderName | Add-NTFSAccess -Account $Acc … \n| ~~~~~~~~~~~ \n| Cannot bind argument to parameter ‘LiteralPath’ because it is null. \nFolder 1! \nGet-Item: \nLine | \n10 | Get-Item -LiteralPath $FolderName | Add-NTFSAccess -Account $Acc … \n| ~~~~~~~~~~~ \n| Cannot bind argument to parameter ‘LiteralPath’ because it is null. \nFolder 1!<\/p>","upvoteCount":0,"datePublished":"2022-03-03T13:52:03.000Z","url":"https://community.spiceworks.com/t/powershell-share-folder-permission/826559/13","author":{"@type":"Person","name":"spiceuser-7oi8r","url":"https://community.spiceworks.com/u/spiceuser-7oi8r"}},{"@type":"Answer","text":"
We’re not a script writing service. I’ve given plenty of advice on what to look at and change. I’ve also asked that you use </> to paste data. I’m not sure how to further assist if you’re going to ignore what I’m recommending/asking.<\/p>","upvoteCount":0,"datePublished":"2022-03-03T13:56:06.000Z","url":"https://community.spiceworks.com/t/powershell-share-folder-permission/826559/14","author":{"@type":"Person","name":"saidbrandon","url":"https://community.spiceworks.com/u/saidbrandon"}}]}}
Hi I am trying to add permissions in a file server share folder through csv and PowerShell. I am pretty new on this. The groups are in a different domain. I can change the domain in the gui , like LOCATION option. how do I do it with powershell?
Currently the csv file has the fields:
FolderName;AccountName;AccessRight;Inherited
\ServerName\Folder\subFolder;domain\User1;Modify, Synchronize;True
\ServerName\Folder\subFolder ;domain\user2;FullControl;True
\ServerName\Folder\subFolder ;domain\admin;FullControl;True
And it was with this masterpiece that I destroyed my test environment:
I need a for each loop. and please give me an example.
Thank you!
7 Spice ups
Consider this as well. Let’s say you have DomainA and DomainB. Security groups in either domain are going to have a scope: domain local, global, or universal. If Server is in DomainA and groups are in DomainB, then the groups need to either be global (if users are in DomainB) or universal (if users are in the same forest). DomainA and DomainB need to either be in the same forest or have a trust. Do you meet this criteria?
Yes I made Global Groups. and I need am stuck with this code in PowerShell. can you please solve it?
Yes I made Global Groups. and I need am stuck with this code in PowerShell. can you please solve it? its giving me some error
FolderName
Group
AccessRight
Inherited
C:\Users\GhoshG\Desktop\rrr
IR-5-abstract-Modify
Read
TRUE
Yes I made Global Groups. and I need am stuck with this code in PowerShell. can you please solve it? its giving me some error
FolderName
Group
AccessRight
Inherited
C:\Users\GhoshG\Desktop\rrr
IR-5-abstract-Modify
Read
TRUE
$PermissionList = Import-Csv -Delimiter “;” -Path C:\Users\GhoshG\Desktop\test1.csv
foreach($item in $PermissionList){
$FolderName = $item.FolderName
$AccountName = $item.Group
$AccessRight = $item.AccessRight
$Inherit = $item.Inherited
Get-Item $FolderName | Add-NTFSAccess -Account $AccountName -AccessRights $AccessRight
}
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
‘PSGallery’?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is “N”): a
Get-Item:
Line |
12 | Get-Item $FolderName | Add-NTFSAccess -Account $AccountName -Acce …
| ~~~~~~~~~~~
| Cannot bind argument to parameter ‘Path’ because it is null.
$FolderName is empty
Ensure that your CSV has a column named “FolderName” and that it doesn’t contain any blanks or white space
-LiteralPath didn’t work. Please help me solve it.
FolderName
Group
AccessRight
Inherited
C:\Users\GhoshG\Desktop\rrr
IR-5-abstract-Modify
Read
TRUE
and this is a example of my code and CSV
$PermissionList = Import-Csv -Delimiter “;” -Path C:\Users\GhoshG\Desktop\test1.csv
foreach($item in $PermissionList){
$FolderName = $item.FolderName
$AccountName = $item.Group
$AccessRight = $item.AccessRight
$Inherit = $item.Inherited
Get-Item -LiteralPath $FolderName | Add-NTFSAccess -Account $AccountName -AccessRights $AccessRight
}
Get-Item:
Line |
11 | Get-Item -LiteralPath $FolderName | Add-NTFSAccess -Account $Acco …
| ~~~~~~~~~~~
| Cannot bind argument to parameter ‘LiteralPath’ because it is null.
$FolderName is still empty. Can you post the first few lines of the CSV (including the header) so we can see what it looks like? Either FolderName isn’t a value in the csv or one of the line items is blank in the FolderName column.
This is my new code It worked on my personal pc but it is not working in the server. I am trying to add this to the server.
Name
Path
Group
AccessRight
Inherited
count
rrr
\FS5\F:\rrr
FS5-Administration-Modify
ReadAndExecute,Synchronize
TRUE
1
rrr
\FS5\F:\rrr
FS5-123-Modify
ReadAndExecute,Synchronize
TRUE
2
rrr
\FS5\F:\rrr
FS5-users-Modify
ReadAndExecute,Synchronize
TRUE
3
foreach($item in $PermissionList){
$FolderName = $item.FolderName
$Path = $item.Path
$AccountName = $item.Group
$AccessRight = $item.AccessRight
$Inherit = $item.Inherited
Get-Item $FolderName -Path $Path | Add-NTFSAccess -Account $AccountName -AccessRights $AccessRight
Write-Host -ForegroundColor Green “Folder $($item.count)!”
}
it dosent work and dosent even give me any error.
and the groups are in a different domain. its a global group. I have tried Domain\group format but it doesn’t work.
spiceuser-7oi8r:
This is my new code It worked on my personal pc but it is not working in the server. I am trying to add this to the server.
Name Path Group AccessRight Inherited count rrr \FS5\F:\rrr FS5-Administration-Modify ReadAndExecute,Synchronize TRUE 1 rrr \FS5\F:\rrr FS5-123-Modify ReadAndExecute,Synchronize TRUE 2 rrr \FS5\F:\rrr FS5-users-Modify ReadAndExecute,Synchronize TRUE 3
foreach($item in $PermissionList){
$FolderName = $item.FolderName
$Path = $item.Path
$AccountName = $item.Group
$AccessRight = $item.AccessRight
$Inherit = $item.Inherited
Get-Item $FolderName -Path $Path | Add-NTFSAccess -Account $AccountName -AccessRights $AccessRight
Write-Host -ForegroundColor Green “Folder $($item.count)!”
}
it dosent work and dosent even give me any error.
Looks like you need to use $item.Name instead of $item.FolderName
Name Path Group AccessRight Inherited count
rrr \\FS5\F:\rrr FS5-Administration-Modify ReadAndExecute,Synchronize TRUE 1
You can see this in your text. Name, Path,AccessRight, Inherited, and Count are valid properties. When pasting anything please use the </> at the top of the editor box so that it’s legible, This includes text and code.
I don’t understand what is missing? I am still getting errors. Can you please fix the code?
Name
Group
AccessRight
Inherited
count
\FS5\F:\rrr
FS5-Administration-Modify
ReadAndExecute,Synchronize
TRUE
1
\FS5\F:\rrr
FS5-123-Modify
ReadAndExecute,Synchronize
TRUE
2
\FS5\F:\rrr
FS5-users-Modify
ReadAndExecute,Synchronize
TRUE
3
PS C:\Users***> $PermissionList = Import-Csv -Delimiter “;” -Path ‘C:\Users\GhoshG\Desktop\test1.csv’
foreach($item in $PermissionList){
$FolderName = $item.Name
$AccountName = $item.Group
$AccessRight = $item.AccessRight
$Inherit = $item.Inherited
Get-Item -LiteralPath $FolderName | Add-NTFSAccess -Account $AccountName -AccessRights $AccessRight
Write-Host -ForegroundColor Green “Folder $($item.count)!”
}
Get-Item:
Line |
10 | Get-Item -LiteralPath $FolderName | Add-NTFSAccess -Account $Acc …
| ~~~~~~~~~~~
| Cannot bind argument to parameter ‘LiteralPath’ because it is null.
Folder 1!
Get-Item:
Line |
10 | Get-Item -LiteralPath $FolderName | Add-NTFSAccess -Account $Acc …
| ~~~~~~~~~~~
| Cannot bind argument to parameter ‘LiteralPath’ because it is null.
Folder 1!
Get-Item:
Line |
10 | Get-Item -LiteralPath $FolderName | Add-NTFSAccess -Account $Acc …
| ~~~~~~~~~~~
| Cannot bind argument to parameter ‘LiteralPath’ because it is null.
Folder 1!
Get-Item:
Line |
10 | Get-Item -LiteralPath $FolderName | Add-NTFSAccess -Account $Acc …
| ~~~~~~~~~~~
| Cannot bind argument to parameter ‘LiteralPath’ because it is null.
Folder 1!
Get-Item:
Line |
10 | Get-Item -LiteralPath $FolderName | Add-NTFSAccess -Account $Acc …
| ~~~~~~~~~~~
| Cannot bind argument to parameter ‘LiteralPath’ because it is null.
Folder 1!
We’re not a script writing service. I’ve given plenty of advice on what to look at and change. I’ve also asked that you use </> to paste data. I’m not sure how to further assist if you’re going to ignore what I’m recommending/asking.