ExchangeOnline Powershell - Get-QuarantineMessage -ReleaseStatus Requested: no results

Erin Martin 40 Reputation points
2024-05-24T19:02:59.75+00:00

I'm having a problem running a Get-QuarantineMessage Powershell script for ExchangeOnline in Powershell. My manager is able to run it connecting to the exact same account and get results. When I run it, I just get brought back to the prompt without any output.

What could be the reason that my manager is able to run a script and get results, while I run it and get nothing? We are both successfully connecting to the same email address. I have confirmed that there are emails with the release status of requested. I'm able to run other Get-QuarantineMessage scripts and see results in the same session.

I'm running Powershell as an Admin and on VPN. I've tried uninstalling and reinstalling ExchangeOnline, disconnecting/reconnecting, and updating.

Thanks

#user notification area for modules

write-host -foreground yellow "Importing AD Module"

Import-Module ActiveDirectory

write-host -foreground yellow "Importing ExchangeOnlineManagement Module"

Import-Module -Name ExchangeOnlineManagement

#connection to exchange online here

write-host -foreground yellow "Connecting to ExchangeOnLine"

#$corpusername = $env:USERNAME

$corpusername = "email address"

write-host -foreground yellow "Logging in as $corpusername"

Connect-ExchangeOnline -UserPrincipalName $corpusername -ShowBanner:$false -ShowProgress $true

#get the quarantined messages with a release status of requested, ignore all others

$qmsgs= Get-QuarantineMessage -ReleaseStatus Requested

Microsoft Exchange Online
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,213 questions
{count} votes

Accepted answer
  1. Rich Matheisen 45,416 Reputation points
    2024-05-25T02:09:50.92+00:00

    So, you log on, start PowerShell and run the script. You get no results. Then your manager takes your place at the keyboard, starts PowerShell and runs the script -- and gets results????

    Or you and your manager both run the script but the manager's logged on with his/her account and gets results. The the manager logs off. You log on using your account, start PowerShell, run the script, and get no results?

    If the second description is what's happening then the answer is probably a difference in permissions between the two accounts.

    If it's the first situation your machine's probably possessed by demons! :-)


1 additional answer

Sort by: Most helpful
  1. Rich Matheisen 45,416 Reputation points
    2024-05-31T19:35:18.75+00:00

    I see that variable used in only one place: $qmsgs= Get-QuarantineMessage -ReleaseStatus Requested, and that's on the left side of an assignment operator. If you run your code as you posted it that variable would still be available. However, if the code you posted is part of a function, the variable would disappear when the code returned to whatever invoked the function.

    If you removed the $qmsgs = from the code the results of the Get-QuarainteMessage would be sent into the success stream.

    So, what's missing here is context. How is the code you posted used?

    Just for fun, add this at the end of the code you posted: $qmsgs. Then run the code again. Do you see the results you expect?

    0 comments No comments