We are using the script you created for us to upload the employees photo based on their employee ID which works fantastic. The script is below:
$picturePath = "picture path" # TODO: modify me
# Check whether a file with the photo exists
if(!(Test-Path -Path $picturePath))
$Context.LogMessage("The path to the user's picture is incorect.", "Error") # TODO: modify me
# Save picture to AD
[Byte]$pictureInByte = Get-Content $picturePath -Encoding Byte
As we only want to add a photo if there is not one at the moment and then add the user to a group we currently use it in a custom command that has the following actions:
If the 'thumbnailPhoto' property is empty then
Run PowerShell script 'Import Photo' for the user
Add the User to the 'AD Group Name' group
We have run into issues recently where the user does not have a photo loaded but there in not a photo in the location to load, we get the error message but they way we have it the user is still added to the 'AD Group Name'. We would like to amend this so if there is no photo loaded they are not added to the group. If there is a photo uploaded they would still be added to the group.
Could you help out please? I feel like I am missing something obvious but can't see how to do it :?