PowerTip of the Day, from PowerShell.com:
When you need to store a picture into an AD account, the picture will have to be converted to byte values before it can be stored. Just make sure you adjust the path to the picture you want to store and the LDAP path of the AD object you want the picture to be stored in:
1: # adjust picture path:2: $file = "C:\pic.jpg"3: $bild = New-Object system.Drawing.Bitmap($file)4:5: $ms = New-Object IO.MemoryStream6: $bild.Save($MS, 'jpeg')7: $MS.Flush()8: $byte = $MS.ToArray()9: # adjust user LDAP path:10: $user = New-Object System.DirectoryServices.DirectoryEntry`11:12: ("LDAP://10.17.141.219/CN=Tobias,CN=Users,DC=powershell,DC=local")13:14: $User.Properties["jpegPhoto"].Value = $byte
$user.SetInfo()
Thanks to www.PowerShell.com
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.