Add Public Folder to AuthOrig Property

I am currently looking for a way to update the AuthOrig property of a distribution group via PowerShell. We currently have an issue wherein modifying the SendAs field in the Exchange GUI will remove all our public folders that ARE permitted to sendas, so we’ve resorted to manually updating this field via ADSI edit. However, depending on the amount of users or groups to modify this can be very tedious and time consuming. I know I can use the bellow command to add a user and the get command does list the public folders, but I can’t seem to add a public folder (I have tried via name, Canonical DN & DistinguishedName). Any tips or advise are greatly appreciated, perhaps there is a way to do this via the ADSI class?

Set-DistributionGroup -Identity TestGroup -AcceptMessagesOnlyFrom user@test.com

(Get-DistributionGroup -Identity TestGroup).AcceptMessagesOnlyFrom | ForEach {Write-Host $_.DistinguishedName}

Here’s my attempt at something via ADSI but I’m not sure how I would specifically add to the AuthOrig property. So far this just adds a user to a group.

function Get-TEST_ADSPathUser ($username) {
    $string = Get-ADUser $username|Select-Object -ExpandProperty DistinguishedName
    $string = 'LDAP://' + $string
    [ADSI]$ADSPath = $string
    $ADSPath
}

function Get-TEST_ADSPathGroup ($group) {
    $string = Get-ADGroup $group|Select-Object -ExpandProperty DistinguishedName
    $string = 'LDAP://' + $string
    [ADSI]$ADSPath = $string
    $ADSPath
}

function Add-TEST_ADSIUser($username, $group) {
    $user = Get-TEST_ADSPathUser $username
    $group = Get-TEST_ADSPathGroup $group
    $group.Add($user.ADSPath)
}

Try this: The AD Users and Computers interface won't let you edit the authOrig property of a Distribution Group until you set an initial value. You need to use a real DN because it will check the validity before adding it. After doing this, you can add/edit the authorized senders from the AD Users and Computers GUI. · GitHub

That worked. Thanks a lot!