首页 > 解决方案 > Remove-WmiObject 不起作用,而且 $profile.Delete()

问题描述

我正在尝试删除 Powershell 中的用户配置文件。

直到昨天一切Remove-WmiObject正常。但是今天他们没有工作。请检查以下命令:

Get-WMIObject -class Win32_UserProfile | Where {
    ((!$_.Special) -and
    ($_.LocalPath -ne "C:\Users\Administrator") -and
    ($_.LocalPath -ne "C:\Users\UpdatusUser") -and
    ($_.LocalPath -eq "C:\Users\$user"))
} | Remove-WmiObject

我收到以下错误:

+ CategoryInfo : NotSpecified: (:) [Remove-WmiObject], FileLoadException
+ FullyQualifiedErrorId:System.IO.FileLoadException,Microsoft.PowerShell.Commands.RemoveWmiObject

我也试过$profile.Delete()方法。这也行不通。我得到方法未找到错误。我还检查了配置文件是否已加载。我也尝试过在删除他们的个人资料之前注销用户。我也尝试过使用Remove-Cmiinstance,但结果相同。

标签: powershellpowershell-3.0

解决方案


推荐阅读