GithubHelp home page GithubHelp logo

evotecit / mailozaurr Goto Github PK

View Code? Open in Web Editor NEW
146.0 12.0 15.0 27.16 MB

Mailozaurr is a PowerShell module that aims to provide SMTP, POP3, IMAP and probably some other ways to interact with Email. Underneath it uses MimeKit and MailKit libraries written by Jeffrey Stedfast.

License: MIT License

PowerShell 100.00%
powershell pop3 imap smtp mimekit mailkit mailkit-libraries hacktoberfest email

mailozaurr's Introduction

Mailozaurr - PowerShell Module

Mailozaurr is a PowerShell module that aims to provide SMTP, POP3, IMAP and few other ways to interact with Email. Underneath it uses MimeKit and MailKit and EmailValidation libraries written by Jeffrey Stedfast.

For oAuth2 it also requires some Microsoft and Google libraries that are also bundled in

Finally since Resolve-DNSName is Windows specific I'm using:

This started with a single goal to replace Send-MailMessage which is depracated/obsolete with something more modern, but since MailKit and MimeKit have lots of options why not build on that?

Features

  • Send Email (Send-EmailMessage) using:
    • SMTP with standard password
    • SMTP with oAuth2 Office 365
    • SMTP with oAuth2 Google Mail
    • SMTP with SendGrid
    • SendGrid API
    • Office 365 Graph API
  • POP3
    • Connect to POP3
    • Get POP3 Emails
    • Save POP3 Emails
  • IMAP
    • Connect to IMAP
    • Get IMAP Folder
    • Get Messages (you have to your own work to get what you need). Needs improvements!
  • Office 365 Graph API
    • Get Mail Folders
    • Get Mail Messages
    • Save Mail Messages
  • DNS Checks via TCP/UDP, but also via HTTPS using Cloudflare/Google providers
    • DKIM Reporting (Find-DKIMRecord)
    • MX Reporting (Find-MXRecord)
    • DMARC Reporting (Find-DMARCRecord)
    • SPF Reporting (Find-SPFRecord)
    • DNSBL Reporting (Find-DNSBL)
  • Email Validation
    • Test Email Address for errors

Documentation

While I didn't spent much time creating WIKI, working on Get-Help documentation, I did write blog articles that should help you get started.

You can also utilize Examples which should help to understand use cases. Of course it would be great having pretty help so if you can help me out feel free to submit PR's.

Keep in mind PSSharedGoods is only required for development. When you use this module from PowerShellGallery it's not installed as everything is merged.

To install

Install-Module -Name Mailozaurr -AllowClobber -Force

Force and AllowClobber aren't necessary, but they do skip errors in case some appear.

And to update

Update-Module -Name Mailozaurr

That's it. Whenever there's a new version, you run the command, and you can enjoy it. Remember that you may need to close, reopen PowerShell session if you have already used module before updating it.

The essential thing is if something works for you on production, keep using it till you test the new version on a test computer. I do changes that may not be big, but big enough that auto-update may break your code. For example, a small rename to a parameter, and your code stops working! Be responsible!

mailozaurr's People

Contributors

andrew0wells avatar jborean93 avatar przemyslawklys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mailozaurr's Issues

When path to attachment is empty error should be handled better when using Graph

WARNING: ConvertTo-GraphAttachment: Attachment '' processing error. Error: Cannot bind argument to parameter 'LiteralPath' because it is an empty string.
WARNING: ConvertTo-GraphAttachment: Attachment '' processing error. Error: Cannot bind argument to parameter 'LiteralPath' because it is an empty string.
WARNING: ConvertTo-GraphAttachment: Attachment '' processing error. Error: Cannot bind argument to parameter 'LiteralPath' because it is an empty string.
WARNING: ConvertTo-GraphAttachment: Attachment '' processing error. Error: Cannot bind argument to parameter 'LiteralPath' because it is an empty string.

DNS Server Parameter shows error

Hello,
when using the DnsServer Paramter i get an error message:

Command:
Find-MxRecord -DomainName $Domains -DnsServer 8.8.8.8

Error:
Resolve-DnsQuery : A parameter cannot be found that matches parameter name 'Server'.
At C:\Program Files\WindowsPowerShell\Modules\Mailozaurr\0.0.8\Mailozaurr.psm1:951 char:36

  •         $MX = Resolve-DnsQuery @Splat
    
  •                                ~~~~~~
    
    • CategoryInfo : InvalidArgument: (:) [Resolve-DnsQuery], ParameterBindingException
    • FullyQualifiedErrorId : NamedParameterNotFound,Resolve-DnsQuery

Hope that helps.
kind regards
Sebastian

Cannot update Mailozaurr 1.0.2 - not trusted any longer

Cannot update Mailozaurr 1.0.2 - not trusted any longer

Update-Module "Mailozaurr"
Install-Package: Authenticode issuer 'CN=Przemysław Kłys EVOTEC, O=Przemysław Kłys EVOTEC, L=Mikołów, C=PL' of the new module
'Mailozaurr' with version '1.0.2' from root certificate authority 'CN=DigiCert Trusted Root G4, OU=www.digicert.com,
O=DigiCert Inc, C=US' is not matching with the authenticode issuer 'CN=Przemysław Kłys EVOTEC, O=Przemysław Kłys
EVOTEC, L=Katowice, S=Śląskie, C=PL' of the previously-installed module 'Mailozaurr' with version '1.0.0' from root
certificate authority 'CN=DigiCert Assured ID Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US'. If you still want to
install or update, use -SkipPublisherCheck parameter.

mfg Klaus Oberdalhoff

WARNING: Connect-oAuth - Exception calling "GetResult" with "0" argument(s)

The error

WARNING: Connect-oAuth - Exception calling "GetResult" with "0" argument(s): "Possible cause: If you are using an XForms app, or generally a .NET Standard assembly, make sure you add a reference to Microsoft.Identity.Client.dll from each platform assembly (e.g. UWP, Android, iOS), not just from the common .NET Standard assembly. A browser is not available in the box on .NET Standard 1.3."

shows up when using PowerShell 7+ and oAuth

$CredentialOAuth2 = Connect-oAuthO365 -ClientID $ClientID -TenantID $TenantID -Login '[email protected]'

Possibly related to:

  1. AzureAD/microsoft-authentication-library-for-dotnet#1918
  2. AzureAD/microsoft-authentication-library-for-dotnet#1991

Move email to a different folder

I need to use Powershell and move an email in my GMAIL INBOX to a different folder.
I am using the Powershell module Mailozaurr to connect to Gmail via IMAP. I am able to correctly login and read emails in my Inbox.
Here is my code:
`
$FromAddress = "[email protected]"
$Password = "MY_password"
$Client = Connect-IMAP -Server 'imap.gmail.com' -Password $Password -UserName $FromAddress -Port 993 -Options Auto

Get-IMAPFolder -Client $Client -Verbose
foreach ($Email in $client.Data.Inbox)
{
if ($Email.from -notlike "test") {continue}
$Email
Break
}`

At this stage I want to move $email to a new folder named "NewFolder". How do i achieve this?
Please help, Thanks

SendEmail-OAuthO365 + SASL xoauth2 token refresh

From field should be mandatory

Exception calling "Add" with "1" argument(s): "Value cannot be null.
Parameter name: address"
At C:\Users\przemyslaw.klys\Documents\WindowsPowerShell\Modules\Mailozaurr\Mailozaurr.psm1:2734 char:5
+     $Message.From.Add($SmtpFrom)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentNullException

Logging

Hello,

Your Script is great save me a lot of time making it myself.

I only have One Question. With Sending The mail there is a logging to screen. Is it posable for me to send it to a Steing so i can include it in my logfile ?

Thanks

Ronald

-SkipCertificateValidatation does not seem to work

hi, i am executing this command:

Send-EmailMessage -to "[email protected]" -From "[email protected]" -Subject "test" -Text "test" -Server "mail.company.com" -port 25 -SkipCertificateValidatation

the cert on port 25 does NOT match "mail.company.com" but i am using the -SkipCertificateValidatation switch....this is what i get:

WARNING: Send-EmailMessage - Error: Exception calling "Connect" with "3" argument(s): "An error occurred while attempting to establish an SSL or TLS connection.

The host name did not match the name given in the server's SSL certificate.
"
WARNING: Send-EmailMessage - Possible issue: Port? (25 was used), Using SSL? (Auto was used). You can also try SkipCertificateValidation or SkipCertificateRevocation. 


Status        : False
Error         : Exception calling "Connect" with "3" argument(s): "An error occurred while attempting to establish an SSL or TLS connection.
                
                The host name did not match the name given in the server's SSL certificate.
                "
SentTo        : [email protected]
SentFrom      : [email protected]
Message       : 
TimeToExecute : 00:00:00.0235829
Server        : mail.company.com
Port          : 25

so, why is this happening? Am I doing something wrong?
thanks

"Send-EmailMessage -Verbose" Throws Exception if -HTML is less than 10 Characters

To reproduce:

Send-EmailMessage -From @{ Name = 'Wells, Andrew'; Email = '<from address>' } -To '<to address>' -Credential $Credential -HTML "TEST" -Subject 'Test ' -Graph -Verbose -Priority High

The exception received was

Exception calling "Substring" with "2" argument(s): "Index and length must refer to a location within the string.
Parameter name: length"
At C:\Program Files\WindowsPowerShell\Modules\Mailozaurr\0.0.7\Mailozaurr.psm1:317 char:13
$Message.message.body.content = -join ($Message.message.b ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : ArgumentOutOfRangeException

My assumption is that this is because that line uses Substring, without checking to see if the length is at least 10 characters long.

Great work on this module, btw!

Adding attachment >3 MB not possible if no client secret is used

Hi,
maybe it's a bug, but I'm unable to send attachments which are bigger than 3 MB via a managed identity or a normal app registration with certificate based authentication.
After creating a client secret for the same app registration it worked. (But I don't want to use a client secret.)
Is it possible, that the function which handles the upload somehow doesn't use the already existing session?
Because the upload doesn't work, but the email is send without problems (and without an attachment of course).

image

I used the following commands:
Connect-MgGraph -Identity
or
Connect-MgGraph -ClientId $ClientId -TenantId $TenantId -CertificateThumbprint $Thumbprint

Send-EmailMessage -From 'XXX' -To 'XXX' -HTML "XXX" -Subject 'XXX' -Graph -ReplyTo "XXX" -MgGraphRequest -Attachment "C:\temp\XXX.pdf" -Verbose

(By using the parameter -Credential and the function ConvertTo-GraphCredential for generating the credential object and removing the parameter -MgGraphRequest it worked.)

Thanks,
Markus

Small problem with Email-name

Hi,

If you try to send an email using the spec:

“Name ”
Instead of pure Email, then it doesn’t work

In “Originial” Send-Mail I used:

$email = $mail.Rch_Email
$name = $mail.NameKunde
$MailTo = "$name <$email>"

And did use $Mailto as Emailaddress (To) and it worked

I circumvent by just using $email instead, but nevertheless I’d prefer the “old” method …

Für Rücksprachen stehe ich gern zur Verfügung

mit freundlichen Grüßen aus Nürnberg
Klaus Oberdalhoff | Senior Consultant | Database Specialist
Untere Schmiedgasse 8 | D-90403 Nürnberg | Germany
Tel : +49(911)2369666 | Handy: +49(1515) 2 58 02 47
Email: [email protected] | Fax : 03212 / 1154718
Profil: https://1drv.ms/f/s!Am2T4hGcNbbMgfNNTpeaYlAuDHYDkw
Meine letzte Veröffentlichung:
https://www.linkedin.com/pulse/time-changes-ms-access-mobile-apps-klaus-klaus-oberdalhoff/

Add UseDefaultCredentials

In SMTP mail UseDefaultCredentials can be called to skip need to provide credentials.

In Send-MailMessage it seems to be turned on by default if there's no login/pass prompt given or at least I think so. Would need to check sources.

In MailKit it can be achieved it seems but requires some deep dive

Adapting "from" with custom name

Hello all,
I'm using the Mailozaurr with the "ClientID" - "ClientSecret" and "Directory ID"
The script works and my mails are coming in.

However I'm trying to tweak the the From field to have something custom.
I'm using an alias of a shared mailbox to sent and I want to use a specific "Name" that would be shown when the mail arrives.

But it keeps showing the primary mail and linked name of the shared mailbox.

Send-EmailMessage -From @{ Name = 'nametobeshown'; Email = '[email protected]' }

Can't send attachment > 3Mb using Graph

Hello,

When sending mail with attachment bigger than 3mb, (using Graph) i get this error :

WARNING: Send-GraphMailMessage - Error during draft message creation: Response status code does not indicate success: 403 (Forbidden). Access is denied. Check credentials and try again.
WARNING: New-GraphAttachment - Error creating upload session: Response status code does not indicate success: 400 (Bad Request).
WARNING: Send-GraphMailMessageDraft - Error: Response status code does not indicate success: 400 (Bad Request). Empty Payload. JSON content expected.

And no mail is send.

I think it's a limitation for Graph, but do you think we can bypass it using the "Upload Session" method bellow ?

Thank you for the help.

MX Record IPAddress with -Separate

Hello,
first of all thank you very much for you work, this tool is so powerful and I just started to scratch the surface.
It might be just my inexperience but when I use the Find-MXRecord with a single Domain as input and with only -Separate as parameter, the moment i pipe it to Export-Csv the IPAddress get always as System.Object[].
I tried to add in the pipe many ways to -join the arrays of IPAddresses but I get always a Lenght column with some number values like 260.
I tried to find the part in your source code where you wrote about the -Separate but I can't get my head around it.
There is somebody that can help me? I just need to put the IPAddresses in the csv with the -Separate but joined.
Also, as I'm already in topic, there is somebody that applied -Separate but with other -Find?
Thanks again and sorry for the dumb question.

Pester Tests

Please consider creating Pester tests for common uses of Cmdlets and Functions.
This would identify issues such as #17 early on.

Feature Request: SkipCertificateCheck on Connect-IMAP/Connect-POP3

WARNING: Connect-IMAP - Unable to connect Exception calling "Connect" with "3" argument(s): "An error occurred while attempting to establish an SSL or TLS connection.

The server's SSL certificate could not be validated for the following reasons:
• The server certificate has the following errors:
  • The revocation function was unable to check revocation for the certificate.
  • The revocation function was unable to check revocation because the revocation server was offline.
"
VERBOSE: Get-IMAPMessage - Client not connected?

Send-EmailMessage: More Flexible Attachments and Linked Resources

The ability to have more flexible attachments (other than just specifying path) would be useful.

The easiest way to do this is to change the $Attachment Parameter to [object[]] type and rely on MimeKit.AttachmentCollection.Add() which supports both Strings and MimeEntity

Although this doesn't really help with LinkedResources for things like changing changing attachment meta-data, such as Content-Disposition and Content-Id which is required for inline images in HTML emails in some emails. Perhaps LinkedResources can be exposed as a parameter too? Could be a number of ways to implement this as a more polished easy-to-use solution, maybe a separate -InlineAttachments Parameter that handles both?

https://www.mimekit.net/docs/html/Creating-Messages.htm#UsingBodyBuilder

To consider .NET replacement of PS Classes if things stop working or so

Add-Type -TypeDefinition @'
using System;
using MailKit.Net.Smtp;

public class MySmtpClient : MailKit.Net.Smtp.SmtpClient
{
    public MySmtpClient() : base() {}
    
    public string[] DeliveryNotificationOption { get; set; }

    public override DeliveryStatusNotification? GetDeliveryStatusNotifications(MimeMessage message, MailboxAddress mailbox)
    {
        bool output = false;
        DeliveryStatusNotification info = DeliveryStatusNotification.Never;
        if (this.GetDeliveryStatusNotifications.Contains("OnSuccess"))
            info |= DeliveryStatusNotification.Success;

        if (this.GetDeliveryStatusNotifications.Contains("Delay"))
            info |= DeliveryStatusNotification.Delay;

        if (this.GetDeliveryStatusNotifications.Contains("OnFailure"))
            info |= DeliveryStatusNotification.Failure;

        if (this.GetDeliveryStatusNotifications.Contains("Never"))
            info |= DeliveryStatusNotification.Never;
            
        if (output)
            return info;

        return null;
    }
}
'@

Getting Exception calling "Send" with "1" argument(s): "Could not load file or assembly 'System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified." when using Send-EmailMessage

Hi,
I'm trying to use Mailozaurr to send email using Send-EmailMessage but I'm getting the following exception:

WARNING: Send-EmailMessage - Error: Exception calling "Send" with "1" argument(s): "Could not load file or assembly 
'System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The 
system cannot find the file specified."

I am using the following arguments with Send-EmailMessage

Send-EmailMessage -To 'tom.austin@***.com' -From 'notifications@***.com' `
    -Server 'smtp.office365.com' -Credential $MailCredentials -HTML $output -Subject 'Update Report' -SkipCertificateRevocation

This is on Windows 10 21H1

Do you know what could cause this or what I can do to sort it?

Thanks

Auto-loading module in Required Modules fails in PowerShell 5.1

When you use Mailozaurr and do Import-Module Mailozaurr everything works fine.

When you add Mailozaurr as part of RequiredModules like below Mailozaurr will fail auto-load if you try to import that module. Otherwise it works fine

@{
    AliasesToExport      = @()
    Author               = 'Przemyslaw Klys'
    CmdletsToExport      = @()
    CompanyName          = 'Evotec'
    CompatiblePSEditions = @('Desktop', 'Core')
    Copyright            = '(c) 2011 - 2021 Przemyslaw Klys @ Evotec. All rights reserved.'
    Description          = 'This module allows creation of password expiry emails for users, managers, administrators and security according to defined templates. It''s able to work with different rules allowing to fully customize who gets the email and when.'
    FunctionsToExport    = @('Find-Password', 'Find-PasswordNotification', 'Send-PasswordEmail', 'Start-PasswordSolution')
    GUID                 = 'c58ff818-1de6-4500-961c-a243c2043255'
    ModuleVersion        = '0.0.14'
    PowerShellVersion    = '5.1'
    PrivateData          = @{
        PSData = @{
            Tags                       = @('password', 'passwordexpiry', 'activedirectory', 'windows')
            ProjectUri                 = 'https://github.com/EvotecIT/PasswordSolution'
            ExternalModuleDependencies = @('ActiveDirectory')
        }
    }
    RequiredModules      = @(@{
            ModuleVersion = '0.0.207'
            ModuleName    = 'PSSharedGoods'
            Guid          = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe'
        }, @{
            ModuleVersion = '0.0.15'
            ModuleName    = 'Mailozaurr'
            Guid          = '2b0ea9f1-3ff1-4300-b939-106d5da608fa'
        }, @{
            ModuleVersion = '0.0.156'
            ModuleName    = 'PSWriteHTML'
            Guid          = 'a7bdf640-f5cb-4acf-9de0-365b322d245c'
        }, 'ActiveDirectory')
    RootModule           = 'PasswordSolution.psm1'
}

You need to explicitly import Mailozaurr before importing it. This seems to be related to how classes are parsed during runtime.

I've tried putting classes into a separate files, loading them via ScriptsToProcess, putting classes at the beginning and end of the file. Nothing seems to work.

Please note this affects only PowerShell 5.1 and may not be fixable as classes are a bit special in PowerShell.

Change NET Framework + Net Core to Net Standard to mnimize library size

Not a bug but maybe a suggestion to maybe use MimeKitLite instead of MimeKit for the dll. It's approx. 24% smaller making the loading quicker and everything more lightweight. I switched to that in your module and everything is working fine.
The only difference between the two is the crypto is not in the lite version (s/mime stuff, etc.)
Thank you for the module, it's expertly written!

If Path doesn't exists, an error occurs (attachments)

If Path doesn't exists, an error occurs.

            attachments   = @(
                foreach ($A in $Attachment) {
                    $ItemInformation = Get-Item -Path $A
                    if ($ItemInformation) {
                        $File = [system.io.file]::ReadAllBytes($A)
                        $Bytes = [System.Convert]::ToBase64String($File)
                        @{
                            '@odata.type'  = '#microsoft.graph.fileAttachment'
                            'name'         = $ItemInformation.Name
                            #'contentType'  = 'text/plain'
                            'contentBytes' = $Bytes
                        }
                    }
                }
            )
Get-Item : Cannot find path 'C:\Reporting\CustomReports\PasswordSolution_2022-09-22_22_00_45.html' because it does not exist.
At C:\Users\przemyslaw.klys\Documents\WindowsPowerShell\Modules\Mailozaurr\Mailozaurr.psm1:532 char:40
+                     $ItemInformation = Get-Item -Path $A
+                                        ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Reporting\Cu...2_22_00_45.html:String) [Get-Item], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

Get 403 after using Send-EmailMessage

I have an Azure AD application with Send.Mail permissions.
I am trying to use this app to send emails using this code:

$Credential = ConvertTo-GraphCredential -ClientID $ClientID -ClientSecret $SendEmailSecret -DirectoryID $DirectoryID
Send-EmailMessage -To $To -Cc $cc -Subject $subject -From $senderEmail -Credential $Credential -HTML $body -Graph -Priority Normal

$ClientID, $DirectoryID - are taken from my Azure AD application
$SendEmailSecret - is the text from a secret defined in the Azure AD application.

After running the code, I get this:
WARNING: Send-GraphMailMessage - Error: The remote server returned an error: (403) Forbidden.

FIlename containing ie round brackets dont show correctly in attachment

Hi,

If an attachment pathfilename contains a “(“ or “)” or both in pathfilename, the pathfilename is not correctly shown in the sent email (see Attachments)

If I try to circumvent the problem and adding a “ or a ‘ before and after the pathfilename, then the file is not recognized at all as a file.
Problem_18-03-2022_12-52-51
Problem2_18-03-2022_12-52-51

mit freundlichen Grüßen aus Nürnberg
Klaus Oberdalhoff | Senior Consultant | Database Specialist
Untere Schmiedgasse 8 | D-90403 Nürnberg | Germany
Tel : +49(911)2369666 | Handy: +49(1515) 2 58 02 47
Email: [email protected] | Fax : 03212 / 1154718
Profil: https://1drv.ms/f/s!Am2T4hGcNbbMgfNNTpeaYlAuDHYDkw
Meine letzte Veröffentlichung:
https://www.linkedin.com/pulse/time-changes-ms-access-mobile-apps-klaus-klaus-oberdalhoff/

"Find-SPFRecord" does not seem to work in Azure Automation Accounts

Thanks for this awesome module, I'm using it to create a report on tenant security using Azure Automation Account.

On that note, something seems to fail when running in given context. Using v0.9 of your module.

Catched error:

# Exception:

System.Management.Automation.MethodInvocationException: Exception calling ".ctor" with "0" argument(s): "Unable to find 

an entry point named 'GetPerAdapterInfo' in DLL 'iphlpapi.dll'." ---> System.EntryPointNotFoundException: Unable to 

find an entry point named 'GetPerAdapterInfo' in DLL 'iphlpapi.dll'.

   at DnsClient.NameServer.ResolveNameServers(Boolean skipIPv6SiteLocal, Boolean fallbackToGooglePublicDns)

   at DnsClient.LookupClient..ctor(LookupClientOptions options, DnsMessageHandler udpHandler, DnsMessageHandler 

tcpHandler)

   at CallSite.Target(Closure , CallSite , Type )

   --- End of inner exception stack trace ---

   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception 

exception)

   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)

   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

   at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)

   at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)

   at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object 

inputToProcess)

   at System.Management.Automation.PSScriptCmdlet.DoEndProcessing()

   at System.Management.Automation.CommandProcessorBase.Complete()

# Exception:

## Exception\ErrorRecord:

Exception calling ".ctor" with "0" argument(s): "Unable to find an entry point named 'GetPerAdapterInfo' in DLL 

'iphlpapi.dll'."

## Exception\WasThrownFromThrowStatement:

False

## Exception\Message:

Exception calling ".ctor" with "0" argument(s): "Unable to find an entry point named 'GetPerAdapterInfo' in DLL 

'iphlpapi.dll'."

## Exception\InnerException:

System.EntryPointNotFoundException: Unable to find an entry point named 'GetPerAdapterInfo' in DLL 'iphlpapi.dll'.

   at DnsClient.NameServer.ResolveNameServers(Boolean skipIPv6SiteLocal, Boolean fallbackToGooglePublicDns)

   at DnsClient.LookupClient..ctor(LookupClientOptions options, DnsMessageHandler udpHandler, DnsMessageHandler 

tcpHandler)

   at CallSite.Target(Closure , CallSite , Type )

## Exception\TargetSite:

Void CheckActionPreference(System.Management.Automation.Language.FunctionContext, System.Exception)

## Exception\StackTrace:

at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception 

exception)

   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)

   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

   at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)

   at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)

   at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object 

inputToProcess)

   at System.Management.Automation.PSScriptCmdlet.DoEndProcessing()

   at System.Management.Automation.CommandProcessorBase.Complete()

## Exception\Source:

System.Management.Automation

## Exception\HResult:

-2146233087

# CategoryInfo:

## CategoryInfo\Category:

NotSpecified

## CategoryInfo\Activity:

Resolve-DnsQuery

## CategoryInfo\Reason:

MethodInvocationException

# FullyQualifiedErrorId:

## FullyQualifiedErrorId\Length:

44

## FullyQualifiedErrorId\Chars:

char Chars(int index) {get;}

# InvocationInfo:

## InvocationInfo\MyCommand:

Resolve-DnsQuery

## InvocationInfo\ScriptLineNumber:

839

## InvocationInfo\OffsetInLine:

26

## InvocationInfo\HistoryId:

1

## InvocationInfo\ScriptName:

C:\Modules\User\Mailozaurr\Mailozaurr.psm1

## InvocationInfo\Line:

$DNSRecord = Resolve-DnsQuery @Splat -All

## InvocationInfo\PositionMessage:

At C:\Modules\User\Mailozaurr\Mailozaurr.psm1:839 char:26

+             $DNSRecord = Resolve-DnsQuery @Splat -All

+                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

## InvocationInfo\PSScriptRoot:

C:\Modules\User\Mailozaurr

## InvocationInfo\PSCommandPath:

C:\Modules\User\Mailozaurr\Mailozaurr.psm1

## InvocationInfo\InvocationName:

Resolve-DnsQuery

## InvocationInfo\PipelineLength:

0

## InvocationInfo\PipelinePosition:

0

## InvocationInfo\ExpectingInput:

False

## InvocationInfo\CommandOrigin:

Internal

# ScriptStackTrace:

## ScriptStackTrace\Length:

197

## ScriptStackTrace\Chars:

char Chars(int index) {get;}

    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException

    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException

Questions

  • Does this give you enough info into what breaks?
  • Is this something you think you'll be able to fix, or even want to fix?

Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe

Hello,

I have installed your toolkit. When I try to run connect-imap I get the following warning:

WARNING: Connect-IMAP - Unable to connect Exception calling "Connect" with "3" argument(s): "Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified."

What should I do to make this work?

Thank you.
Jan

How to get <CR><LF> in body text using plain ASCII input from file

I have a CR/LF terminated text file and do not want to use HTML as a body but stick to plain text:
PS C:\users> Get-Content -path 'd:\foo.txt' -raw
hello
world

Sending out with Send-MailMessage results in 2 lines as needed in my email client but using Send-EMailMessage results in 1 line only:
hello world

CMD used:
$StrBody = (Get-Content -Path 'd:\foo.txt' -raw) ; Send-EMailMessage -SmtpServer 'w.x.y.z' -Body $StrBody -from '[email protected]' -To '[email protected]' -port 25

I'm a Windows user and the result is the same using PS 5.1 and PSCore 7.2.1 (on Mailozaurr 0.0.21)

Feature Request: Signed mail

Hi there.

I love this collection of utilities and replaced some of my own tools with it.
Would it be possible to add S/MIME signed mails to the Send-Email function?

Also on this topic:
The System.Net.Mail.SmtpClient API is obsolete. Microsoft recommends using https://github.com/jstedfast/MimeKit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.