cancellare cartelle con WMI e Powershell … (DEL nonsepo’ ?)
Following on from the last post this is how you can delete a file.
Use the same file structure as previously
This time you need to use the CIM_DataFile class. It’s one of the few classes I’ve found that doesn’t have a Win32_ equivalent.
The class has a Delete method. Assuming you know the full path to the file
Get-CimInstance -ClassName CIM_DataFile -Filter “Name=’C:\\Expendable\\Target1\\proc.txt’ ” |
Invoke-CimMethod -MethodName Delete
You can perform most actions on files and folders using WMI but you can’t create a file or a folder