# PowerShell error

I am running the following in PS:

Import-module ActiveDirectory
$Photo = [byte[]] (Get-content c:\Photos\jones.jpg -Encoding byte) Set-User -identity Jones -Replace @[thumbnailPhoto=$photo}

This was working. Now I get the error "Set-AdUser: A value for the attribute was not in the acceptable range of values at: Line 3 char:10"

I check the 'attributeID' in ADSIEdit, upperlimit value. It was set to <not set>. I set it to 64. I still get this error. Any thought?
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Senior Solutions EngineerCommented:
line 3, character 10 is the - in front of "Identity".

Try running without the -identity switch, but further, here is some syntax that might achieve what you are trying to do:

Active Directory: Add or Update a User Picture using PowerShell

Hope this helps,

Jonathan
Author Commented:
I ran it first w/o the identity switch and got same error. The Link you refenced shows the same script i used. I believe this has to do with an AD property setting.
Senior Systems EngineerCommented:

why don't you confirm

note: identify can be set as
distinguished name (DN), GUID, security identifier (SID), Security Accounts Manager (SAM) account name or name

confirm return successful before process the next step

if it does then do
Get-Aduser -identity Jones | Set-ADuser -Replace @[thumbnailPhoto=$photo} Author Commented: Same error. It errors out right after 'Set-ADuser' Again, it say "Attribute not in acceptable range of values." There is something about the Set-ADUser command. Not sure what it is. Author Commented: Further investigation shows the script was complaining about the size of the .jpg photo. Apparently the AD value for thumbnail can not exceed 100k. My .jpg was 556k. Using a 65k .bmp file works fine!! Experts Exchange Solution brought to you by Your issues matter to us. Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle. Exchange AdministratorCommented: Hi, User Below Script with CSV file to upload pic in AD with dimension of 96x96. =========ps1 file script content============== Add-Type -AssemblyName System.Drawing$importfile = "c:\to\ps1\photo\picture.csv"

$importedusers = Import-CSV$importfile

foreach ($importeduser in$importedusers)

{

$importeduser.SAM$Photofile = Get-ChildItem -Path $importeduser.file$Photo = [byte[]](Get-Content $Photofile.Fullname -Encoding byte) Set-ADUser -Identity$importeduser.SAM -Replace @{thumbnailPhoto=\$Photo}

}

===========ps1 file end===================

Add users samaccount name and jpg file against each user to upload picture.

============picture.csv File Content==============

File,SAM
C:\To\PS1\Photo\phto.jpg,SamAccountName

============CSV end=======================
Author Commented: