Skip to content

Commit

Permalink
deployment scripts - Feture, Site Collection and List Items
Browse files Browse the repository at this point in the history
  • Loading branch information
adiazcan committed May 22, 2014
1 parent 322f0c9 commit df5982d
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 0 deletions.
39 changes: 39 additions & 0 deletions SharePoint/Deployment/ActivateFeature.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
############################################################################################################################################
# Script para la activación de una Feature
# Parámetros necesarios:
# - Identidad de la Feature
# - URL del sitio
############################################################################################################################################


If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{ Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell }

#Hacemos un buen uso de PowerShell para no penalizar el rendimiento
$host.Runspace.ThreadOptions = "ReuseThread"

#Definición de la función que obtiene el tamaño de las BD's de contenidos
function Activate-Feature
{
param($sIdentity,$sWebUrl)
try
{
Enable-SPFeature -identity $sIdentity -URL $sWebUrl
}
catch [System.Exception]
{
write-host -f red $_.Exception.ToString()
}
}

Start-SPAssignment –Global
$sWebUrl="http://sf1"

$sIdentity="c3e7d105-d10b-4b81-a3f6-b1ea1b8974c0"
Activate-Feature -sIdentity $sIdentity -sWebUrl $sWebUrl

$sIdentity="b747d2ea-19de-41e3-b165-1b4772c85d32"
Activate-Feature -sIdentity $sIdentity -sWebUrl $sWebUrl

Stop-SPAssignment –Global
Remove-PsSnapin Microsoft.SharePoint.PowerShell
75 changes: 75 additions & 0 deletions SharePoint/Deployment/CreateListItemsFromCSV.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
############################################################################################################################################
# Script para creación de elementos de una lista desde un CSV
# Parámetros necesarios:
# - URL del sitio
# - Nombre de la lista
# - Ruta al fichero CSV
############################################################################################################################################


If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{ Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell }

#Hacemos un buen uso de PowerShell para no penalizar el rendimiento
$host.Runspace.ThreadOptions = "ReuseThread"

#Definición de la función que lee el CSV y lo carga en la lista
function Add-CsvDataToList()
{
param($sweb,$slistName,$scsvPath)

try
{
$web = Get-SPWeb -Identity $sweb
$list = $web.Lists.get_Item($slistName)
Import-Csv $scsvPath | ForEach-Object {
$csvRow = $_
$newItem = $list.Items.Add()
Get-Member -InputObject $csvRow -MemberType NoteProperty | ForEach-Object {
$property = $_.Name

if ($_.Name -eq "ENMARCHAReceiver")
{
$user = Get-SPUser -Identity $csvRow.$property -web $sweb
$newItem.set_Item($property, $user)
}
Elseif ($_.Name -eq "ENMARCHASender")
{
$user = Get-SPUser -Identity $csvRow.$property -web $sweb
$newItem.set_Item($property, $user)
}
Elseif ($_.Name -eq "ENMARCHAUser")
{
$user = Get-SPUser -Identity $csvRow.$property -web $sweb
$newItem.set_Item($property, $user)
}
Else
{
$newItem.set_Item($property, $csvRow.$property)
}
}
$newItem.Update()
}
}
catch [System.Exception]
{
write-host -f red $_.Exception.ToString()
}
}


Start-SPAssignment –Global

$sWebUrl="http://sf1"
$sListName="Notifications"
$sCSVPath="c:\deploy\notifications.csv"

Add-CsvDataToList -sweb $sWebUrl -slistName $sListName -scsvPath $sCSVPath

$sListName="Favorites"
$sCSVPath="c:\deploy\favorites.csv"

Add-CsvDataToList -sweb $sWebUrl -slistName $sListName -scsvPath $sCSVPath

Stop-SPAssignment –Global
Remove-PsSnapin Microsoft.SharePoint.PowerShell
50 changes: 50 additions & 0 deletions SharePoint/Deployment/RecreateSite.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
############################################################################################################################################
# Script para el borrado/creación de un Site Collection
# Parámetros necesarios:
# - URL del sitio
############################################################################################################################################


If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{ Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell }

#Hacemos un buen uso de PowerShell para no penalizar el rendimiento
$host.Runspace.ThreadOptions = "ReuseThread"

function Create-Site
{
param($sWebUrl)
try
{
New-SPSite -url $sWebUrl -template STS#0 -OwnerAlias “pharus\alberto.diaz“ -Name “Vitrall”
}
catch [System.Exception]
{
write-host -f red $_.Exception.ToString()
}
}

function Delete-Site
{
param($sWebUrl)
try
{
Remove-SPSite -Identity $sWebUrl -Confirm:$False
}
catch [System.Exception]
{
write-host -f red $_.Exception.ToString()
}
}


Start-SPAssignment –Global

$sWebUrl="http://sf1"

Delete-Site -sWebUrl $sWebUrl

Create-Site -sWebUrl $sWebUrl

Stop-SPAssignment –Global
Remove-PsSnapin Microsoft.SharePoint.PowerShell
13 changes: 13 additions & 0 deletions SharePoint/Deployment/favorites.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ENMARCHAProject,ENMARCHAProjectId,Title,ENMARCHAType,ENMARCHAUser
Project 1,1,Favorite 1,Search,Pharus\alberto.diaz
Project 2,2,Favorite 2,Search,Pharus\alberto.diaz
Project 3,3,Favorite 3,Search,Pharus\alberto.diaz
Project 3,3,Favorite 4,Search,Pharus\alberto.diaz
Project 3,3,Favorite 5,Search,Pharus\alberto.diaz
Project 3,3,Favorite 6,Search,Pharus\alberto.diaz
Project 4,4,Favorite 7,Production,Pharus\alberto.diaz
Project 5,5,Favorite 8,Production,Pharus\alberto.diaz
Project 6,6,Favorite 9,Production,Pharus\alberto.diaz
Project 6,6,Favorite 10,Production,Pharus\alberto.diaz
Project 6,6,Favorite 11,Production,Pharus\alberto.diaz
Project 6,6,Favorite 12,Production,Pharus\alberto.diaz
15 changes: 15 additions & 0 deletions SharePoint/Deployment/notifications.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ENMARCHAContent,ENMARCHAProject,ENMARCHAProjectId,ENMARCHAReceiver,ENMARCHASender,ENMARCHAStatus,Title
Content 1,Project 1,1,pharus\alberto.diaz,pharus\alberto.diaz,Search,Search 1
Content 2,Project 1,1,pharus\alberto.diaz,pharus\alberto.diaz,Search,Search 2
Content 3,Project 1,1,pharus\alberto.diaz,pharus\alberto.diaz,Search,Search 3
Content 4,Project 4,4,pharus\alberto.diaz,pharus\alberto.diaz,Search,Search 4
Content 5,Project 5,5,pharus\alberto.diaz,pharus\alberto.diaz,Search,Search 5
Content 6,Project 5,5,pharus\alberto.diaz,pharus\alberto.diaz,Search,Search 6
Content 7,Project 7,7,pharus\alberto.diaz,pharus\alberto.diaz,Search,Production 7
Content 8,Project 8,8,pharus\alberto.diaz,pharus\alberto.diaz,Search,Production 8
Content 9,Project 8,8,pharus\alberto.diaz,pharus\alberto.diaz,Search,Production 9
Content 10,Project 10,10,pharus\alberto.diaz,pharus\alberto.diaz,Search,Production 10
Content 11,Project 11,11,pharus\alberto.diaz,pharus\alberto.diaz,Search,Production 11
Content 12,Project 12,12,pharus\alberto.diaz,pharus\alberto.diaz,Search,Production 12
Content 13,Project 13,13,pharus\alberto.diaz,pharus\alberto.diaz,Search,Production 13
Content 14,Project 14,14,pharus\alberto.diaz,pharus\alberto.diaz,Search,Production 14
8 changes: 8 additions & 0 deletions SharePoint/SharePoint.pssproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
<Content Include="Audit\Get-ItemsAndPermissions.ps1" />
<Content Include="Audit\Inventory-SPFarm.ps1" />
<Content Include="Audit\User Access Report.ps1" />
<Content Include="Deployment\Activate-Feature.ps1" />
<Content Include="Deployment\ActivateFeature.ps1" />
<Content Include="Deployment\CreateListItemsFromCSV.ps1" />
<Content Include="Deployment\favorites.csv" />
<Content Include="Deployment\notifications.csv" />
<Content Include="Deployment\RecreateSite.ps1" />
<Content Include="Utils\PS_AddFieldsToList.ps1" />
<Content Include="Utils\PS_ApplyCustomMasterPageRecursively.ps1" />
<Content Include="Utils\PS_ChangeAuthenticationType.ps1" />
Expand All @@ -78,9 +84,11 @@
<Content Include="Utils\PS_RemoveOffice365Users.ps1" />
<Content Include="Utils\PS_RemoveOffice365Users_UsuariosABorrar.csv" />
<Content Include="Utils\PS_RemoveWebParts_WebPartCatalog.ps1" />
<Content Include="Utils\Script1.ps1" />
</ItemGroup>
<ItemGroup>
<Folder Include="Audit\" />
<Folder Include="Deployment\" />
<Folder Include="Utils\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Expand Down
Empty file added SharePoint/Utils/Script1.ps1
Empty file.

0 comments on commit df5982d

Please sign in to comment.