Solved

Optimize GAL Photos from AD using Script

Posted on 2014-04-29
3
279 Views
Last Modified: 2014-05-06
Ok so I have a folder with all my photos that I want to add to AD and Outlook to appear on emails.  I know I have to optimize each photo to be less than 100x100.  I found a free tool ImageMagik and a PS1 to use although Im unsure what I change in the PS1 to get it to work:

My folder is C:\security photos\atlanta
The new pics cna be written to folder:  C:\ad photos\atlanta


Here is the PS1 where do I change the input and output folders to the above to get this to work?  Thanks

param($InputFolder,$OutputFolder,$Quality);
# GALBatchConvert.ps1
# Use to convert large numbers of contact pictures to optimised 96x96 GAL photos
#
# Steve Goodman
if (!$InputFolder -or !$InputFolder)
{
    throw "InputFolder and OutputFolder parameters are mandatory";
}
if (!(Test-Path $InputFolder))
{
    throw "InputFolder not found";
}
if (!(Test-Path $OutputFolder))
{
    throw "OutputFolder not found";
}
$FullOutputFolderPath = (Get-Item $OutputFolder).FullName
if (!$Quality)
{
    $Quality = 50;
}
$Items = Get-ChildItem $InputFolder
if ($Items.Count -eq 0)
{
    throw "No items in folder"
}
[array]$ValidExt=".jpg",".jpeg",".bmp",".tif",".tiff",".gif",".png"
foreach ($Item in $Items)
{
    if ($ValidExt -contains $Item.Extension)
    {
        Write-Output "Converting $($Item.FullName)"
        .\convert.exe -quality $Quality -depth 8 -strip -thumbnail 96x96^ -gravity Center -crop 96x96+0+0 $Item.FullName "$($FullOutputFolderPath)\$($Item.BaseName).jpg"
    }
}
0
Comment
Question by:Twhite0909
  • 2
3 Comments
 
LVL 70

Expert Comment

by:Chris Dent
ID: 40031357
You're supposed to pass them into the script as arguments (the param block dictates this).

That is, if you had the above saved as fix-pictures.ps1, you'd run:
c:\somewhere\fix-pictures.ps1 -InputFolder "C:\Source" -OutputFolder "C:\Destination"

Open in new window

Quality is set to 50 if you don't set it to something else. If you needed to change that too it would become:
c:\somewhere\fix-pictures.ps1 -InputFolder "C:\Source" -OutputFolder "C:\Destination" -Quality 75

Open in new window

Finally, if PowerShell complains about not being able to execute unsigned code, you should review "Get-Help about_Code_Signing" then consider running:
Set-ExecutionPolicy RemoteSigned

Open in new window

Cheers,

Chris
0
 

Accepted Solution

by:
Twhite0909 earned 0 total points
ID: 40034530
I used a free tool called Infraview
0
 

Author Closing Comment

by:Twhite0909
ID: 40043941
BC I was right lol
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question