I have Python code that is supposed to use Powershell to connect to an exchange server and remove messages from the Queue. (I am new to Powershell)
I have found this which also led to this. Which basically says I should do:
Remove-Message -Server SERVERNAME -Filter {FromAddress -like '*MATCH*'} -WithNDR $false
Where SERVERNAME
and MATCH
will be given by the code... My problem was how should I run this in the Powershell? So I did this:
powershell -NoExit -Command "COMMAND"
Where COMMAND
is the command above. And I want to run that with subprocess. When I test the command manually I get this error:
The term 'Remove-Message' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:15
+ Remove-Message <<<< -Server SERVERNAME -Filter {FromAddress -like '*MATCH*'} -WithNDR $false
+ CategoryInfo : ObjectNotFound: (Remove-Message:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
So I figure I am doing something wrong, though I think I am passing the arguments correctly into Powershell.