#########################################################################################
# by Max Melcher, http://melcher.it, @maxmelcher
# Feel free to change and reuse as you wish - use on your own risk
# Script that replaces the OOTB SharePoint 2013 PDF icon with the orignal Adobe PDF icon.
# Execute on each webfrontend
#########################################################################################
#settings
$destination = "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\IMAGES\icpdf.png"
#Check if the icon exists otherwise download it
$item = Get-ChildItem pdficon_small.png -ErrorAction SilentlyContinue
#Helper
function download{
# usage: download http://url c:\temp
param([string]$URL, [string]$destination)
Write-Host "Downloading $URL ..."
$clnt = new-object System.Net.WebClient -ErrorVariable err -ErrorAction "SilentlyContinue"
$clnt.DownloadFile($url,$destination)
if ([String]::IsNullOrEmpty($err) -eq $true)
{
Write-Output " - Download completed."
}
else
{
Write-Error "Download ERROR - Check URL: $err"
}
}
function RestartIIS(){
$title = "Restart IIS"
$message = "Do you want to restart the local IIS?"
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "Yes","Restarts IIS."
$no = New-Object System.Management.Automation.Host.ChoiceDescription "No","Silently continues..."
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
$result = $host.ui.PromptForChoice($title, $message, $options, 0)
if ($result -eq 0){
Write-Host -ForegroundColor Yellow "Restarting IIS"
iisreset /noforce
}
}
if ($item)
{
Write-Host -ForegroundColor Yellow "Supplied icon found - overwriting"
Copy-Item $item -Destination $destination -Force
}
else
{
Write-Host -ForegroundColor Yellow "Downloading icon from Adobe"
Download "http://www.adobe.com/images/pdficon_small.png" $destination
}
Write-Host -ForegroundColor Green "Icon replaced"
#Icon will only be changed after iisreset or reboot
RestartIIS
Write-Host -ForegroundColor Green "done!"
No comments:
Post a Comment