Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Import thumbnail photos

$
0
0

I'm trying to Import thumbnail photos to AD user accounts. They are saved in a folder with a first.last name. This script works but I just need it to either parse just user objects or only import from a particular OU, either one is fine with me for this particular excercise.

$PhotoPath = "d:\Photos\*.*"
ForEach ($PhotoFile in gci $PhotoPath)
{
$User = '' + $PhotoFile.Name.substring(0, $PhotoFile.Name.Length - 4) + ''
Import-RecipientDataProperty -Identity $User -Picture -FileData ([Byte[]]$(Get-Content -Path $PhotoFile.Fullname -Encoding Byte -ReadCount 0))
}

Reason being, there are Contact objects that use the same name but with a (discription) tag on the end of it. example user = "tim.marshall" and the contact = "tim.marshall (Houston)". This script updates the users who do not have a orresponding contact but not the user object that have a corresponding contact. The contacts are in a seperate OU from the user objects.

This is the error I get:

The operation couldn't be performed because 'tim.marshall' matches multiple entries.
    + CategoryInfo          : NotSpecified: (:) [Import-RecipientDataProperty], ManagementObjectAmbiguousException
    + FullyQualifiedErrorId : [Server=EGYEXMB01,RequestId=68978e98-ffab-43e6-ba44-256f06357617,TimeStamp=1/31/2014 12:
   55:02 PM] 85846A34,Microsoft.Exchange.Management.RecipientTasks.ImportRecipientDataProperty
    + PSComputerName        : egyexca01.apacheegypt.com


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>