0

I have been working on a powershell sync script that will be used to control what users have on their desktop (mainly lnk/shortcut files). I have it currently setup to do basic comparisons to add/remove/update the files that are stored locally. The main problem that I am running into is that I don't have a good way to differentiate between deployed links and user created links. Depending on how I sync the files, I run into problems.

Problem 1: If I force the client location to stay in sync with the server, everything on the desktop gets wiped out every time the script is run.

Problem 2: If I don't force a client side sync, when I change/remove a file, the client side retains the files.

So if that makes any sense, I'm hoping someone knows of a way to flag the files that I send down to the local computer. I could then build my script to look for that flag and only affect deployed files.

Doltknuckle
  • 1,254
  • 7
  • 25
  • 32
  • Dennis' suggestion is a good one, but I have to chime in because I was trying to do this a few months ago and wound up approaching the underlying problem differently - if you don't mind, can you provide more context for why you're trying to do this? Maybe we had similar situations. – Doug Chase Nov 02 '09 at 16:05
  • I am trying to build a way to sync our favorites from our network drive to our local machine. We are probably going to be using folder redirection to make it work. – Doltknuckle Feb 04 '10 at 22:28

2 Answers2

1

I wonder if using Get-Acl and Set-Acl on the Group property of the files would be a valid way to flag the files for your needs.

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
  • This would probably work as a last resort. My only problem with using permissions is that your tracking info can be easily destroyed by a permission reset. Something that our company does for some reason... In other places, this would probably work. – Doltknuckle Feb 04 '10 at 22:24
0

If all your machines are using NTFS formatted drives then you could use an alternate data stream to store a message that marks the links that your script added.

Custom class method (PowerShell v2):

http://poshcode.org/1430

COM method:

http://groups.google.de/group/microsoft.public.windows.powershell/msg/66697a0aba7ab9ec

Another option is to write a message into some unused metadata item. Here is an example using the TagLib library in PowerShell:

http://huddledmasses.org/editing-media-tags-from-powershell/

Here is another example using COM, but the code does a lot of stuff that could be done by standard PowerShell commands:

http://www.vistax64.com/powershell/70760-accessing-metadata.html

Focus on the use of these lines:

$shellApp = new-object -com shell.application
$myFolder = $shellApp.Namespace($dir)
$fileobj = $myFolder.Items().Item($file)
...
$v = $myFolder.GetDetailsOf($fileobj,$i)
JasonMArcher
  • 125
  • 4
  • It looks like that in windows 7, and possibly Vista, they added meta data support for files to where you can add descriptions and such. In that case, I can simply add data to these fields to make it work. Thanks for the input. – Doltknuckle Feb 04 '10 at 22:23