Powershell 从文件夹中删除用户权限

Powershell 从文件夹中删除用户权限,powershell,Powershell,我创建了此脚本,该脚本将为每个用户创建一个文件夹,该用户在UNC路径上具有“Customer Service Representative”的标题。有一个从父用户继承的用户组。如何删除该用户组 $names = (Get-ADUser -Filter 'Title -eq "Customer Service Representative"').name foreach ($name in $names) { New-Item -ItemType "directory" -Path "\\unc\

我创建了此脚本,该脚本将为每个用户创建一个文件夹,该用户在UNC路径上具有“Customer Service Representative”的标题。有一个从父用户继承的用户组。如何删除该用户组

$names = (Get-ADUser -Filter 'Title -eq "Customer Service Representative"').name
foreach ($name in $names)
{
New-Item -ItemType "directory" -Path "\\unc\$name" -ErrorAction SilentlyContinue
$path = "\\unc\$name" #Replace with whatever file you want to do this to.
$user = "domain\group" #User account to grant permisions too.
$Rights = "Full" #"Read, ReadAndExecute, ListDirectory" #Comma seperated list.
$InheritSettings = "Containerinherit, ObjectInherit" #Controls how permissions are inherited by 
children
$PropogationSettings = "None" #Usually set to none but can setup rules that only apply to children.
$RuleType = "Allow" #Allow or Deny.
$acl = Get-Acl $path
$perm = $user, $Rights, $InheritSettings, $PropogationSettings, $RuleType
$rule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $perm
$acl.SetAccessRule($rule)
$acl | Set-Acl -Path $path
}

从PowerShell的管理控制台
安装软件包ntfsecurity

在结束之前{添加行
删除NTFSAccess-AccessRights FullControl-Account DOMAIN\Group-Path$Path-AccessType Deny-Applies to ThisFolders子文件夹和文件


至少,我猜这是合适的?我还没有深入研究您的代码以了解您的具体操作。我可能会在创建文件夹后立即将其放入,但在这里似乎不会发生这种情况?

不确定您是否对加载项感到满意,但您可能想查看此模块:


我已经使用它很多年了。它功能非常强大,而且非常容易使用。

您搜索过答案吗?我想第三个链接让我找到了答案。我找到了,但没有意义如何将它应用到我的脚本中。remove ntfsaccess不是cmdlet