I was trying to create the SharePoint Site Provisioning using PowerShell. The following PowerShell script will help us to create a SharePoint sites based on Site Address, Site Name and Site Template parameters.
# This is Script to Create the Sites, based on the Siteadress and Templates, given by the user. # Use Get-SPWebTemplate cmdlet to get the list of the installed Site templates. PARAM ( [Parameter(Mandatory=$true, Position=0)] [string] $YourSiteAddress, [Parameter(Mandatory=$true, Position=1)] [string] $YourSiteName, [Parameter(Mandatory=$true, Position=2)] [string] $YourSiteTemplate #, #[Parameter(Mandatory=$true, Position=3)] #[bool] $OverWrite =$false ) $OverWrite ='N' $web = Get-SPWeb $YourSiteAddress -erroraction silentlycontinue if ($web -ne $null) { Write-Host ("Web site already present with same name : {0}"-f $YourSiteAddress) $OverWrite = Read-Host "If want to overwrite the current website Please enter [Y] else enter [N]" if($OverWrite -eq 'Y') { Write-Host ("Removing the Site {0}" -f $YourSiteAddress) Remove-SPWeb $YourSiteAddress -Confirm:$false -erroraction silentlycontinue Write-Host (" {0} - Site Removed" -f $YourSiteAddress) } $web = Get-SPWeb $YourSiteAddress -erroraction silentlycontinue } if($web -eq $null) { Write-Host ("Creating the Site {0}"-f $YourSiteAddress) New-SPWeb –url $YourSiteAddress -name $YourSiteName -template $YourSiteTemplate –AddToTopNav:$false
–UniquePermissions -UseParentTopNav:$false } else { Write-Host "use OverWrite =[Y] to overwrite this Site upon getting the prompt, once you rerun the script" }
Subscribe to my blog
Pingback: Add heading and link to SharePoint Global Navigation through Powershell - My experiments with SharePoint, Azure and .NET using Visual Studio
Pingback: Create SharePoint sites using Powershell - My experiments with SharePoint, Azure and .NET using Visual Studio