CIM_DataFile

CIM Data File
root/cimv2dynamickey : Name

The CIM_DataFile class represents a named collection of data or executable code. Only instances of files on local fixed disks will be returned.

On this page

Main example

List instances

# All instances of CIM_DataFile, with the main properties
Get-CimInstance -ClassName CIM_DataFile |
    Select-Object -Property @(
        'CSName'
        'FSCreationClassName'
        'Name'
        'Caption'
        'Description'
        'Status'
        'Manufacturer'
    )

Examples

Filter with WQL

# WQL filter evaluated by the provider: AccessMask = 1 (FILE_READ_DATA (file) or FILE_LIST_DIRECTORY (directory))
Get-CimInstance -ClassName CIM_DataFile -Filter 'AccessMask = 1' |
    Select-Object -Property @(
        'CSName'
        'FSCreationClassName'
        'Name'
        'Caption'
        'Description'
        'Status'
        'Manufacturer'
    )

The filter is evaluated by the WMI provider: less data is transferred than with Where-Object.

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_DataFile |
    Select-Object -Property @(
        'CSName'
        'FSCreationClassName'
        'Name'
        'Caption'
        'Description'
        'Status'
        'Manufacturer'
    )

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_DataFile |
        Select-Object -Property @(
            'CSName'
            'FSCreationClassName'
            'Name'
            'Caption'
            'Description'
            'Status'
            'Manufacturer'
        )
} 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_DataFile
$cimClass.CimClassProperties |
    Select-Object -Property Name, CimType, Flags

# Methods of the class
$cimClass.CimClassMethods |
    Select-Object -Property Name, ReturnType

Properties

33 of 33 properties
NameTypeAccessDescription
AccessMaskuint32read

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)
ValueLabelDescription
1FILE_READ_DATA (file) or FILE_LIST_DIRECTORY (directory)
2FILE_WRITE_DATA (file) or FILE_ADD_FILE (directory)
4FILE_APPEND_DATA (file) or FILE_ADD_SUBDIRECTORY (directory)
8FILE_READ_EA
16FILE_WRITE_EA
32FILE_EXECUTE (file) or FILE_TRAVERSE (directory)
64FILE_DELETE_CHILD (directory)
128FILE_READ_ATTRIBUTES
256FILE_WRITE_ATTRIBUTES
65536DELETE
131072READ_CONTROL
262144WRITE_DAC
524288WRITE_OWNER
1048576SYNCHRONIZE
Code
# Value of AccessMask for each instance
# 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_DataFile -Property CSName, FSCreationClassName, AccessMask |
    Select-Object -Property @(
        'CSName'
        'FSCreationClassName'
        @{ Name = 'AccessMask'; Expression = { $accessMaskName[[int]$_.AccessMask] } }
    )
Archivebooleanread

If True, the file should be archived.

Code
# Value of Archive for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, Archive |
    Select-Object -Property CSName, FSCreationClassName, Archive
Captionstringread

A short textual description of the object.

Code
# Value of Caption for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, Caption |
    Select-Object -Property CSName, FSCreationClassName, Caption
Compressedbooleanread

If True, the file is compressed.

Code
# Value of Compressed for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, Compressed |
    Select-Object -Property CSName, FSCreationClassName, Compressed
CompressionMethodstringread

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
# Value of CompressionMethod for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, CompressionMethod |
    Select-Object -Property CSName, FSCreationClassName, CompressionMethod
CreationClassName keystringread

Name of the class.

Code
# Value of CreationClassName for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, CreationClassName |
    Select-Object -Property CSName, FSCreationClassName, CreationClassName
CreationDatedatetimeread

Date and time of the file's creation.

Code
# Value of CreationDate for each instance
# CIM cmdlets already return a DateTime object: no conversion is needed
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, CreationDate |
    Select-Object -Property CSName, FSCreationClassName, CreationDate
CSCreationClassName keystringread

Class of the computer system.

Code
# Value of CSCreationClassName for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, CSCreationClassName |
    Select-Object -Property CSName, FSCreationClassName, CSCreationClassName
CSName keystringread

Name of the computer system.

Code
# Value of CSName for each instance
Get-CimInstance -ClassName CIM_DataFile -Property FSCreationClassName, CSName |
    Select-Object -Property FSCreationClassName, CSName
Descriptionstringread

A textual description of the object.

Code
# Value of Description for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, Description |
    Select-Object -Property CSName, FSCreationClassName, Description
Drivestringread

Drive letter (including the colon that follows the drive letter) of the file.

Example: "c:"

Code
# Value of Drive for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, Drive |
    Select-Object -Property CSName, FSCreationClassName, Drive
EightDotThreeFileNamestringread

DOS-compatible file name.

Example: "c:\progra~1"

Code
# Value of EightDotThreeFileName for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, EightDotThreeFileName |
    Select-Object -Property CSName, FSCreationClassName, EightDotThreeFileName
Encryptedbooleanread

If True, the file is encrypted.

Code
# Value of Encrypted for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, Encrypted |
    Select-Object -Property CSName, FSCreationClassName, Encrypted
EncryptionMethodstringread

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
# Value of EncryptionMethod for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, EncryptionMethod |
    Select-Object -Property CSName, FSCreationClassName, EncryptionMethod
Extensionstringread

File name extension without the preceding period (dot).

Example: "txt", "mof", "mdb"

Code
# Value of Extension for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, Extension |
    Select-Object -Property CSName, FSCreationClassName, Extension
FileNamestringread

File name without the file name extension. Example: "MyDataFile"

Code
# Value of FileName for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, FileName |
    Select-Object -Property CSName, FSCreationClassName, FileName
FileSizeuint64read

Size of the file, in bytes.

For more information about using uint64 values in scripts, see Scripting in WMI.

Unit: bytes

Code
# Value of FileSize for each instance
# FileSize is expressed in bytes: converted to GB
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, FileSize |
    Select-Object -Property @(
        'CSName'
        'FSCreationClassName'
        @{ Name = 'FileSizeGB'; Expression = { [math]::Round($_.FileSize / 1GB, 2) } }
    )
FileTypestringread

Descriptor that represents the file type indicated by the Extension property.

Code
# Value of FileType for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, FileType |
    Select-Object -Property CSName, FSCreationClassName, FileType
FSCreationClassName keystringread

Class of the file system.

Code
# Value of FSCreationClassName for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName |
    Select-Object -Property CSName, FSCreationClassName
FSName keystringread

Name of the file system.

Code
# Value of FSName for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, FSName |
    Select-Object -Property CSName, FSCreationClassName, FSName
Hiddenbooleanread

If True, the file is hidden.

Code
# Value of Hidden for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, Hidden |
    Select-Object -Property CSName, FSCreationClassName, Hidden
InstallDatedatetimeread

Indicates when the object was installed. Lack of a value does not indicate that the object is not installed.

Code
# Value of InstallDate for each instance
# CIM cmdlets already return a DateTime object: no conversion is needed
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, InstallDate |
    Select-Object -Property CSName, FSCreationClassName, InstallDate
InUseCountuint64read

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
# Value of InUseCount for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, InUseCount |
    Select-Object -Property CSName, FSCreationClassName, InUseCount
LastAccesseddatetimeread

Date and time the file was last accessed.

Code
# Value of LastAccessed for each instance
# CIM cmdlets already return a DateTime object: no conversion is needed
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, LastAccessed |
    Select-Object -Property CSName, FSCreationClassName, LastAccessed
LastModifieddatetimeread

Date and time the file was last modified.

Code
# Value of LastModified for each instance
# CIM cmdlets already return a DateTime object: no conversion is needed
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, LastModified |
    Select-Object -Property CSName, FSCreationClassName, LastModified
Manufacturerstringread

Manufacturer string from the version resource (if one is present).

Code
# Value of Manufacturer for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, Manufacturer |
    Select-Object -Property CSName, FSCreationClassName, Manufacturer
Name keystringread

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
# Value of Name for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, Name |
    Select-Object -Property CSName, FSCreationClassName, Name
Pathstringread

Path of the file including the leading and trailing backslashes. Example: "\windows\system\"

Code
# Value of Path for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, Path |
    Select-Object -Property CSName, FSCreationClassName, Path
Readablebooleanread

If True, the file can be read.

Code
# Value of Readable for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, Readable |
    Select-Object -Property CSName, FSCreationClassName, Readable
Statusstringread

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)
ValueLabelDescription
OKOK
ErrorError
DegradedDegraded
UnknownUnknown
Pred FailPred Fail
StartingStarting
StoppingStopping
ServiceService
StressedStressed
NonRecoverNonRecover
No ContactNo Contact
Lost CommLost Comm
Code
# Value of Status for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, Status |
    Select-Object -Property CSName, FSCreationClassName, Status
Systembooleanread

If True, the file is a system file.

Code
# Value of System for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, System |
    Select-Object -Property CSName, FSCreationClassName, System
Versionstringread

Version string from the version resource (if one is present).

Code
# Value of Version for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, Version |
    Select-Object -Property CSName, FSCreationClassName, Version
Writeablebooleanread

If True, the file can be written.

Code
# Value of Writeable for each instance
Get-CimInstance -ClassName CIM_DataFile -Property CSName, FSCreationClassName, Writeable |
    Select-Object -Property CSName, FSCreationClassName, Writeable

Methods

ChangeSecurityPermissions #

Changes the security permissions for the logical file specified in the object path. Implemented by WMI.

uint32 ChangeSecurityPermissions([in] Win32_SecurityDescriptor SecurityDescriptor, [in] uint32 Option);

Parameters

ParameterTypeDirectionDescription
SecurityDescriptorWin32_SecurityDescriptorin

Specifies the security information.

Note: A NULL access control list (ACL) in the SECURITY_DESCRIPTOR structure grants unlimited access. For information about the implications of unlimited access, see Creating a Security Descriptor for a New Object.

Optionuint32in

Security privilege to modify. For example, to change the owner and DACL security, use:

Option = 1 + 4

or

Option = CHANGE_OWNER_SECURITY_INFORMATION | CHANGE_DACL_SECURITY_INFORMATION

Return values

ValueLabelDescription
0Success
2Access Denied
8Unspecified failure
9Invalid object
10Object already exists
11File system not NTFS
12Platform not NT/Windows 2000Platform not Windows NT-based.
13Drive not the same
14Directory not empty
15Sharing violation
16Invalid start file
17Privilege not held
21Invalid parameter

Call the ChangeSecurityPermissions method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName CIM_DataFile -Filter "CSName = 'Example'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'ChangeSecurityPermissions'
    Arguments   = @{
        SecurityDescriptor = $null
        Option             = 1
    }
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Success'
        2 = 'Access Denied'
        8 = 'Unspecified failure'
        9 = 'Invalid object'
        10 = 'Object already exists'
        11 = 'File system not NTFS'
        12 = 'Platform not NT/Windows 2000'
        13 = 'Drive not the same'
        14 = 'Directory not empty'
        15 = 'Sharing violation'
        16 = 'Invalid start file'
        17 = 'Privilege not held'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

ChangeSecurityPermissionsEx #

Changes the security permissions for the logical file specified in the object path. Implemented by WMI.

uint32 ChangeSecurityPermissionsEx(
    [in] Win32_SecurityDescriptor SecurityDescriptor,
    [in] uint32 Option,
    [out] string StopFileName,
    [in] string StartFileName,
    [in] boolean Recursive
);

Parameters

ParameterTypeDirectionDescription
SecurityDescriptorWin32_SecurityDescriptorin

Specifies security information.

Note: A NULL ACL in the SECURITY_DESCRIPTOR structure grants unlimited access. For more information about the implications of unlimited access, see Creating a Security Descriptor for a New Object.

Optionuint32in

Security privilege to modify. For example, to change the owner and DACL security, use:

Option = 1 + 4 or Option = CHANGE_OWNER_SECURITY_INFORMATION | CHANGE_DACL_SECURITY_INFORMATION

StopFileNamestringout

String that represents the name of the file (or directory) where the method failed. This parameter is null if the method succeeds.

StartFileNamestringin

String that represents the child file (or directory) to use as a starting point for this method. Typically, the *StartFileName* parameter is the *StopFileName* parameter specifying the file or directory at which an error occurred from the previous method call. If this parameter is null, the operation is performed on the file (or directory) specified in the ExecMethod call.

If *StartFileName* is used, *Recursive* must be set to true as well.

Recursivebooleanin

If True, the method is also applied recursively to files and directories within the directory that is specified by the CIM_DataFile instance. For file instances, this parameter is ignored.

Return values

ValueLabelDescription
0Success
2Access Denied
8Unspecified failure
9Invalid objectObject name specified is not valid.
10Object already exists
11File system not NTFS
12Platform not NT/Windows 2000Platform not Windows.
13Drive not the same
14Directory not empty
15Sharing violation
16Invalid start fileThe start file is not valid.
17Privilege not held
21Invalid parameterA parameter is not valid.

Call the ChangeSecurityPermissionsEx method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName CIM_DataFile -Filter "CSName = 'Example'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'ChangeSecurityPermissionsEx'
    Arguments   = @{
        SecurityDescriptor = $null
        Option             = 1
        StartFileName      = 'Example'
        Recursive          = $false
    }
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Success'
        2 = 'Access Denied'
        8 = 'Unspecified failure'
        9 = 'Invalid object'
        10 = 'Object already exists'
        11 = 'File system not NTFS'
        12 = 'Platform not NT/Windows 2000'
        13 = 'Drive not the same'
        14 = 'Directory not empty'
        15 = 'Sharing violation'
        16 = 'Invalid start file'
        17 = 'Privilege not held'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
    $result.StopFileName
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

Compress #

Uses NTFS compression to compress the logical file (or directory) specified in the object path. Implemented by WMI.

uint32 Compress();

Return values

ValueLabelDescription
0Success.
2Access denied.
8Unspecified failure.
9Invalid object.
10Object already exists.
11File system not NTFS.
12Platform not Windows.
13Drive not the same.
14Directory not empty.
15Sharing violation.
16Invalid start file.
17Privilege not held.
21Invalid parameter.

Call the Compress method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName CIM_DataFile -Filter "CSName = 'Example'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'Compress'
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Success'
        2 = 'Access denied'
        8 = 'Unspecified failure'
        9 = 'Invalid object'
        10 = 'Object already exists'
        11 = 'File system not NTFS'
        12 = 'Platform not Windows'
        13 = 'Drive not the same'
        14 = 'Directory not empty'
        15 = 'Sharing violation'
        16 = 'Invalid start file'
        17 = 'Privilege not held'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

CompressEx #

Compresses the logical file (or directory) specified in the object path. Implemented by WMI.

uint32 CompressEx(
    [out] string StopFileName,
    [in] string StartFileName,
    [in] boolean Recursive
);

Parameters

ParameterTypeDirectionDescription
StopFileNamestringout

String that represents the name of the file (or directory) where the method failed. This parameter is null if the method succeeds.

StartFileNamestringin

String that represents the child file (or directory) to use as a starting point for this method. Typically, the *StartFileName* parameter is the *StopFileName* parameter that specifies the file or directory at which an error occurred from the previous method call. If this parameter is null, the operation is performed on the file or directory specified in the ExecMethod call.

If *StartFileName* is used, *Recursive* must be set to true as well.

Recursivebooleanin

If TRUE, the method is also applied recursively to files and directories within the directory specified by the CIM_DataFile instance. For file instances, this parameter is ignored.

Return values

ValueLabelDescription
0Success.
2Access denied.
8Unspecified failure.
9Invalid object.
10Object already exists.
11File system not NTFS.
12Platform not Windows.
13Drive not the same.
14Directory not empty.
15Sharing violation.
16Invalid start file.
17Privilege not held.
21Invalid parameter.

Call the CompressEx method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName CIM_DataFile -Filter "CSName = 'Example'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'CompressEx'
    Arguments   = @{
        StartFileName = 'Example'
        Recursive     = $false
    }
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Success'
        2 = 'Access denied'
        8 = 'Unspecified failure'
        9 = 'Invalid object'
        10 = 'Object already exists'
        11 = 'File system not NTFS'
        12 = 'Platform not Windows'
        13 = 'Drive not the same'
        14 = 'Directory not empty'
        15 = 'Sharing violation'
        16 = 'Invalid start file'
        17 = 'Privilege not held'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
    $result.StopFileName
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

Copy #

Copies the logical file (or directory) specified in the object path to the location specified by the input parameter. Implemented by WMI.

uint32 Copy([in] string FileName);

Parameters

ParameterTypeDirectionDescription
FileNamestringin

Fully qualified name of the destination file (or directory).

Example: "c:\temp\newdirectory"

Return values

ValueLabelDescription
0Success.
2Access denied.
8Unspecified failure.
9Invalid object.
10Object already exists.
11File system not NTFS.
12Platform not Windows.
13Drive not the same.
14Directory not empty.
15Sharing violation.
16Invalid start file.
17Privilege not held.
21Invalid parameter.

Call the Copy method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName CIM_DataFile -Filter "CSName = 'Example'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'Copy'
    Arguments   = @{ FileName = 'Example' }
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Success'
        2 = 'Access denied'
        8 = 'Unspecified failure'
        9 = 'Invalid object'
        10 = 'Object already exists'
        11 = 'File system not NTFS'
        12 = 'Platform not Windows'
        13 = 'Drive not the same'
        14 = 'Directory not empty'
        15 = 'Sharing violation'
        16 = 'Invalid start file'
        17 = 'Privilege not held'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

CopyEx #

Copies the logical file (or directory) specified in the object path to the location specified by the input parameter. Implemented by WMI.

uint32 CopyEx(
    [in] string FileName,
    [out] string StopFileName,
    [in] string StartFileName,
    [in] boolean Recursive
);

Parameters

ParameterTypeDirectionDescription
FileNamestringin

Fully qualified name of the destination file (or directory).

Example: "c:\temp\newdirectory"

StopFileNamestringout

String that represents the name of the file (or directory) where the method failed. This parameter will be null if the method succeeds.

StartFileNamestringin

String that represents the child file (or directory) to use as a starting point for this method. Typically, the *StartFileName* parameter is the *StopFileName* parameter specifying the file (or directory) at which an error occurred from the previous method call. If this parameter is null, the operation is performed on the file (or directory) specified in the ExecMethod call.

If *StartFileName* is used, *Recursive* must be set to true as well.

Recursivebooleanin

If TRUE, the method is also applied recursively to files and directories within the directory specified by the CIM_DataFile instance. For file instances, this parameter is ignored.

Call the CopyEx method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName CIM_DataFile -Filter "CSName = 'Example'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'CopyEx'
    Arguments   = @{
        FileName      = 'Example'
        StartFileName = 'Example'
        Recursive     = $false
    }
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $result.ReturnValue
    $result.StopFileName
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

Delete #

Deletes the logical file (or directory) specified in the object path. Implemented by WMI.

uint32 Delete();

Return values

ValueLabelDescription
0Success.
2Access denied.
8Unspecified failure.
9Invalid object.
10Object already exists.
11File system not NTFS.
12Platform not Windows.
13Drive not the same.
14Directory not empty.
15Sharing violation.
16Invalid start file.
17Privilege not held.
21Invalid parameter.

Call the Delete method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName CIM_DataFile -Filter "CSName = 'Example'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'Delete'
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Success'
        2 = 'Access denied'
        8 = 'Unspecified failure'
        9 = 'Invalid object'
        10 = 'Object already exists'
        11 = 'File system not NTFS'
        12 = 'Platform not Windows'
        13 = 'Drive not the same'
        14 = 'Directory not empty'
        15 = 'Sharing violation'
        16 = 'Invalid start file'
        17 = 'Privilege not held'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

DeleteEx #

Deletes the logical file (or directory) specified in the object path. Implemented by WMI.

uint32 DeleteEx([out] string StopFileName, [in] string StartFileName);

Parameters

ParameterTypeDirectionDescription
StopFileNamestringout

String that represents the name of the file (or directory) where the method failed. This parameter is null if the method succeeds.

StartFileNamestringin

String that represents the child file (or directory) to use as a starting point for this method. Typically, the *StartFileName* parameter is the *StopFileName* parameter specifying the file or directory at which an error occurred from the previous method call. If this parameter is null, the operation is performed on the file (or directory) specified in the ExecMethod call.

Call the DeleteEx method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName CIM_DataFile -Filter "CSName = 'Example'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'DeleteEx'
    Arguments   = @{ StartFileName = 'Example' }
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $result.ReturnValue
    $result.StopFileName
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

GetEffectivePermission #

Determines whether the caller has the aggregated permissions specified by the Permission argument. Implemented by WMI.

boolean GetEffectivePermission([in] uint32 Permissions);

Parameters

ParameterTypeDirectionDescription
Permissionsuint32in

List of permissions that the caller can inquire about.

Call the GetEffectivePermission method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName CIM_DataFile -Filter "CSName = 'Example'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'GetEffectivePermission'
    Arguments   = @{ Permissions = 0 }
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $result.ReturnValue
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

Rename #

Renames the logical file (or directory) specified in the object path. Implemented by WMI.

uint32 Rename([in] string FileName);

Parameters

ParameterTypeDirectionDescription
FileNamestringin

Fully qualified new name of the file (or directory).

Example: "c:\temp\newfile.txt"

Return values

ValueLabelDescription
0Success.
2Access denied.
8Unspecified failure.
9Invalid object.
10Object already exists.
11File system not NTFS.
12Platform not Windows.
13Drive not the same.
14Directory not empty.
15Sharing violation.
16Invalid start file.
17Privilege not held.
21Invalid parameter.

Call the Rename method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName CIM_DataFile -Filter "CSName = 'Example'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'Rename'
    Arguments   = @{ FileName = 'Example' }
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Success'
        2 = 'Access denied'
        8 = 'Unspecified failure'
        9 = 'Invalid object'
        10 = 'Object already exists'
        11 = 'File system not NTFS'
        12 = 'Platform not Windows'
        13 = 'Drive not the same'
        14 = 'Directory not empty'
        15 = 'Sharing violation'
        16 = 'Invalid start file'
        17 = 'Privilege not held'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

TakeOwnerShip #

Obtains ownership of the logical file specified in the object path. Implemented by WMI.

uint32 TakeOwnerShip();

Return values

ValueLabelDescription
0Success.
2Access denied.
8Unspecified failure.
9Invalid object.
10Object already exists.
11File system not NTFS.
12Platform not Windows.
13Drive not the same.
14Directory not empty.
15Sharing violation.
16Invalid start file.
17Privilege not held.
21Invalid parameter.

Call the TakeOwnerShip method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName CIM_DataFile -Filter "CSName = 'Example'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'TakeOwnerShip'
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Success'
        2 = 'Access denied'
        8 = 'Unspecified failure'
        9 = 'Invalid object'
        10 = 'Object already exists'
        11 = 'File system not NTFS'
        12 = 'Platform not Windows'
        13 = 'Drive not the same'
        14 = 'Directory not empty'
        15 = 'Sharing violation'
        16 = 'Invalid start file'
        17 = 'Privilege not held'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

TakeOwnerShipEx #

Obtains ownership of the logical file specified in the object path. Implemented by WMI.

uint32 TakeOwnerShipEx(
    [out] string StopFileName,
    [in] string StartFileName,
    [in] boolean Recursive
);

Parameters

ParameterTypeDirectionDescription
StopFileNamestringout

Name of the file (or directory) where the method failed. This parameter will be null if the method succeeds.

StartFileNamestringin

Child file (or directory) to use as a starting point for this method. Typically, the *StartFileName* parameter is the *StopFileName* parameter specifying the file (or directory) at which an error occurred from the previous method call. If this parameter is null, the operation is performed on the file (or directory) specified in the ExecMethod call.

If *StartFileName* is used, *Recursive* must be set to true as well.

Recursivebooleanin

If TRUE, the method is also applied recursively to files and directories within the directory that is specified by the CIM_DataFile instance. For file instances, this parameter is ignored.

Return values

ValueLabelDescription
0Success.
2Access denied.
8Unspecified failure.
9Invalid object.
10Object already exists.
11File system not NTFS.
12Platform not Windows.
13Drive not the same.
14Directory not empty.
15Sharing violation.
16Invalid start file.
17Privilege not held.
21Invalid parameter.

Call the TakeOwnerShipEx method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName CIM_DataFile -Filter "CSName = 'Example'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'TakeOwnerShipEx'
    Arguments   = @{
        StartFileName = 'Example'
        Recursive     = $false
    }
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Success'
        2 = 'Access denied'
        8 = 'Unspecified failure'
        9 = 'Invalid object'
        10 = 'Object already exists'
        11 = 'File system not NTFS'
        12 = 'Platform not Windows'
        13 = 'Drive not the same'
        14 = 'Directory not empty'
        15 = 'Sharing violation'
        16 = 'Invalid start file'
        17 = 'Privilege not held'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
    $result.StopFileName
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

Uncompress #

Uncompresses the logical file (or directory) specified in the object path. Implemented by WMI.

uint32 Uncompress();

Return values

ValueLabelDescription
0Success.
2Access denied.
8Unspecified failure.
9Invalid object.
10Object already exists.
11File system not NTFS.
12Platform not Windows.
13Drive not the same.
14Directory not empty.
15Sharing violation.
16Invalid start file.
17Privilege not held.
21Invalid parameter.

Call the Uncompress method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName CIM_DataFile -Filter "CSName = 'Example'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'Uncompress'
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Success'
        2 = 'Access denied'
        8 = 'Unspecified failure'
        9 = 'Invalid object'
        10 = 'Object already exists'
        11 = 'File system not NTFS'
        12 = 'Platform not Windows'
        13 = 'Drive not the same'
        14 = 'Directory not empty'
        15 = 'Sharing violation'
        16 = 'Invalid start file'
        17 = 'Privilege not held'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

UncompressEx #

Uncompresses the logical file (or directory) specified in the object path. Implemented by WMI.

uint32 UncompressEx(
    [out] string StopFileName,
    [in] string StartFileName,
    [in] boolean Recursive
);

Parameters

ParameterTypeDirectionDescription
StopFileNamestringout

Name of the file (or directory) where the method failed. This parameter is null if the method succeeds.

StartFileNamestringin

Child file (or directory) to use as a starting point for this method. Typically, the *StartFileName* parameter is the *StopFileName* parameter specifying the file (or directory) at which an error occurred from the previous method call. If this parameter is null, the operation is performed on the file (or directory) specified in the ExecMethod call.

If *StartFileName* is used, *Recursive* must be set to true as well.

Recursivebooleanin

If TRUE, the method is also applied recursively to files and directories within the directory that is specified by the CIM_DataFile instance. For file instances, this parameter is ignored.

Return values

ValueLabelDescription
0Success.
2Access denied.
8Unspecified failure.
9Invalid object.
10Object already exists.
11File system not NTFS.
12Platform not Windows.
13Drive not the same.
14Directory not empty.
15Sharing violation.
16Invalid start file.
17Privilege not held.
21Invalid parameter.

Call the UncompressEx method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName CIM_DataFile -Filter "CSName = 'Example'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'UncompressEx'
    Arguments   = @{
        StartFileName = 'Example'
        Recursive     = $false
    }
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Success'
        2 = 'Access denied'
        8 = 'Unspecified failure'
        9 = 'Invalid object'
        10 = 'Object already exists'
        11 = 'File system not NTFS'
        12 = 'Platform not Windows'
        13 = 'Drive not the same'
        14 = 'Directory not empty'
        15 = 'Sharing violation'
        16 = 'Invalid start file'
        17 = 'Privilege not held'
        21 = 'Invalid parameter'
    }
    $returnValueName[[int]$result.ReturnValue]
    $result.StopFileName
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

Remarks

The CIM_DataFile class is derived from CIM_LogicalFile.

WMI implements the CIM_DataFile class and all of its methods. The CIM_DataFile class is a dynamic class.

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.

Due to security purposes, WMI does not directly support calling a remote computer and instructing it to copy files to itself. However, you can use the relevant programming language to call FTP or RoboCopy, for example.

Inheritance

Superclass chain

  1. CIM_ManagedSystemElement
  2. CIM_LogicalElement
  3. CIM_LogicalFile
  4. CIM_DataFile

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

Dynamic Provider("CIMWin32") UUID("{8502C55A-5FBB-11D2-AAC1-006008C78BC7}") DisplayName("All Files (CIM)") AMENDMENT

Microsoft source

Source: Microsoft Learn

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.