Manipulating Files

In addition to providing information about the underlying files that they represent, CIM_DataFile objects can be used to perform a number of simple housekeeping tasks.

CIM_DataFile objects have methods to support most of the actions that you would expect to be supported at the filesystem level—namely, copying, moving, renaming, and deleting. In addition, there are methods to control a file’s compression status and to manipulate security on an NTFS filesystem. The following script fragments demonstrate the use of these methods (with the exception of the security-related methods, which are discussed in Chapter 5, “WMI Security”). Because some of these methods are really quite destructive, it is probably best not to use a file ...

Get Windows Management Instrumentation (WMI) now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.