0 votes

Hello,

I have a scheduled task running daily at 1am. After that the Softerra.Adaxes.Service.exe process is using most of the available memory and brings the server to a crawl. The scheduled task calls a custom command, which in turn calls a script. The script is accessing Exchange Online, getting the user photo, and writing it to the on-prem AD thumbnailPhoto attribute. The task takes a little over an hour to run for about 75 users. I understand that it's currently over-writing the photo each night regardless of if a change occurred. Maybe there is a way to check if the two are identical and if so, skip? There are also some users that don't have a photo stored in Exchange Online, so it fails on that user but moves onto the next. Any thoughts on how to make this more efficient so it's not such a memory hog? Thanks!

try
{
    # Connect to Exchange Online
    $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://ps.outlook.com/powershell/?proxymethod=rps" `
    -Credential $Context.GetOffice365Credential() -Authentication Basic -AllowRedirection -WarningAction SilentlyContinue

    Import-PSSession $session -AllowClobber -DisableNameChecking

    $pictureBytes = Get-UserPhoto %userPrincipalName%

    $Context.TargetObject.Put("thumbnailPhoto", $pictureBytes.PictureData)
    $Context.TargetObject.SetInfo()
}
catch
{
    $Context.LogMessage("The user doesn't have an Exchange Online Mailbox", "Warning")
    return
}
finally
{
# Close the remote session and release resources
    if ($session) { Remove-PSSession $session }
}

by (920 points)

1 Answer

0 votes
by (270k points)
selected by
Best answer

Hello,

It is a known issue when using the Import-PSSession in PowerShell 3.0 and higher. As a solution, we recommend adding the If PowerShell script returns true condition to your Custom Command that will check whether the user has a mailbox in Exchange Online and update your script accordingly. In the condition, you need to use the following script from our repository: https://www.adaxes.com/script-repositor ... e-s303.htm.

In the action of the Custom Command, the following script should be used:

try
{
    # Connect to Exchange Online
    $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://ps.outlook.com/powershell/?proxymethod=rps" `
    -Credential $Context.GetOffice365Credential() -Authentication Basic -AllowRedirection -WarningAction SilentlyContinue

    Import-PSSession $session -AllowClobber -DisableNameChecking -CommandName "Get-UserPhoto"

    $pictureBytes = Get-UserPhoto %userPrincipalName%

    $Context.TargetObject.Put("thumbnailPhoto", $pictureBytes.PictureData)
    $Context.TargetObject.SetInfo()
}
finally
{
    # Close the remote session and release resources
    if ($session) { Remove-PSSession $session }
}

Finally, the Custom Command will look like the following:

0

Thanks! I'll give that a try.

Related questions

0 votes
1 answer

Dear Adaxes support, can you please advise if there an option to release memory, used by Adaxes service? I'm facing an issue with 2019.1 that after ... ) $computer.SetInfo() } } } Remove-Module $ConfigMgrModulePath -ErrorAction SilentlyContinue Thanks, Dmytro

asked Jun 25, 2019 by Dmytro.Rudyi (920 points)
0 votes
1 answer

Since upgrading to 2018.2 we are experiencing an issue where the Softerra.Adaxes.Service will consume all of the OS's available memory causing it to become unresponsive. ... for the service or figure out what might be causing the high memory utilization?

asked Nov 2, 2018 by yourpp (540 points)
0 votes
1 answer

Hello! how do i manage do get adaxes to remove all groups from the user after one month? We have a Business Rule where you can add an end of Date when the Account ... value field the powershell script works but not with the +1 Month. Thanks for your help!

asked Jun 14, 2023 by eww ag (140 points)
0 votes
1 answer

Experimentation has shown that if the Adaxes service is not up when a Scheduled Task is supposed to run, the ST obviously does not happen. After the service comes back up, ... that at our site we have a single Adaxes server, not a multi-server deployment.

asked Mar 17, 2023 by alex.vanderwoude (60 points)
0 votes
1 answer

Currently, when I disable a user account in Adaxes, the group memberships of the user remain intact. I'd like to automate the removal of group memberships such as distribution ... a list of groups/DL that the user was previously in and removed from. Thanks!

asked Nov 3, 2021 by jayden.ang (20 points)
3,326 questions
3,026 answers
7,727 comments
544,679 users