Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
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 2 '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 4 '10 at 22:28

2 Answers 2

up vote 0 down vote accepted

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)
share|improve this answer
    
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 4 '10 at 22:23

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.

share|improve this answer
    
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 4 '10 at 22:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.