Interview Questions administrator

Best SharePoint administrator Interview Questions and Answers with topic wise:


Recycle Bin | MMS | ManagedVsCrawledProperties |

Tuesday, November 25, 2014

Create sharepoint site in Office365 using powershell script

Just do copy/paste the below script in you powershell and see the magic..You will be able to new site in your office 365 application.

Am sharing the below script to all of my SharePoint colleges once did the experiments from my side.

*********************************************************************************
$wc = New-Object System.Net.WebClient
$wc.Headers.Add("User-Agent","Mozilla/4.0+")      
$wc.Proxy = [System.Net.WebRequest]::DefaultWebProxy
$wc.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
Add-Type –Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type –Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type –Path "C:\Program Files\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll"
$siteUrl = “http://xxx.xxxx.com”
$password = convertto-securestring "*****" -asplaintext -force
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials("username", $password)
$ctx.Credentials = $credentials
$webCreationInformation = New-Object Microsoft.SharePoint.Client.WebCreationInformation
$webCreationInformation.Url = "URLName"
$webCreationInformation.Title = "Title"
$webCreationInformation.WebTemplate = "STS#0"
$newWeb = $ctx.Web.Webs.Add($webCreationInformation)
$ctx.Load($newWeb)
$ctx.ExecuteQuery()
**********************************************************************************
Please let me know for any concerns.

-Thanks,
Sasi Kumar Reddy
https://sharepointquicksolutions.blogspot.com

No comments:

Post a Comment