powershell 使用powershell创建一个健全的Intranet子站点

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 使用powershell创建一个健全的Intranet子站点相关的知识,希望对你有一定的参考价值。

$site = Get-SPweb "http://scushp01"

$mList=$site.Lists["Branches"]
$i = 1

foreach($f in $mList.Items)
{
    $nospace = $f["Title"].Replace(" ","")
    $title = $f["Title"]
    $i
    $nospace
    $i++
        ########################################
    $web = get-spweb http://scushp01/Branches
    $template = $web.WebTemplate
    $newUrl = 'http://scushp01/Branches/' + $nospace
    $newWeb = New-SPWeb -Url $newUrl -Name $nospace
    $newWeb.ApplyWebTemplate($template)
    $w = Get-SPWeb  $newUrl
    $w.Title = $title
    $w.Update()

    ##Backup a list
    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
    $SourceWebURL = "http://scushp01/IT"
    $SourceListURL = "/IT/Lists/SiteLinks"
    $BackupPath = "C:\temp\"

    Export-SPweb $SourceWebURL -IncludeVersions All -ItemUrl $SourceListURL -path ($BackupPath + "SiteLinks.cmp") -nologfile -Force

    ##add the main backup site to the main site.
    Add-PSSnapin Microsoft.SharePoint.PowerShell
    $TargetWebURL = $newUrl
    $BackupPath = "C:\temp\SiteLinks"
    import-spweb $TargetWebURL -IncludeUserSecurity -path ($BackupPath + ".cmp") -nologfile -UpdateVersions Overwrite

}
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
########################################
$web = get-spweb http://scushp01/Branches
$newWeb = New-SPWeb -Url 'http://scushp01/Branches/Auburn' -Name "Auburn"
$newWeb.ApplyWebTemplate($template)
$w = Get-SPWeb  'http://scushp01/Branches/Auburn'
$w.Title = "Auburn"

##Backup a list
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$SourceWebURL = "http://scushp01/IT"
$SourceListURL = "/IT/Lists/SiteLinks"
$BackupPath = "C:\temp\"

Export-SPweb $SourceWebURL -IncludeVersions All -ItemUrl $SourceListURL -path ($BackupPath + "SiteLinks.cmp") -nologfile -Force

##add the main backup site to the main site.
Add-PSSnapin Microsoft.SharePoint.PowerShell
$TargetWebURL = "http://scushp01/Branches/Auburn"
$BackupPath = "C:\temp\SiteLinks"
import-spweb $TargetWebURL -IncludeUserSecurity -path ($BackupPath + ".cmp") -nologfile -UpdateVersions Overwrite

以上是关于powershell 使用powershell创建一个健全的Intranet子站点的主要内容,如果未能解决你的问题,请参考以下文章

powershell [AD - 创建/编辑AD用户]通过powershell创建/编辑AD用户,使用纯文本密码#Windows #Powershell #ActiveDirectory

powershell 使用PowerShell创建本地管理员帐户

powershell MS SQL Powershell使用SQLPS创建视图

powershell MS SQL Powershell使用TSQL创建表

powershell MS SQL Powershell使用SQLPS创建表

powershell 使用powershell创建一个健全的Intranet子站点