首页 > 解决方案 > Remove-PublicFolderClientPermission - 输出到外壳?

问题描述

当我在处理许多用户以从中删除权限时使用 Remove-PublicFolderClientPermission 命令时,它不会输出到主机每一行...它只是显示一个空白的 Powershell 窗口,直到它完成,除非要删除的用户权限不拥有权限,则返回错误。

有没有办法让 Remove-PublicFolderClientPermission 为它删除的每个人输出一行?

我用于删除的代码如下:

#This script imports data from "PFPerm.csv" and Removes permissions for all users in the file.
Write-Host "Removing users...White text = OK ADDED!" -ForegroundColor Green
Write-Host "If a user DOES NOT exist there will be *RED TEXT* stating it was not found.." -ForegroundColor Magenta
Write-Host "If a user is being removed, it will not show any feedback to the screen, just wait for processing to complete.." -ForegroundColor Yellow
"`n"
$Users= Import-CSV -Encoding Unicode H:\Temp\PublicFolder-powershell\PFPerm.csv 
#The switch in this line, prevents confirmation popups from requiring user input and supresses them silently [-Confirm:$false]
foreach ($User in $Users){Get-PublicFolder -identity \$($User.Identity) -recurse | Remove-publicfolderclientpermission -Confirm:$false -User $User.User}

如果我使用$VerbosePreference = "Continue"-Verbose参数,它会显示我想要捕获和显示的输出,但是有太多不必要的信息,我不希望“VERBOSE”位于该行的最前面。

在此处输入图像描述

标签: powershellprintingoutputhost

解决方案


不幸的是,这是无法做到的。正如官方帮助建议的那样,此命令的输出字段为空。

“如果输出类型字段为空,则 cmdlet 不会返回数据。” 截屏 查看更多: https ://docs.microsoft.com/en-us/exchange/client-developer/management/exchange-management-shell-cmdlet-input-and-output-types


推荐阅读