powershell - 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”位于该行的最前面。
解决方案
不幸的是,这是无法做到的。正如官方帮助建议的那样,此命令的输出字段为空。
“如果输出类型字段为空,则 cmdlet 不会返回数据。” 查看更多: https ://docs.microsoft.com/en-us/exchange/client-developer/management/exchange-management-shell-cmdlet-input-and-output-types
推荐阅读
- android - 如何将活动范围对象注入应用程序范围对象?
- javascript - 使用 JSON 文件作为数据库
- python - os.path.realpath(__file__) 没有返回预期的路径
- c# - 如何在 OnModelCreating 中填写被忽略的字段?
- docker - 詹金斯在容器内运行命令吗?
- angular - Angular 无法将类型添加到选项对象
- vue.js - vue-chartjs - 中间有文字的圆环图
- react-native - 我们可以将 Telr 支付网关与 React Native 集成吗?
- pandas - Pandas 在两列中重新采样数据
- c# - 如何将 1 月 1 日转换为日期时间