[英]Powershell CIM Method "Delete" is missing in Win32_ShadowCopy?
我嘗試從 WMI 切換到 CIM,但缺少一些方法:WMI way so select the next best VSS snapshot:
$SnapShot = (Get-WmiObject Win32_ShadowCopy)[0]
然后你就有了工作方法:
$SnapShot.Delete()
但是 Get-CimInstance 並沒有給我設計的方法。
$SnapShot = (Get-CimInstance Win32_ShadowCopy)[0]
和Get-CimClass -ClassName Win32_ShadowCopy
僅顯示方法“Create”和“Revert” - “Delete”方法在哪里?
通常 if 會像Invoke-CimMethod -ClassName Win32_ShadowCopy -MethodName "Delete" -Arguments @{ID="$SnapShot.ID"}
這樣的東西。 但不是...
我已經嘗試了很多組合來訪問甚至看到“刪除”方法,但它在哪里? 不鼓勵使用 WMI,因為當 CIM 可用時它是“舊的”,但對於 CIM,通常會缺少方法或隱藏在不明顯的地方,如本例所示。
是的,我可以使用vssadmin.exe delete shadows /Shadow=$($SnapShot.ID) /Quiet
但這不是干凈的方法,只是一個骯臟的解決方法。
可能是 pipe 以像 win32_userprofile 一樣刪除實例。 .delete() 是由 get-wmiobject 組成的方法,它做類似的事情。
get-ciminstance win32_userprofile | ? localpath -match js2010 |remove-ciminstance
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.