Main example
List instances
# Abstract class: Get-CimInstance returns the instances of its subclasses
Get-CimInstance -ClassName CIM_LogicalFile |
Select-Object -Property @(
'CSName'
'FSCreationClassName'
'Name'
'Caption'
'Description'
'Status'
'Path'
)Abstract class: it has no instances of its own. Get-CimInstance returns the instances of its subclasses (CIM_DataFile, CIM_DeviceFile, CIM_Directory).
Examples
Decode numeric values
# Lookup table for AccessMask (values documented by Microsoft)
$accessMaskName = @{
1 = 'FILE_READ_DATA (file) or FILE_LIST_DIRECTORY (directory)'
2 = 'FILE_WRITE_DATA (file) or FILE_ADD_FILE (directory)'
4 = 'FILE_APPEND_DATA (file) or FILE_ADD_SUBDIRECTORY (directory)'
8 = 'FILE_READ_EA'
16 = 'FILE_WRITE_EA'
32 = 'FILE_EXECUTE (file) or FILE_TRAVERSE (directory)'
64 = 'FILE_DELETE_CHILD (directory)'
128 = 'FILE_READ_ATTRIBUTES'
256 = 'FILE_WRITE_ATTRIBUTES'
65536 = 'DELETE'
131072 = 'READ_CONTROL'
262144 = 'WRITE_DAC'
524288 = 'WRITE_OWNER'
1048576 = 'SYNCHRONIZE'
}
Get-CimInstance -ClassName CIM_LogicalFile |
Select-Object -Property @(
'CSName'
'FSCreationClassName'
'Name'
'Caption'
'Description'
'Status'
'Path'
)Query a remote computer (CIM session)
review before running# Name of the remote computer
$computerName = 'SERVER01'
# The CIM session (WSMan by default) can be reused for several queries
$cimSession = New-CimSession -ComputerName $computerName
try {
Get-CimInstance -CimSession $cimSession -ClassName CIM_LogicalFile |
Select-Object -Property @(
'CSName'
'FSCreationClassName'
'Name'
'Caption'
'Description'
'Status'
'Path'
)
} finally {
Remove-CimSession -CimSession $cimSession
}WSMan (WinRM) is used by default. For a host without WinRM, create the session with -SessionOption (New-CimSessionOption -Protocol Dcom). Add -Credential to use another account.
Show the class structure
# Class structure: properties, types and flags (Key, ReadOnly…)
$cimClass = Get-CimClass -ClassName CIM_LogicalFile
$cimClass.CimClassProperties |
Select-Object -Property Name, CimType, FlagsProperties
| Name | Type | Access | Description | |||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| AccessMask# | uint32 | read | Bitmask that represents the access rights required to access or perform specific operations on the file. For bit values, see File and Directory Access Rights Constants. Note: On FAT volumes, the FULL_ACCESS value is returned instead, which indicates no security has been set on the object. Values (14)
Code | |||||||||||||||||||||||||||||||||||||||||||||
| Archive# | boolean | read | If True, the file should be archived. Code | |||||||||||||||||||||||||||||||||||||||||||||
| Caption# | string | read | A short textual description of the object. Code | |||||||||||||||||||||||||||||||||||||||||||||
| Compressed# | boolean | read | If True, the file is compressed. Code | |||||||||||||||||||||||||||||||||||||||||||||
| CompressionMethod# | string | read | Free-form string that indicates the algorithm or tool used to compress the logical file. If the compression scheme is unknown or not described, use "Unknown". If the logical file is compressed, but the compression scheme is unknown or not described, use "Compressed". If the logical file is not compressed, use "Not Compressed". Code | |||||||||||||||||||||||||||||||||||||||||||||
| CreationClassName# key | string | read | Name of the class. Code | |||||||||||||||||||||||||||||||||||||||||||||
| CreationDate# | datetime | read | Date and time of the file's creation. Code | |||||||||||||||||||||||||||||||||||||||||||||
| CSCreationClassName# key | string | read | Class of the computer system. Code | |||||||||||||||||||||||||||||||||||||||||||||
| CSName# key | string | read | Name of the computer system. Code | |||||||||||||||||||||||||||||||||||||||||||||
| Description# | string | read | A textual description of the object. Code | |||||||||||||||||||||||||||||||||||||||||||||
| Drive# | string | read | Drive letter (including the colon that follows the drive letter) of the file. This property is inherited from CIM_LogicalFile.Example: "c:" Code | |||||||||||||||||||||||||||||||||||||||||||||
| EightDotThreeFileName# | string | read | DOS-compatible file name. Example: "c:\progra~1" Code | |||||||||||||||||||||||||||||||||||||||||||||
| Encrypted# | boolean | read | If True, the file is encrypted. Code | |||||||||||||||||||||||||||||||||||||||||||||
| EncryptionMethod# | string | read | Free-form string that identifies the algorithm or tool used to encrypt a logical file. If the encryption scheme is not indulged (for security reasons, for example), use "Unknown". If the file is encrypted, but either its encryption scheme is unknown or not disclosed, use "Encrypted". If the logical file is not encrypted, use "Not Encrypted". Code | |||||||||||||||||||||||||||||||||||||||||||||
| Extension# | string | read | File name extension without the preceding period (dot). Example: "txt", "mof", "mdb" Code | |||||||||||||||||||||||||||||||||||||||||||||
| FileName# | string | read | File name without the file name extension. Example: "MyDataFile" Code | |||||||||||||||||||||||||||||||||||||||||||||
| FileSize# | uint64 | read | Size of the file, in bytes. For more information about using uint64 values in scripts, see Scripting in WMI. Unit: bytes Code | |||||||||||||||||||||||||||||||||||||||||||||
| FileType# | string | read | Descriptor that represents the file type indicated by the Extension property. Code | |||||||||||||||||||||||||||||||||||||||||||||
| FSCreationClassName# key | string | read | Class of the file system. Code | |||||||||||||||||||||||||||||||||||||||||||||
| FSName# key | string | read | Name of the file system. Code | |||||||||||||||||||||||||||||||||||||||||||||
| InstallDate# | datetime | read | Indicates when the object was installed. Lack of a value does not indicate that the object is not installed. Code | |||||||||||||||||||||||||||||||||||||||||||||
| InUseCount# | uint64 | read | Number of "file opens" that are currently active against the file. For more information about using uint64 values in scripts, see Scripting in WMI. Code | |||||||||||||||||||||||||||||||||||||||||||||
| LastAccessed# | datetime | read | Date and time the file was last accessed. Code | |||||||||||||||||||||||||||||||||||||||||||||
| LastModified# | datetime | read | Date and time the file was last modified. Code | |||||||||||||||||||||||||||||||||||||||||||||
| Name# key | string | read | The Name property is a string representing the inherited name that serves as a key of a logical file instance within a file system. Full path names should be provided. Example: C:\Windows\system\win.ini Code | |||||||||||||||||||||||||||||||||||||||||||||
| Path# | string | read | Path of the file including the leading and trailing backslashes. Example: "\windows\system\" Code | |||||||||||||||||||||||||||||||||||||||||||||
| Readable# | boolean | read | If True, the file can be read. Code | |||||||||||||||||||||||||||||||||||||||||||||
| Status# | string | read | String that indicates the current status of the object. Operational and non-operational status can be defined. Operational status can include "OK", "Degraded", and "Pred Fail". "Pred Fail" indicates that an element is functioning properly, but is predicting a failure (for example, a SMART-enabled hard disk drive). Non-operational status can include "Error", "Starting", "Stopping", and "Service". "Service" can apply during disk mirror-resilvering, reloading a user permissions list, or other administrative work. Not all such work is online, but the managed element is neither "OK" nor in one of the other states. Values include the following: Values (12)
Code | |||||||||||||||||||||||||||||||||||||||||||||
| System# | boolean | read | If True, the file is a system file. Code | |||||||||||||||||||||||||||||||||||||||||||||
| Writeable# | boolean | read | If True, the file can be written. Code |
Remarks
The CIM_LogicalFile class is derived from CIM_LogicalElement.
WMI does not implement this class. For classes derived from CIM_LogicalFile, see Win32 Classes.
This documentation is derived from the CIM class descriptions published by the DMTF. Microsoft may have made changes to correct minor errors, conform to Microsoft SDK documentation standards, or provide more information.
Inheritance
Superclass chain
- CIM_ManagedSystemElement
- CIM_LogicalElement
- CIM_LogicalFile
Known subclasses
Requirements
- Namespace
- root/cimv2
- Minimum client
- Windows Vista
- Minimum server
- Windows Server 2008
- Provider
- CIMWin32
- MOF file
- CIMWin32.mof
- DLL
- CIMWin32.dll
Class qualifiers
SupportsDelete DeleteBy("DeleteInstance") Abstract Provider("CIMWin32") UUID("{8502C559-5FBB-11D2-AAC1-006008C78BC7}") DisplayName("Files (CIM)") AMENDMENT
Microsoft source
Descriptions, properties and methods come from the Microsoft documentation (MicrosoftDocs/win32 repository), published under the CC BY 4.0 licence. Formatting and translations are specific to this site; the PowerShell examples are written for it.