-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathRemove-NTUSER.ps1
More file actions
32 lines (31 loc) · 1.34 KB
/
Remove-NTUSER.ps1
File metadata and controls
32 lines (31 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
param($Check=$True,$Remove=$False,$TestMode=$False)
[array]$Folders = Get-PublicFolder -Identity "\" -Recurse -ResultSize Unlimited
foreach ($Folder in $Folders)
{
[array]$FolderPermissions = Get-PublicFolderClientPermission -Identity $Folder.Identity | Where {$_.User -like "NT User:*"}
if ($FolderPermissions)
{
foreach ($FolderPermission in $FolderPermissions)
{
Write-Host -NoNewline "Folder "
Write-Host -NoNewline -ForegroundColor Green $FolderPermission.Identity
Write-Host -NoNewline " has "
Write-Host -NoNewline -ForegroundColor Green $FolderPermission.AccessRights
Write-Host -NoNewline " permissions for user "
Write-Host -NoNewline -ForegroundColor Green $FolderPermission.User
if ($Remove)
{
if ($TestMode)
{
Write-Host -ForegroundColor Yellow " - Testing Removal"
$FolderPermission | Remove-PublicFolderClientPermission -WhatIf
} else {
Write-Host -ForegroundColor Red " - Removing"
$FolderPermission | Remove-PublicFolderClientPermission -Confirm:$False
}
} else {
Write-Host
}
}
}
}