certify icon indicating copy to clipboard operation
certify copied to clipboard

Example script for Exchange doesn't work

Open altwohill opened this issue 8 years ago • 9 comments

Hi!

Looking at https://github.com/webprofusion/certify/blob/development/docs/Request%20Script%20Hooks.md,

The script for loading the exchange certificate param($result) Enable-ExchangeCertificate -Thumbprint $result.ManagedItem.CertificateThumbprintHash -Services POP,IMAP,SMTP,IIS

doesn't work, giving the following error

Post-Request Script output: Enable-ExchangeCertificate: The term 'Enable-ExchangeCertificate' 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

I guess this is because the base powershell doesn't include the connection to Exchange.

I've tried adding in $CallEMS = ". '$env:ExchangeInstallPath\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto -ClientApplication:ManagementShell " Invoke-Expression $CallEMS

This works using an administrative powershell session, but does not work when testing with CertifyTheWeb, giving a bunch of errors saying cannot find the file specified

Any ideas on how to get around this?

altwohill avatar Mar 07 '18 02:03 altwohill

Hi, can you confirm which version if Exchange this is and that you're running Certify on the same server exchange is installed on?

webprofusion-chrisc avatar Mar 07 '18 08:03 webprofusion-chrisc

Hi, this is with Exchange 2013, and yes, it's on the same machine.

altwohill avatar Mar 07 '18 20:03 altwohill

Thanks, and is this Windows Server 2012?

webprofusion-chrisc avatar Mar 07 '18 23:03 webprofusion-chrisc

yep - Server 2012 R2

altwohill avatar Mar 08 '18 21:03 altwohill

Under the latest version of Certify, the background service does all the work as Local System, so you may need to make sure Local System has admin rights for Exchange

webprofusion-chrisc avatar Mar 10 '18 03:03 webprofusion-chrisc

@mobiusnz

i had the same problem, but i have a working script now!

Note > Change "Server01" to you Exchange Server Name ;)

param($result) set-alias ps64 "$env:windir\sysnative\WindowsPowerShell\v1.0\powershell.exe" ps64 -args $result -command { $result = $args[0] write-output "Powershell Script Erfolgreich?" $result.IsSuccess Add-PSSnapin Exchange Enable-ExchangeCertificate -Server "Server01" -Thumbprint $result.ManagedItem.CertificateThumbprintHash -Services "SMTP, IMAP, POP, IIS" –Force }

Jaggl-AT avatar Mar 10 '18 12:03 Jaggl-AT

Great! We should probably just look at getting the powershell engine to be 64bit by default, unless you're on 32-bit. We currently run 32-bit because there's some users on 32-bit server 2008/2008 r2.

Is 'Add-PSSnapin Exchange' required?

webprofusion-chrisc avatar Mar 10 '18 12:03 webprofusion-chrisc

i see the form here don't like the * yes you need this command to include the Exchange PSSnapin

the command is: Add-PSSnapin * Exchange * > delete the blank space before/after the *

Jaggl-AT avatar Mar 10 '18 12:03 Jaggl-AT

Closing as resolved

webprofusion-chrisc avatar Feb 23 '19 09:02 webprofusion-chrisc