As promised here are the PowerShell scripts I used in my session at ITForums in Barcelona Spain.
If you want to follow along with the demo script (demoScript.txt) you must place the files in the correct location or change the included demo script. Once the files are placed in the correct location on the SharePoint server you can copy and paste the commands from demoScript.txt to PowerShell.
To setup the environment to follow the demoScript.txt:
1) Copy DBGDesignLinks to the SharePoint server’s feature folder (12TemplateFeature). This simple feature will add two links to the Site Actions menu to access the Features management page.
2) Copy the code located in the Microsoft.PowerShell_profile.ps1 file to your profile.ps1 file. To locate your profile simply type in $profile at the PowerShell prompt. The Microsoft.PowerShell_profile.ps1 file contains some basic functions such as AddFeatureToWeb, RemoveFeatureToWeb as well as loading the SharePoint assembly and creating PSDrives. You will need to exit and restart PowerShell so PowerShell will load up the functions in the profile.
3) Copy the files located in the PSScripts folder to C: PSScripts. These script files are used in the demoScript.txt file to Create and Delete sub webs. There is also txt file that contains the information about the sub webs that will be created.
Once done, you can copy the commands from the demo script to recreate the demo. The basic demo will:
- Install a feature
- Create sub sites from a configuration file
- Add the feature to the sub sites
- Find the sub sites with the feature
- Remove the feature from the sub site
- Delete the sites
- Uninstall the feature.
Check back soon for a few more simple but powerfull PowerShell functions and filters that can be easily chained togehter to provide basic access to key SharePoint objects.