Here's what I'm attempting to do. Users save their PST files pretty much anywhere on the PC. When I rebuild it I would like this script to search the old computer for PST files and copy them to the new computer. Here is the script as it is and the error message I keep getting.
$strComputer = Read-Host 'Type In The Name Of The Remote Computer'
New-Item -ItemType Directory -Path C:\PSTBackup -Force
Get-WmiObject -Class CIM_DataFile -Filter "Drive='C:' And Extension='pst'" -ComputerName $strComputer |
% { Copy-Item $_.name -Destination C:\PSTBackup -WhatIf}
Error message:
Copy-Item : Cannot find path 'C:\documents and settings\username\local settings\application
data\microsoft\outlook\archive.pst' because it does not exist.
At line:3 char:5
+ % { Copy-Item $_.name -Destination C:\PSTBackup -WhatIf}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\documents an...ook\archive.pst:String) [Copy-Item], Ite
mNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
Any help in getting me to understand why it's not working correctly is appreciated.