I am new to CIM technology and its usability in Powershell. I am trying to copy all txt files from FolderA to FolderB. Both files are located on the root of C.
The script runs successfully with return code 2 with is “Access denied”. I have checked the folder permissions to which full control is granted to administrator. Also I am running PowerShell ISE as admin. Following is my scripting
$query= "SELECT * FROM CIM_LogicalFile WHERE Path= ‘\folderA\’ AND Extension = ‘txt’ "
$obj = Get-WmiObject -ComputerName “localhost” -Query $query
$obj.Copy(“C:\folderB”)
Can I change the destination to network shared folder i.e. move or copy the folder to network shared folder. I have tried this with following script, the script runs successfully but return code is 9 i.e. invalid object.
$query= "SELECT * FROM CIM_LogicalFile WHERE Path= ‘\folderA\’ AND Extension = ‘txt’ "