Hi;
My code read a CSV file in input and call this function with the 2 parameters : the name of the site collection ($dscc) and the content base ($database) :
function CreateCollectionSites
{
param(
[string]$dscc,
[string]$database
)
$SiteCollectionUrl = $WebAppSharepointUrl + "/sites/" + $dscc
$SPSite = Get-SPSite -Identity $SiteCollectionUrl -ErrorAction SilentlyContinue
if($SPSite -eq $null)
{
try
{
New-SPSite -Url $SiteCollectionUrl -OwnerAlias $SPSiteOwner -Language 1036 -Template "STS#0" -ContentDatabase $database
Import-SPWeb $SiteCollectionUrl -Path $fichierRTO -UpdateVersions overwrite -IncludeUserSecurity
Set-SPSite -Identity $SiteCollectionUrl -OwnerAlias $SPSiteOwner -SecondaryOwnerAlias $SPSiteOwnerAlias
Install-SPUserSolution -identity "LaPoste.DTC.Intranet.GenericBranding.wsp" -site $SiteCollectionUrl
Install-SPUserSolution -identity "ModeleSiteCourrier.wsp" -site $SiteCollectionUrl
$web = Get-SPWeb $SiteCollectionUrl
if ($web -eq $null)
{
$out = "## La collection de sites n'a pas t cre! ## " + $SiteCollectionUrl
$out | out-file $traceFile -append
return $false
}
else
{
$web.Title = $dscc
$web.Update()
$out = "## LA COLLECTION DE SITES $SiteCollectionUrl A ETE CREEE AVEC SUCCES DANS LA BASE $database ##"
$out | out-file $traceFile -append
return $true
}
}
catch
{
$out = "## ERREUR - LA CREATION DE LA COLLECTION DE SITES $SiteCollectionUrl A ECHOUE ##"
$out | out-file $traceFile -append
Read-Host "## ERREUR - LE DEPLOIEMENT A ECHOUE : APPUYER SUR UNE TOUCHE POUR QUITER..."
return $false
}
}
else
{
$out = "## LA COLLECTION DE SITES $SiteCollectionUrl EXISTE DEJA ##"
$out | out-file $traceFile -append
return $true
}
}
regards