Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Wednesday, November 27, 2013

Quick JPEG Optimization to Speed Up Your Web Site

If you would like to quickly optimize the jpeg images for your web site, here's a quick method that works pretty good.

First, download jpegtran.exe, and save it to C:\

Download your image files to C:\Users\administrator\Desktop\files, or change the path in the code below to point to the root folder where you want to search for images to optimize. The script will crawl through subdirectories, so don't worry about the directory structure under the path that you specify.

Open a PowerShell prompt (you may need to "run as administrator" depending on your security settings). If your files are in a different path, or you placed jpegtran.exe edit the code below to reflect those difference. Run the code below.


$files = Get-ChildItem -Path C:\Users\administrator\Desktop\files -Recurse | where {$_.Extension -eq ".jpg"}
foreach($file in $files){
    [string]$image = $file.FullName
    [string]$cmd = "C:\jpegtran.exe -copy none -optimize $image $image"
    Invoke-Expression $cmd
}

The way the previous code is written, it will overwrite the existing file with the optimized one, so make a copy of them first if you want to keep the original as well.

I hope that helps. I optimized all of the JPEGs on one of my sites in a few minutes, and that includes writing the PowerShell code above.

Wednesday, January 30, 2013

Powershell Script to Delete Out Temporary Internet Files

If you have a lot of user profiles on a box, the user profiles can start to take up a lot of disk space. This is especially so on a Citrix or terminal services server, but can affect any system where more than a few people logon. I wrote a quick powershell script that can be scheduled to clean these out.


IIS Log Management Script in Powershell

IIS logs on a busy webserver can use up a lot of disk space. I wrote this little powershell script that I schedule to run on all of my web servers. It goes in and deletes out any IIS logs older than 1 year. Then it compresses any IIS logs that are left which are older than 1 day and are not already compressed. You can change the length of time for these to suit your needs by changeing the numbers in the "AddDays(-123)" parts of the script. Just make sure it's a negative number, or else you won't have any logs left.

Wednesday, January 2, 2013

Symantec Endpoint Protection 12.1 clients are holding onto multiple virus definitions, using a lot of disk space

There is a known issue with Symantec Endpoint Protection 12.1 clients where it does not delete the old virus definition files. These definition files build up and start consuming gigs and gigs of disk space.

They do have a fix for it now, which involves upgrading to Update Rollup 2 (UR2). Unfortunately,  you might not be able to upgrade right away. As a workaround, I wrote the powershell script below that will cleanup the old definition files. I schedule this to run daily.