powershell - 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
,但结果相同。
解决方案
推荐阅读
- linux - 如何在不更改 cd 的情况下更改 tcsh 中的目录 -
- java - 如何在java中制作动态嵌套for循环?
- laravel - 安装包时出错(安装失败,正在将 ./composer.json 还原为其原始内容。)
- c - 函数返回后在内存中堆栈帧
- excel - Excel VBA:等待前一行代码完全执行
- php - Woocommerce 页面标题出现在错误的位置
- r - 根据几个参数填充一列
- java - 带有问号的构造函数的java哈希表
- vba - 有没有办法在 VBScript 中运行 excel VBA 模块
- sql - PostgreSQL - 如何按一组重复的相同字段值排序