/
Disable-SPBlobCache.ps1
73 lines (60 loc) · 1.87 KB
/
Disable-SPBlobCache.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<#
$Metadata = @{
Title = "Disable-SPBlobCache"
Filename = "Disable-SPBlobCache.ps1"
Description = ""
Tags = "sharepoint, disable, blob, cache"
Project = ""
Author = "Janik von Rotz"
AuthorContact = "http://janikvonrotz.ch"
CreateDate = "2014-04-08"
LastEditDate = "2014-04-08"
Url = ""
Version = "0.0.0"
License = @'
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Switzerland License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ch/ or
send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
'@
}
#>
function Disable-SPBlobCache{
<#
.SYNOPSIS
Disable SharePoint Blob Cache.
.DESCRIPTION
Disable SharePoint Blob Cache.
.PARAMETER Identity
Url of the SharePoint web application where Blob cach should be disabled.
.EXAMPLE
PS C:\> Disable-SPBlobCache -AppUrl
.LINK
http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/14/use-powershell-to-script-changes-to-the-sharepoint-web-config-file.aspx
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string]
$Identity
)
#--------------------------------------------------#
# modules
#--------------------------------------------------#
if(-not (Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue)){Add-PSSnapin "Microsoft.SharePoint.PowerShell"}
#--------------------------------------------------#
# main
#--------------------------------------------------#
$SPWebApplication = Get-SPWebApplication -Identity $Identity
$SPWebApp = $SPWebApplication.Read()
$Mods = @()
foreach($Mod in $SPWebApp.WebConfigModifications){
if($Mod.Owner -eq "BlobCacheMod"){
$Mods += $Mod
}
}
foreach($Mod in $Mods){
[void] $SPWebApp.WebConfigModifications.Remove($Mod)
}
$SPWebApp.Update()
$SPWebApp.Parent.ApplyWebConfigModifications()
}