【发布时间】:2020-01-11 18:57:23
【问题描述】:
用于邮箱文件夹统计信息和权限的 Exchange PowerShell 命令是脱节的,需要您处理数据以获取统计信息并将它们用作删除文件夹权限的变量。
我正在尝试使用 PowerShell 中的替换命令来操作值而不破坏数组本身。
我尝试了各种方法来使用 -replace 命令来处理这个问题,因为它没有成功。
我正在尝试使用类似这样的代码:
Get-MailboxFolderStatistics -Identity jon@towles.com | Select Identity | ForEach-Object { $_."Identity" -replace '.com','.com:'}
当我使用替换功能时,它会破坏数组,因此我们不再看到标题,并且不能将它与 foreach-object {Remove-MailboxFolderPermissions -identity $_.identity -user testuser} 之类的东西一起使用
我希望替换功能仍然会保留数据布局。
【问题讨论】:
-
$_.identity 会破坏标题,因为您要取消引用属性。您可以一起跳过 foreach 并在您的选择对象中使用计算属性
-
感谢您的想法。这是修复:$folders = get-mailboxfolderstatistics -Identity $user | Where-Object {($_.FolderPath -ne "/Top of Information Store" -and $_.FolderPath -ne "/Recoverable Items" -and $_.FolderPath -ne "/Deletions" -and$_.FolderPath - ne "/Purges" -and $_.FolderPath -ne "/Versions")} | Select-Object -Property @{ Name = 'FolderPath';表达式 = { $_.identity -replace 'test.com','test.com:' -and -replace '?','\'}}
标签: powershell exchange-server exchange-server-2010