How do I download a masterpage file using PowerShell?
e.g. URL: http://sharepoint/_catalogs/masterpage/file.master
To list all master pages:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue;
Get-SPWebApplication | Get-SPSite -Limit All | Get-SPWeb -Limit All | Select Title, URL, MasterUrl
To download a specific file / master page:
$fromsite = "<your sp url>"
$fromfile = "/_catalogs/masterpage/seattle.master"
$tofile = "c:\seattle.master"
$web = Get-SPWeb $fromsite
$file = $web.GetFile($fromfile)
$filebytes = $file.OpenBinary()
$filestream = New-Object System.IO.FileStream($tofile, "Create")
$binarywriter = New-Object System.IO.BinaryWriter($filestream)
$binarywriter.write($filebytes)
$binarywriter.Close()