2014-03-28 41 views
1

我已經創建了幾個SharePoint託管的應用程序。是否可以創建批量應用目錄,因爲該應用是爲100個小客戶創建的。我找不到可用於Sharepoint office 365網站目錄的PowerShell命令。PowerShell Sharepoint 2013應用程序目錄

是否有可能使用PowerShell上傳批量應用程序。在網上找不到更多信息。

也許任何人在這裏有一些建議?

乾杯, 克里斯

+0

你已經成功了還是對你來說還是個問題? –

+0

尚未用於SharePoint Online。所以這仍然是一個問題。 – user3396761

回答

0

,可以批量上傳應用到Office 365的環境,因爲它是爲SharePoint內部部署。 這裏棘手的部分是,您必須將應用程序上傳到應用程序目錄,實際上它是一個文檔庫。

最近我創建了一個使用來自互聯網腳本的功能。發佈以下功能:

function UploadAppToCatalog    
    {    
    [CmdletBinding()]    
    Param(   
    [Parameter(Mandatory=$true,ValueFromPipeline=$true)]    
    [string]$webUrl,    
    [Parameter(Mandatory=$true)]    
    [string]$DocLibName,    
    [Parameter(Mandatory=$true)]    
    [string]$FilePath    
    )     

    Start-SPAssignment -Global    
    $spWeb = Get-SPWeb -Identity $webUrl    
    $spWeb.AllowUnsafeUpdates = $true;    
    $List = $spWeb.Lists[$DocLibName]    
    $folder = $List.RootFolder    
    $FileName = $FilePath.Substring($FilePath.LastIndexOf("\")+1)    
    $File= Get-ChildItem $FilePath    
    [Microsoft.SharePoint.SPFile]$spFile = $spWeb.GetFile("/" + $folder.Url + "/" + File.Name)    
    $flagConfirm = 'y'    
    if($spFile.Exists -eq $true)    
    {    
     $flagConfirm = Read-Host "File $FileName already exists in library $DocLibName, do you want to upload a new version(y/n)?"    
    }    

    if ($flagConfirm -eq 'y' -or $flagConfirm -eq 'Y')    
    {    
     $fileStream = ([System.IO.FileInfo] (Get-Item $File.FullName)).OpenRead()    
     #Add file    
     write-host -NoNewLine -f yellow "Copying file " $File.Name " to " $folder.ServerRelativeUrl "..."    
     [Microsoft.SharePoint.SPFile]$spFile = $folder.Files.Add($folder.Url + "/" + $File.Name, [System.IO.Stream]$fileStream, $true)    
     write-host -f Green "...Success!"    
     #Close file stream    
     $fileStream.Close()    
     write-host -NoNewLine -f yellow "Update file properties " $spFile.Name "..."    
     $spFile.Item["Title"] = "Document Metrics Report"    
     $spFile.Item.Update()    
     write-host -f Green "...Success!"    
    }    
    $spWeb.AllowUnsafeUpdates = $false;    


    Stop-SPAssignment -Global    
} 
+0

所以它只能在內部部署?在Sharepoint Online(Office 365)中,這是不可能的? – user3396761

相關問題