Skip to content

Instantly share code, notes, and snippets.

View IAMPetro's full-sized avatar

IAMPetro IAMPetro

View GitHub Profile
@IAMPetro
IAMPetro / Powershell.part2.ps1
Created December 22, 2016 09:38
SharePoint: Mysterious parameter name g
function Add-SPUserSolutionProperties
{
<#
.Synopsis
This function will allow you to add additional properties to a Sandboxed solution
.Description
This function will add the additional Sandboxed solution information specified under the " #Sandboxed Solution Properties " comment tag
.Example
C:\> Add-SPUserSolutionProperties –SiteUrl “http://yourdomain.com/sites/Finance –SolutionName My.Sandboxed.Solution -SolutionId 6b701ca1-9c46-452f-8f91-73799ffb24fa -SolutionHash 8JfkvlDR9eTUcdZb1GDncs+hhqy8wZPd0oEh2GIK/20=
.Notes
@IAMPetro
IAMPetro / Powershell.part1.ps1
Created December 22, 2016 09:35
SharePoint: Mysterious parameter name g
# Open the Site Collection and the Solution Gallery Library
$web = Get-SPWeb http://yourDomain/
$solGallery = $web.Lists["Solution Gallery"]
# View all of the details on the specified Solution
$solGallery.Items | Where-Object {$_.displayName -eq "SolutionName"}
# View the properties of the specified Solution
$solution = $solGallery.Items | Where-Object {$_.displayName -eq "SolutionName"}
$solution.Properties
@IAMPetro
IAMPetro / SharePoint.TrustedMimeType.ps1
Created December 13, 2016 12:35
SharePoint: Trusted IIS MIME Types
Write-Host "This script will check if a particular MIME Type is excluded from the AllowedInlineDownloadedMimeTypes list when STRICT Browser File Handling Permissions are set on the Web Application" -foregroundcolor Darkcyan
$webAppRequest = Read-Host "What is the name of your Web Application? i.e. http://<serverName>
$webApp = Get-SPWebApplication $webAppRequest
$mimeType = Read-Host "Which MIME Type would you like to confirm is included in the AllowedInlineDownloadedMimeTypes list for $webApp ? i.e. application/pdf"
if ($webApp.AllowedInlineDownloadedMimeTypes -notcontains "$mimeType")
{
write-host "$mimeType does not exist in the AllowedInlineDownloadedMimeTypes list" -foregroundcolor Yellow
$addResponse = Read-Host "Would you like to add it? (Yes/No)"
if ($addResponse -contains "Yes")
{
@IAMPetro
IAMPetro / SharePoint.BrowserHandling.Example3.ps1
Created December 12, 2016 02:15
SharePoint: Browser File Handling Permissions
# To view a library's properties we can pipe the information into the Get-Member cmdlet
$library | Get-Member
# We will do the same thing for the $web variable but with the inclusion of the sort function
$web | Get-Member | Sort-Object Name
@IAMPetro
IAMPetro / SharePoint.BrowserHandling.Example2.ps1
Created December 12, 2016 02:15
SharePoint: Browser File Handling Permissions
# To begin with we need to specify the site the library is located
$web = Get-SPWeb "http://<sharepointServer>/sites/<siteCollection>/<siteName>"
# Next we need to specify the library by using its DisplayName
$library = $web.lists["<libraryDisplayName>"]
# Next we want to check what the current setting for Browser File Handling is set to
$library.BrowserFileHandling
# Next we can change it to either Strict to Permissive
$library.BrowserFileHandling = "Permissive"
# Lastly we will need to apply this change
$library.Update()
@IAMPetro
IAMPetro / SharePoint.BrowserHandling.Example1.xml
Created December 12, 2016 02:15
SharePoint: Browser File Handling Permissions
<?xml version="1.0" encoding="utf-8"?>
<DocIcons>
<ByProgID>
<Mapping Key="Excel.Sheet" Value="ichtmxls.gif" EditText="Microsoft Excel" OpenControl="SharePoint.OpenDocuments"/>
<Mapping Key="Publisher.Document" Value="ichtmpub.gif" EditText="Microsoft Publisher" OpenControl="SharePoint.OpenDocuments"/>
<Mapping Key="Word.Document" Value="ichtmdoc.gif" EditText="Microsoft Word" OpenControl="SharePoint.OpenDocuments"/>
</ByProgID>
<ByExtension>
<Mapping Key="zip" Value="iczip.gif" OpenControl=""/>
<Mapping Key="pdf" Value="pdficon.gif" OpenControl="AdobeAcrobat.OpenDocuments"/>
@IAMPetro
IAMPetro / SharePoint.ExportingLists.Example3.ps1
Created December 12, 2016 02:12
SharePoint: Exporting SharePoint Libraries & Lists
# Additional parameters that can be used at the end of the Export-SPWeb cmdlet are,
[-IncludeUserSecurity] [-IncludeVersions] [-NoFileCompression] [-GradualDelete] [-Verbose]
@IAMPetro
IAMPetro / SharePoint.ExportingLists.Example2.ps1
Created December 12, 2016 02:12
SharePoint: Exporting SharePoint Libraries & Lists
# Example - We will Export the library called "Reports" in the Contoso "Finance Department" team site
# and save it into a folder on the C:\ drive
# The Library URL is "http://intranet.contoso.com/sites/Departments/Finance/Reports/Forms/Allitems.aspx
Export-SPWeb -Identity http://intranet.contoso.com/sites/Departments/Finance -path "C:\Exports\FinanceDepartment_ReportsLibrary.cmp" -ItemUrl "Reports/Forms/Allitems.aspx"
@IAMPetro
IAMPetro / SharePoint.ExportingLists.Example1.ps1
Created December 12, 2016 02:11
SharePoint: Exporting SharePoint Libraries & Lists
# This will Export the Library from the specified SharePoint site onto the SharePoint Server
Export-SPWeb -Identity http://<SharePoint>/sites/<siteCollection>/<siteName> -path "<destinationFolder\fileName.cmp>" -ItemUrl "<SPLibrary>"
@IAMPetro
IAMPetro / SharePoint.ImportingLists.Example3.ps1
Created December 12, 2016 02:09
SharePoint: Importing SharePoint Libraries & Lists
# Additional parameters that can be used at the end of the Import-SPWeb cmdlet are,
[-Force] [-NoFileCompression] [-Verbose]