Solved

Optimize GAL Photos from AD using Script

Posted on 2014-04-29
3
267 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
Comment Utility
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
Comment Utility
I used a free tool called Infraview
0
 

Author Closing Comment

by:Twhite0909
Comment Utility
BC I was right lol
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now