Ensure_SandboxSolution

Checks the solution gallary for a file; uploads if not found.
Language:
PowerShell
Keywords:
SharePoint
Code Snippet

Function Ensure_SandboxSolution( [Microsoft.SharePoint.SPSite]$tSite
                               , $tFilename
                               , $tFileLocation
                               ) {
    # Load the Solution Gallery
    $tSlnGallery = $tSite.GetCatalog([Microsoft.SharePoint.SPListTemplateType]::SolutionCatalog)

    # check whether the solution file has been uploaded to the Solution Gallery
    if (($tSlnGallery.Items | where { $_.Name -eq $tFilename }) -eq $null) {
        # upload file to solution gallery
        $tSlnGallery.RootFolder.Files.Add($tFilename, [System.IO.File]::ReadAllBytes($tFileLocation)) | Out-Null
    }
} # Function Ensure_SandboxSolution(...)


Created 2011-10-13
comments powered by Disqus
Login