Feature Development Help From PowerShell


In my last post, I wrote about using WSPBuilder to automate the process of creating the manifest.xml and solution.ddf files.  But what about the elements.xml file in your feature? 

For a lot of my customers doing WCM solutions on MOSS, they are deploying features that provision all of their branding assets into their site.  This includes, sometimes, hundreds of image, javascript, and css files.  By the end of the day, I am pretty sick of writing

<File Url=SiteCollectionImages/logo.gif Type=GhostableInLibrary />

Enter PowerShell…. Here’s a little script that has helped me keep some sanity:

cd “c:\prjs\Microsoft.SharePoint\TEMPLATE\FEATURES\BrandingFiles\SiteCollectionImages”

Get-ChildItem  | 
%{ WRITE-OUTPUT  “<File Url=””$_”” Type=””GhostableInLibrary”” />” }  > c:\files.txt

The script kicks out all of the filenames formatted in XML.  Nothing really new to the PowerShell world, but just thought I’d share this little script that saved me a couple hours of work.

sitecolimages


Skip to main content