0
我写了一个PowerShell脚本在我的公司使用。无论出于何种原因,应该删除指定位置上的所有.ost文件的脚本部分只能工作一段时间。 ost的路径不会改变。任何人有任何想法,为什么会这样?需要帮助,混淆powershell问题
Stop-process -Name OUTLOOK -ErrorAction SilentlyContinue -Force
Stop-process -Name communicator -ErrorAction SilentlyContinue -Force
Stop-process -Name lync -ErrorAction SilentlyContinue -Force
Stop-Process -Name UcMapi -ErrorAction SilentlyContinue -Force
Stop-Process -Name skypehost -ErrorAction SilentlyContinue -Force
Stop-Process -Name searchprotocalhost -ErrorAction SilentlyContinue -Force
$OstPath = "c:\users\$([environment]::username)"+ "\AppData" + "\local" + "\Microsoft" + "\Outlook"
$ost = get-ChildItem $OstPath | where { $_.Extension -eq ".ost"}
$ost | remove-Item -WhatIf
Start-Process Outlook
是因为拼错'searchprotocolhost'吗?因为你使用'-WhatIf',这意味着什么都不会被删除?由于某些计算机未将用户文件存储在'c:\ users'中,例如他们没有英文本地化?由于另一个程序可能正在使用它,例如Mitel电话系统PIM。 – TessellatingHeckler
已更正,但仍存在问题。 – Funkel
现在已解决。我删除了-whatif并添加了强制,并且每次都清除它。我不好提前不试。感谢您的帮助! – Funkel