Author Posts

February 16, 2018 at 3:52 am

Dear friends,

Need help on this one. I need to get a report of all the users in our org who doesn't have an HD photo ? The photos are stored on Exchange 2013 mailboxes ?

And i am able to retrieve the photos using the below script for a single user ? Need further help to get this done in bulk for entire organization with the following results.

The idea is as follows
1) Retrieve all photos of users based on filter get-aduser cmdlet or an excel sheet as input
2) Export the photos to a folder in which the photo files are named with user email address as for example sam@contoso.com.jpeg
3) The PS script should be able to give an output to the excel sheet after verifying the filesize of the photo and giving the size details in excel sheet for each user photo.

Once i have the excel sheet with user email address corresponding image name and the file size i will classify the photos based on its size as HD or not. As i have confirmed low resolution photos are very low in size compared to HD photos ( obviously)

Your prompt help is much appreciated.

===============================================================================================================
#Script to get the photo for a single user (i removed Photo$ to make this work)

$user = Get-UserPhoto sam@contoso.com
$user.PictureData |Set-Content "C:\Export\Photo$($user.Identity).jpg" -Encoding byte

================================================================================================================

# I guess we can use this cmdlet to sort file sizes of the photos once its exported

$file = 'D:\sample.xls'
if (Test-Path $file) { (Get-Item $file).length -gt 5kb }

===================================================================================================================

Kind regards,
Maahi

February 16, 2018 at 12:58 pm

Dears,

Can someone help me with this ?

Many thanks,
Maahi

February 16, 2018 at 3:47 pm

See if the info assists you in your use case.

'blogs.technet.microsoft.com/heyscriptingguy/2014/02/06/use-powershell-to-find-metadata-from-photograph-files'

February 16, 2018 at 4:07 pm

Dear Postanote,

Thanks for the share.. In the given article we have the last part useful to get the size and path to export into an excel sheet.

As i am a noob in scripting I need your help in combining the script i provided.

When I run this below script I face the following challenges which i need your help

=========================================================================================================================
#Script to get the photo for a single user (i removed Photo$ to make this work)
$user = Get-UserPhoto sam@contoso.com
$user.PictureData |Set-Content "C:\Export\Photo$($user.Identity).jpg" -Encoding byte
===================================================================================================================

1.) To use an input excel sheet with user email address taken as input after Get-userphoto
2.) after getting the photo the photo should be named with his email address so that we can easily relate ( currently this script doesn't give the filename as email address and its difficult to identify without opening the photo as there will be 1000s of photos. So using the input from excel sheet the retrived photo should also be renamed.
3) We can export the Size and path using the script you provided.

$picMetadata = Get-FileMetaData -folder (Get-childitem E:\pics -Recurse -Directory).FullName
$picmetadata | select size, path Export-CSV -Path c:\fso\photoMetadata.csv -NoTypeInformation

Your help is much appreciated..

Many thanks,
Maahi

February 16, 2018 at 5:42 pm

update , found this cmdlet "Rename-Item" to rename files , this should solve the second part of renaming the photo to email address.

https://blogs.technet.microsoft.com/heyscriptingguy/2013/11/22/use-powershell-to-rename-files-in-bulk/