【问题标题】:PowerShell Sharepoint 2013 App CatalogPowerShell Sharepoint 2013 应用程序目录
【发布时间】:2015-06-16 22:45:02
【问题描述】:

我创建了多个 SharePoint 托管应用程序。是否可以创建批量应用程序目录,因为该应用程序是为 100 个客户创建的。我没有找到可以对 Sharepoint office 365 站点目录执行此操作的 PowerShell 命令。

是否也可以使用 PowerShell 上传批量应用程序。在网上找不到太多信息。

也许这里有人有一些建议?

干杯, 克里斯

【问题讨论】:

  • 你已经成功了还是对你来说仍然是个问题?
  • 还没有用于 SharePoint Online。所以还是有问题。

标签: shell sharepoint powershell sharepoint-2013


【解决方案1】:

可以将应用程序批量上传到 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              
}

【讨论】:

  • 所以只有在 On-Premise 中才有可能?在 Sharepoint Online (Office 365) 中这是不可能的?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-31
  • 1970-01-01
  • 1970-01-01
  • 2019-07-06
相关资源
最近更新 更多