Quantcast
Channel: SharePoint 2013 - General Discussions and Questions forum
Viewing all articles
Browse latest Browse all 26374

Error while downloading the wsp file from solutions gallery of a site collection

$
0
0

Hello

I have the code like:
$spWeb = Get-SPWeb -Identity http://<site>
$listTemplate = [Microsoft.SharePoint.SPListTemplateType]::SolutionCatalog
$solGallery = $spWeb.Site.GetCatalog($listTemplate)
$solGallery.Items | ForEach-Object {
  if($_["Title"] -eq "TeamSite Template") {
    [System.IO.FileStream]$outStream = New-Object
      System.IO.FileStream("D:\PSScripts",
      [System.IO.FileMode]::Create)
    $fileData = $_.File.OpenStream()
    $outStream.Write($fileData, 0, $fileData.Length)
    $outStream.Close()
    break
  }
}

It prompts from TypeName for New-Object.
and then gives the error as:

New-Object : Cannot find type [text]: verify that the assembly containing this type is loaded.
At line:3 char:40
+     [System.IO.FileStream]$outStream = New-Object
+                                        ~~~~~~~~~~
    + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

System.IO.FileStream : The term 'System.IO.FileStream' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:4 char:7
+       System.IO.FileStream("D:\PSScripts",
+       ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (System.IO.FileStream:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Method invocation failed because [Microsoft.SharePoint.SPFile] does not contain a method named 'OpenStream'.
At line:6 char:5
+     $fileData = $_.File.OpenStream()
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

You cannot call a method on a null-valued expression.
At line:7 char:5
+     $outStream.Write($fileData, 0, $fileData.Length)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:8 char:5
+     $outStream.Close()
+     ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Kindly help me with loading the correct assembly to download the WSP file and what typename shall I give, when prompted.


Prateek Vijay Vashistha


Viewing all articles
Browse latest Browse all 26374

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>