Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Powershell Script to copy-items from user profiles for a backup

$
0
0

We have software upgrade coming up for a document management software we use, and I want\need to create a script that can copy the three specific files as a backup. Some of the machines are shared among several users, so I need to be able to copy these files, and ensure that they are backed up to a folder that easily identified as belonging to them.

The files live in %userprofile%\appdata\Roaming\imagenow and they're inscan.xml, imagenow.ini, and indevice.xml. There are dozens of other files in this directory that are not needed for the purpose needing to be backed up. I would like to be able to copy these three files using either batch files or powershell scripts. I would like to copy the files to a directory like C:\iNOW_BKUP\%USERNAME%\<files>

I have figured out how to find each file using:

Get-ChildItem -Path '\\computer\C$\Users\*\appdata\Roaming\imagenow\inscan.xml'

But the trick now is to figure out how to copy those items to identifiable directory.

I know I can store those in a Variable, like:

$Inscan = Get-ChildItem -Path '\\computer\C$\Users\*\appdata\Roaming\imagenow\inscan.xml'

I get fairly close with the following:

$Inscan | foreach {
Copy-Item -Path $_.Directory -Destination C:\temp\backup\$_.DirectoryName

but instead of having the file, I get userpath\inscan.xml$.DirectoryName. If I don't put $_.DirectoryName I get a single empty imagenow folder.

I am doing this from a server to a single machine, my goal would be to just run this locally on the machines we need to deploy the software upgrade to, creating a local backup of these files, perhaps even as part of a task sequence prior to the installation of the software.

The software is pretty cruddy in the fact that it creates these control files for each individual user, rather than computer based profile for the scanners and a server based settings for the user.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>