Copy

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

The Copy method in CIM_DataFile is implemented by WMI.

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.

Example

Do not run below example code just to see what happens next. Many methods seriously affect your system. Always make sure you actually understand what the method and the code do.

param
(
  [Parameter(Mandatory)]
  [String]
  $FileName
)


$query = 'Select * From CIM_DataFile where Name='c:\\windows\\explorer.exe''

Invoke-CimMethod -Query $query -MethodName Copy -Arguments $PSBoundParameters

To run this method on one or more remote systems, use New-CimSession:

param
(
  [Parameter(Mandatory)]
  [String]
  $FileName,

  [String[]]
  $ComputerName,

  [PSCredential]
  $Credential
)


$session = New-CimSession -ComputerName $ComputerName -Credential $Credential

$query = 'Select * From CIM_DataFile where Name='c:\\windows\\explorer.exe''

Invoke-CimMethod -Query $query -MethodName Copy -Arguments $PSBoundParameters -CimSession $session

Remove-CimSession -CimSession $session

Learn more about Invoke-CimMethod and invoking WMI methods.

Syntax

uint32 Copy(
  [in] string FileName
);

Parameters

Name Type Description
FileName String  

Return Value

Returns a value of type UInt32. Typically, a value of 0 indicates success.

See Also

Additional methods implemented by CIM_DataFile:

ChangeSecurityPermissions()

ChangeSecurityPermissions() changes the security permissions for the logical file specified in the object path. Implemented by WMI.

ChangeSecurityPermissionsEx()

ChangeSecurityPermissionsEx() changes the security permissions for the logical file specified in the object path. Implemented by WMI.

Compress()

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

CompressEx()

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

CopyEx()

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

Delete()

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

DeleteEx()

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

GetEffectivePermission()

GetEffectivePermission() determines whether the caller has the aggregated permissions specified by the Permission argument. Implemented by WMI.

Rename()

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

TakeOwnerShip()

TakeOwnerShip() obtains ownership of the logical file specified in the object path. Implemented by WMI.

TakeOwnerShipEx()

TakeOwnerShipEx() obtains ownership of the logical file specified in the object path. Implemented by WMI.

Uncompress()

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

UncompressEx()

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

Requirements

To use CIM_DataFile, the following requirements apply:

PowerShell

Get-CimInstance was introduced with PowerShell Version 3.0, which in turn was introduced on clients with Windows 8 and on servers with Windows Server 2012.

If necessary, update Windows PowerShell to Windows PowerShell 5.1, or install PowerShell 7 side-by-side.

Operating System

CIM_DataFile was introduced on clients with Windows Vista and on servers with Windows Server 2008.

Namespace

CIM_DataFile lives in the Namespace Root/CIMV2. This is the default namespace. There is no need to use the -Namespace parameter in Get-CimInstance.

Implementation

CIM_DataFile is implemented in CIMWin32.dll and defined in CIMWin32.mof. Both files are located in the folder C:\Windows\system32\wbem:

explorer $env:windir\system32\wbem
notepad $env:windir\system32\wbem\CIMWin32.mof