0

私はsharepointを知っていますが、powershellは初めてです。Powershell を使用して SharePoint にサイトを作成したいと考えています。いくつかのリンクが見つかりましたが、"Get" コマンドを実行するとエラー メッセージが表示されます。powershell wrt sharepoint で作業を開始するには、初期構成/設定を行う必要がありますか? ガイドをお願いします... PowerShellを使用してSharepointでサイトを作成するにはどうすればよいですか...

ありがとう

4

2 に答える 2

0

これを試してください。powershell リモート処理を使用する場合、コマンドは次のようになります。

Invoke-Command -ComputerName MyComputer `
               -FilePath .\Create-WebSite.ps1 `
               -ArgumentList "MySite", "C:\inetpub\MySite", 443

またはローカルで:

.\Create-WebSite.ps1 -WebSiteName "MySite" -PathInfo "C:\inetpub\MySite" -Port 443

これがスクリプトです。Create-WebSite.ps1という名前を付けました。

[cmdletbinding(SupportsShouldProcess=$True,ConfirmImpact='High')]  
Param(  
    [Parameter(Mandatory = $True,Position = 0,ValueFromPipeline = $True)]  
    [string]$WebSiteName,  

    [Parameter(Mandatory = $True,Position = 1,ValueFromPipeline = $True)]  
    [string]$PathInfo,

    [Parameter(Mandatory = $false,Position = 3,ValueFromPipeline = $True)]  
    [int]$Port = 80,

    [Parameter(Mandatory = $false,Position = 4,ValueFromPipeline = $True)]  
    [string]$HostHeader
) 

begin
{
    Import-Module WebAdministration
}

process
{
    ForEach-Object {

        New-Item $PathInfo -ItemType Directory -force
        New-Item "$PathInfo\$WebSiteName" -ItemType Directory -force
        Set-Content "$PathInfo\$WebSiteName\app_offline.htm" "$WebSiteName under maintenance" 

        if ($WhatIfPreference.IsPresent) 
        {
            write-host "What if: Performing operation New-WebAppPool -Name $WebSiteName"
            write-host "What if: Performing operation New-Website -Name $WebSiteName -ApplicationPool $WebSiteName -HostHeader $HostName -PhysicalPath $PathInfo -Port $Port"
        }
        else
        {
            New-WebAppPool -Name $WebSiteName 

            New-Website -Name $WebSiteName `
                        -ApplicationPool $WebSiteName `
                        -HostHeader $HostHeader `
                        -PhysicalPath $PathInfo `
                        -Port $Port `
                        -SSL

            New-WebApplication -Site $WebSiteName `
                               -Name $WebSiteName `
                               -PhysicalPath "$PathInfo\$WebSiteName" `
                               -ApplicationPool $WebSiteName
        }

    }
}

end
{}
于 2013-02-08T13:25:22.953 に答える