Exchange Server and OpenAI GPT-3?

OpenAI AI is currently on everyone's lips and every day there are new articles in the media about GPT3 or GPT-4 with tests of how well or badly something works. There are calls for the regulation of AI systems and some people are already predicting mass unemployment. As an Exchange admin, I can't predict whether this will all happen and an AI will soon take over the world. But of course I also want to play around with GPT-3...

Of course I also have the GPT-3 Chat and was amazed at the sometimes very good results, but I quickly found the OpenAI API much more interesting. There is even a PowerShell module that can be used to access the OpenAI API very easily. The PowerShell module can be installed with the following command:

Install modules PowerShellAI
Exchange Server and OpenAI GPT-3?

Now only an API key is required, which created here can be used. The API key can then be saved in an environment variable and can therefore be used with the PowerShell module:

$env:OpenAIKey = "APIKEY"
Exchange Server and OpenAI GPT-3?

The first scenario that occurred to me was to feed the AI with the errors from the event log and have it suggest a solution. I therefore quickly created a small script:

#OpenAI API Key:
$env:OpenAIKey = "APITOKEN"
$EventLog = Get-EventLog -LogName Application -EntryType Error -After (get-date).AddDays(-1)
$EventLogGroups = $EventLog | group eventid
foreach ($EventLogGroup in $EventLogGroups) {
$Event = $EventLogGroup.Group | select -Unique
$EventID = $Event.EventID
$Message = $Event.Message
$GPT3Answer = Get-GPT3Completion "What could be the solution for this error: $Message"
write-host "EventID: $EventID" -ForegroundColor red
write-host "Message:" -ForegroundColor red
write-host "$Message"
write-host "Proposed solution by GPT-3:" -ForegroundColor green
write-host "$GPT3Answer"
}

On my test Exchange Server there are unfortunately few "real" errors, most errors occur during startup or shutdown of the server. However, the answers are not that bad:

Exchange Server and OpenAI GPT-3?

I then fed OpenAI with a few errors from a productive Exchange server and the results were surprisingly good. For two errors, the registry key suggested by GPT-3 as a solution even worked. So it's worth testing a little further here.

By the way, GPT-3 can also create quite useful PowerShell scripts for administration. Here is an example:

$Script = Get-GPT3Completion "Create a PowerShell Script to list all Exchange Server Mailbox sizes"

This is the result:

Exchange Server and OpenAI GPT-3?

There is a small error: The line "Import-Module Exchange" does not work because the Exchange CMDLets are not a PowerShell module but a SnapIn. The script works in the Exchange Management Shell itself, as the CMDLets are available and do not have to be loaded separately.

The script actually works, as you can see the size of the administrator mailbox is displayed. If you add a bit of error handling, the script is already finished.

The instructions also work well in German:

Exchange Server and OpenAI GPT-3?

Playing around with the OpenAI API is really fun, you find new use cases very quickly:

Exchange Server and OpenAI GPT-3?

Many results are already amazingly good, but at the moment you don't have to be afraid of becoming unemployed as an Exchange Admin :-)

However, since the entry hurdle with the OpenAI API is very low, it is worth experimenting with it a little. I'm currently having a lot of fun with it :-)

9 thoughts on “Exchange Server und OpenAI GPT-3?”

  1. Ich habe ChatGPT auch schon hinsichtlich meiner offenen Fragen bei Windows Server 2019 zur Änderung der lokalen Absenderdomäne im Email-Header gefragt, woraufhin es mir die Änderung der Namensschemaerweiterung mit der Active Directory-Domänen- und -Vertrauensstellungsverwaltung vorschlug. Leider gibt es beim Windows Server jedoch diese Möglichkeit nicht mehr, woraufhin sich ChatGPT mit folgender interessanten Aussage korrigierte.

    „Entschuldigung für das Missverständnis. Sie haben recht, unter Windows Server 2019 gibt es keine direkte Option zum Bearbeiten der Namensschemainerweiterungen über die Active Directory-Domänen- und -Vertrauensstellungsverwaltung.
    Die Namensschemainerweiterungen werden automatisch von den installierten Active Directory-Domänendiensten verwaltet und sind normalerweise nicht für manuelle Änderungen vorgesehen.“

    Ich finde die Präzision der Aussagen dennoch erstaunlich, handelt es sich doch um ein Fachthema, das zwar aus der IT kommt, aber dennoch ausreichend spezifisch ist, um weniger darüber zu wissen.

    Reply
    • Google kaputt? ;)
      Wenn man das nicht selber recherchieren kann sollte man vielleicht auch keinen Exchange Server administrieren

      Reply
  2. Hallo Frank,

    ich erhalte leider den Fehler „invalid_api_key“.

    PS C:\scripts> $Script = Get-GPT3Completion „Erzeuge ein PowerShell Script für das Exchange Server Message Tracking Log. Das Script soll die letzten 10 Mails zeigen.“
    {
    „error“: {
    „message“: „“,
    „type“: „invalid_request_error“,
    „param“: null,
    „code“: „invalid_api_key“
    }
    }
    + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
    + PSComputerName : localhost

    Hast Du zufällig eine Idee, an was es liegen könnte?

    Beste Grüße
    Sebastian

    Reply
    • Das könnte daran liegen dass der API Key ungültig ist :-P
      Nicht dass du am Ende noch „APIKEY“ als API Key benutzt hast ;)

      Reply
      • Es hatte sich tatsächlich ein Fehler im API Key eingeschlichen. :-)

        Jetzt funktioniert es einwandfrei! ;-)

        Reply

Leave a Comment