首页 > 解决方案 > PowerShell - 清空已删除的项目和垃圾文件夹

问题描述

我正在使用以下代码清空已删除的项目和垃圾文件夹,因为它已满。但是在服务器中,它保存了一些数据,这些数据不会通过脚本或清理文件夹来删除。有人可以告诉我如何在空间用完时清理这两个文件夹。

Add-Type -assembly "Microsoft.Office.Interop.Outlook"
$Outlook = New-Object -comobject Outlook.Application
$namespace = $Outlook.GetNameSpace("MAPI")
$inbox = $namespace.GetDefaultFolder(3)
$readItems = $inbox.Items
$readItems | ForEach-Object{ $_.Delete() }
$junkEmail = $namespace.GetDefaultFolder(23)
$junkItems = $junkEmail.Items
$junkItems | ForEach-Object{ $_.Delete() }

标签: powershelloutlook

解决方案


推荐阅读