Send-MailMessage error in elevated mode.

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
wartech
Posts: 52
Last visit: Wed Jan 03, 2024 9:09 am

Send-MailMessage error in elevated mode.

Post by wartech »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: PowerShell Studio 2019 v5.6.156
32 or 64 bit version of product: 64
Operating system: Windows 10 v1809
32 or 64 bit OS: 64

*** Please add details and screenshots as needed below. ***

DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM

Not certain this isn't a script problem rather than a PowerShell Studio problem...
I was debugging a script that kept failing at Send-MailMessage:
ERROR: Send-MailMessage : Unable to connect to the remote server

The command is similar to

Code: Select all

Send-MailMessage -From psharpe@work.com `
				 -To $recipient.Email `
				 -Subject "Your Windows password is about to expire" `
				 -BodyAsHtml $body `
				 -SmtpServer mail1.work.com `
				 -DeliveryNotificationOption OnFailure
Eventually I realized I'd left the elevated mode toggle enabled.
When I switched it off, the script worked perfectly.

Just curious - what caused that?
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Send-MailMessage error in elevated mode.

Post by Alexander Riedel »

Basically it is a Windows security feature. You cannot cross-call from an elevated process to a non-elevated one or vice versa.
Run notepad and drag a file from Windows Explorer, it works fine.
Now run Notepad elevated and drag and drop from the (non-elevated) File Explorer ... NADA.
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 5 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.