Win32_Directory Scripting
In the last article, I introduced you to the CIM_DataFile
CIM class. I demonstrated how you might use it as an alternative to the file system. You can use a CIM session for remoting and get additional properties.
#create CIMSession to a remote computer
[CimSession]$cs = 'thinkx1-jh'
#query properties
$Properties = "Name","FileSize","LastModified","FileType"
$query= "Select $($Properties -join ',') from CIM_DataFile where Name = 'c:\\scripts\\db.png'"
#update properties for Select-Object
$Properties+= @{Name="ComputerName";Expression={$cs.ComputerName.ToUpper()}}
$cs.QueryInstances("Root/Cimv2","WQL",$query) | Select-Object -Property $Properties
Personally, I find the property names a bit more meaningful.
Name : c:\scripts\db.png
FileSize : 13664
LastModified : 7/16/2013 5:42:07 PM
FileType : PNG Image
ComputerName : THINKX1-JH
Want to read the full issue?