April 8, 2014 by Ravi C Khambhati
This post going to be helpful for those who is struggling with SharePoint deployment and will make their life lot easier.
I will explain the approach with example. So lets assume that below is the only step which we have to perform as a part of deployment.(sounds funny but do not want to confuse anyone)
1. Delete list
So this whole approach is 3 steps process,
Step 1: Prepare Config.XML file
With this steps you will list down all configuration required for the deployment. As of now I am planing two things Log file and email. So here is the configuration. You can update this as per your requirement.
<?xml version="1.0" encoding="utf-8"?> <Configurations> <Log> <!-- if this value is true then folder will be created every day --> <IsLogFolder>true</IsLogFolder> <!-- format of folder for eg yyyy-dd-MM --> <LogFolderFormat>yyyy-MM-dd</LogFolderFormat> <!-- format of log file --> <FileFormat>yyyy-MM-dd_hhmmss</FileFormat> </Log> <Email> <!-- SMTP --> <Smtp>yoursmtp.wan</Smtp> </Email> </Configurations>
Step 2: Prepare Parameters.XML file
With this step you will list down all environment specific parameters which will be based on your environment(IT,UAT,PROD, etc…). In our case we only need one because that’s the only environment specific entry we need.
<?xml version="1.0" encoding="utf-8"?> <Parameters> <Parameter Name="$Url" Value ="yoururl" /> </Parameters>
Step 3: Prepare Operations.XML file
With this step you will list down all steps and prepare Operation.XML file. As mentioned earlier we are going to focus only on one steps. So here is the file for for the same,
<?xml version="1.0" encoding="utf-8"?> <Operations> <Operation Name="DeleteList"> <Parameters> <Parameter Name="URL" Value="$Url" /> <Parameter Name="InternalListName" Value="Test" /> </Parameters> </Operation> </Operations>
and that’s all we need. Once you have all this you are all set for deployment.
Now I have prepared PowerShell script which will perform all operations mentioned in Operations.XML file. As of now this script only support one operation and will continue to add more. You can also update as per your need. Basically this script has been dived in three files. I might divide Operations.ps1 into multiple files in future.
This script will accept three parameters(Config.XML, Parameters.XML and Operations.XML) and will perform below steps,
a. Read all operation
b. Replace operation parameters with actual value if required (in this example it will replace $Url with actual value)
c. Display operation name and parameters
d. Call respected function(which will be in Operation.ps1 file)
e. Log operation to log file
This script will have functions to do operations mentioned in Operation.XML file. Currently it has only one.
This script will have reusable functions which is being used in both of the above file.
Below is sample output of the screen,
Below is sample output of log file,
<?xml version='1.0' encoding='utf-8' ?> <Root> <Parameters> <Parameter Key='$Url' Value='yoururl' /> </Parameters> <Operations> <Operation Name='DeleteList' StartTime='2014-04-08 02:18:00' EndTime='2014-04-08 02:18:00'> <Parameters> <Parameter Key='URL' Value='yoururl' /> <Parameter Key='InternalListName' Value='Test' /> </Parameters> </Operation> </Operations> </Root>
Please share your input, suggestions, questions
You can download all three powershell files from below location(rename file extension from doc to ps1 as WordPress is not allowing me to upload ps1 file),