When you're managing multiple SharePoint farms that rely on custom, in-house developed Powershell modules, keeping these modules up to date across the entire enterprise can be a tricky prospect. This is usually where I employ some Powershell with calls to XCopy.
XCopy is a very powerful tool for synching files between systems. As you can see from its documentation page, there are many command switches for it. The tricky thing is usually when you're trying to sync folders that contain Powershell scripts, but these scripts generate log files. You want to sync the .ps1 files, but not the .log files. How do we do that then?
This is where the /exclude: switch comes into play. You can create a text file containing the extensions you wish to exclude. Then you simply pass the text file to the /exclude: switch thus:
Its important to remember that the exclusion will do a simple path match on the values specified in exclusions.txt. As such, having the file content defined thus:
will exclude anything that matches ".log" somewhere in the path of the file e.g. files ending in ".logger", ".logs", ".log2, ".log" etc. will all be excluded from XCopy. This can be resolved by simply adding a backslash to the back of the extension thus:
Now XCopy will only ignore files with a ".log" extension.
Born and raised in South Africa during the 70's I got my start in computers when a game on my Sinclair ZX Spectrum crashed, revealing it's BASIC source code. The ZX had a whopping 48K of memory which was considered to be a lot in the Commodore Vic20 era, but more importantly, it had BASIC built into the soft touch keyboard. Teaching myself to program, I coded my first commercial application at age 15.
After graduating high school at 17, I joined the South African Air Force, graduating the Academy and becoming a Pilot with the rank of First Lieutenant by age 20. After serving my country for six years, I made my way back into computer software.
Continuing my education, I graduated Suma Cum Laude from the Computer Training Institute before joining First National Bank where my work won the Smithsonian Award for Technological Innovation in the field of Banking and Insurance. Soon I met Will Coleman from Amdahl SA, who introduced me to a little known programming language named Huron/ObjectStar. As fate would have it, this unknown language and Y2K brought me to the USA in 1998.
I got involved with SharePoint after playing around with the Beta for SharePoint Portal Server 2003. Leaving my career at Rexnord to become a consultant in 2004, I was first awarded the Microsoft Most Valuable Professional Award for SharePoint in 2005, becoming only the 9th MVP for WSS at the time. I fulfilled a life long dream by pledging allegiance to the Flag as a US citizen in 2006. I met the love of my life and became a private consultant in 2008. I was honored to receive my ninth MVP award for SharePoint Server in 2013.