zoukankan      html  css  js  c++  java
  • SharePoint 2010 PowerShell 系列 之 Create Site

    # Check to ensure Microsoft.SharePoint.PowerShell is loaded
    $Snapin = get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
    if($Snapin -eq $null){
        Write-host "Loading SharePoint Powershell Snapin"
        Add-PSSnapin "Microsoft.SharePoint.Powershell"
    }
    
    # Get WebApplication
    $WebAppName = "SharePoint - 999"
    $WebApp = Get-SPWebApplication $WebAppName
    if($WebApp -ne $null){
        Write-host $WebApp.Url -foregroundcolor red
        $SiteUrl = $WebApp.Url+"sites/SharePoint"
        $SiteTitle = "Test SharePoint Powershell Create Site"
        $SiteTemplate = "STS#0" # STS#0 is team site
        
        # Check the site
        $targetUrl = Get-SPSite -identity $SiteUrl -regex
        if($targetUrl -ne $null){
            Write-Host "the Site " $SiteTitle " is existing,deleting......"
            Remove-SPSite -Identity $SiteUrl -confirm
        } 
        # create new site
        Write-Host "Creating new site "  $SiteTitle " please waiting......"
        $NewSite = New-SPSite -Url $SiteUrl -OwnerAlias BTV\Administrator -Template $SiteTemplate -Name $SiteTitle
        Write-host "Finish Createed successful" -foregroundcolor green     
    }
    else{
        Write-host "WebApplication " +$WebAppName +" is not existing"
    }

    SiteType 请参考

    学习目录

  • 相关阅读:
    动手动脑
    大道至简第七八章读后感
    super 的用法
    第六章
    课后作业
    大道至简第五章读后感
    课后作业
    大道至简第四章读后感
    大道至简——第六章
    Java数组课后作业
  • 原文地址:https://www.cnblogs.com/Fengger/p/2571364.html
Copyright © 2011-2022 走看看