locked
How to copy a file from remote machine to local machine using WMI in C++ or powershell? RRS feed

  • Question

  • Hi,

    I need to copy a file from remote machine to local machine using WMI or powershell. But am able to copy the file from one location to another in the remote machine but not to the local host.  I did the following,

    1. Established connection to remote machine using WMI (and in powershell)

    2. Executed command on remote machine and redirected the output to a file in the remote machine using 'Create' method of Win32_Process.

    But am not able to get the file from the remote machine inspite of giving the UNC path of my local host (destination file path) in the Copy method of CIM_DataFile like,

    WMI:   \\myhost\sharedrive\foldername

    Powerhsell: "Copy-Item -path C:\folder\file1.txt -destination \\myhost\shareddrive\foldername"

    Am getting path not found error.

    Please let me know if there is any solution for getting the remote file to local machine using WMI or powershell (without mapping the drive).  If sample code using WMI in C++  or any powershell command is available pls provide the same ASAP.

    Also let me know if it is possible to redirect the command output to local host using Create method of Win32_Process?

    Thanks in advance.

     

    Thursday, July 22, 2010 5:03 PM

Answers

All replies