Solved

Optimize GAL Photos from AD using Script

Posted on 2014-04-29
3
298 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 71

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Check out this step-by-step guide for using the newly updated Experts Exchange mobile app—released on May 30.
This process allows computer passwords to be managed and secured without using LAPS. This is an improvement on an existing process, enhanced to store password encrypted, instead of clear-text files within SQL
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
how to add IIS SMTP to handle application/Scanner relays into office 365.
Suggested Courses

624 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