# Get-AdPermission – The operation couldn’t be performed because object couldn’t be found

During our recent creation of Relay Receive Connector on Exchange 2013 we’ve encountered an error: The operation couldn’t be performed because object. Since time…

blog

25 Feb 2016 pl

![Get-AdPermission – The operation couldn’t be performed because object couldn’t be found](/wp-content/uploads/2016/02/PowerShell.png)

During our recent creation of **Relay Receive Connector** on **Exchange 2013** we've encountered an error: **The operation couldn't be performed because object. **Since time was an essence we didn't spent much time debugging the issue and simply found a workaround as shared below. Hopefully will be useful for you.

### ❗ Problem Description

If you run the following command to get permissions assigned to Receive Connector of Exchange an error is displayed

```plain
PS C:\Windows\system32> Get-ReceiveConnector -Identity "MAIL2\SMTP Relay" | Get-ADPermission | ft user
The operation couldn't be performed because object 'MAIL2\SMTP Relay' couldn't be found on 'AD3'.
    + CategoryInfo          : InvalidData: (:) [Get-ADPermission], ManagementObjectNotFoundException
    + FullyQualifiedErrorId : [Server=MAIL1,RequestId=01e7d665-22be-4f01-8519-fb65cc4056b3,TimeStamp=2016-02-25 19:26:59] [FailureC
   ategory=Cmdlet-ManagementObjectNotFoundException] 3A1CC281,Microsoft.Exchange.Management.RecipientTasks.GetADPermission
    + PSComputerName        : mail1
```

Even thou Get-AdPermission shows that the object can't be found, quick verification confirms it's there.

[!\[Exchange PowerShell output showing the MAIL2 SMTP Relay receive connector\](/wp-content/uploads/2016/02/img_56cf54eef1346.png)](/wp-content/uploads/2016/02/img_56cf54eef1346.png)

So what's going on?

### 📧 Solution

It seems the solution to get **Get-AdPermission **running just fine like in example below is very simple.

```plain
Get-ReceiveConnector -Identity "MAIL2\SMTP Relay" | Get-ADPermission | ft user
```

Turns out if you run exactly the same command in **Exchange Management Shell** or standard **PowerShell** Window it works just fine.

```plain
[PS] C:\ExchangeScripts\Manual>Get-ReceiveConnector -Identity "MAIL2\SMTP Relay" | Get-ADPermission | ft user

User
----
NT AUTHORITY\ANONYMOUS LOGON
NT AUTHORITY\ANONYMOUS LOGON
NT AUTHORITY\ANONYMOUS LOGON
NT AUTHORITY\ANONYMOUS LOGON
```

However the reason for this behaviour of **ISE PowerShell is** not known to me at this time. So if you have to work with **Get-AdPermission** commands you may want to run it outside of **ISE**. If we ever find out the reason for this behaviour we will make sure to share the news.

## Powiązane projekty

Projekty powiązane z tagami, kategoriami i treścią tego wpisu.

[Wszystkie projekty](/projekty/)

Trwa dopasowywanie projektów...

[Powrót do bloga](/blog/)

## Powiązane wpisy

- [Check an API write after a PowerShell timeout](/blog/verify-uncertain-api-outcomes-powershell/)
- [Inspect and convert mixed Office archives with PSWriteOffice](/blog/inspect-and-convert-mixed-office-archives-pswriteoffice/)
- [Compose PDF reports and automate page workflows with PSWriteOffice](/blog/automate-pdf-reports-and-page-workflows-pswriteoffice/)

<!-- PowerForge markdown artifact sha256:F77732D9C3E533D6038D6776367756102E0A632A553AD5B1DCCC92C46E949BD4 -->
