Commit cda6ce9e authored by Ben Galloway's avatar Ben Galloway

Use Start-Transcript instead of redirecting stdout

parent 01806abe
......@@ -10,9 +10,9 @@ Download a .zip file of this repository, and copy to the server. Ensure the `iis
Set the script to run on a schedule using Task Scheduler. It will need to run as `administrator`, but shouldn't need to run more frequently than once a week - say at 5am every Thursday.
The script takes one parameter - the port to bind SSL to. If this is omitted it will default to 443, but e.g. the Gamma server serves SSL on port 5729. This would be set by running `iis.ps1 -Port 5729`.
The script takes one parameter - the port to bind SSL to. If this is omitted it will default to 443, but e.g. the Gamma server serves SSL on port 5729. As an example, you might set the Task Scheduler command to be `powershell.exe` with arguments `-file C:\autocert\iis.ps1 -Port 5729`, and set the command to start in `C:\autocert`.
The script will give useful log output which you can redirect to a file by scheduling the task with appropriate arguments - for example, set the command to be `powershell.exe` with arguments `-file iis.ps1 -Port 5729 > log.txt 2>&1`, and set the command to start in `C:\autocert` (or whatever location you defined before).
A useful log output which will automatically be written to a log.txt file in the same directory as the script.
## For Windows Servers Running Exchange 2010
......
# Exchange Autocert Script
# --Ben Galloway, 6 November 2019
Start-Transcript -Path "$PSScriptRoot\log.txt"
try {
Write-Output "Retrieving current certificate..."
.\pscp -pw REPLACEME autocert@acme.gsc.org.uk:certs/win/gsc.org.uk.pfx .
......@@ -60,3 +62,5 @@ Write-Output "The certificate is now in use"
Write-Output "and will expire on $(($certInfo.NotAfter).ToString("dd MMMM yyyy"))"
Write-Output "========================="
Write-Output ""
Stop-Transcript
......@@ -2,9 +2,11 @@
# --Ben Galloway, 6 November 2019
param([Int32]$Port=443)
Start-Transcript -Path "$PSScriptRoot\log.txt"
try {
Write-Output "Retrieving current certificate..."
.\pscp -pw REPLACEME autocert@acme.gsc.org.uk:certs/win/gsc.org.uk.pfx .
.\pscp -pw REPLACEME -hostkey "c6:74:53:1c:be:7f:9b:70:50:14:c8:cd:6a:c2:a0:bb" autocert@acme.gsc.org.uk:certs/win/gsc.org.uk.pfx .
}
catch {
Write-Output "Could not retrieve certificate from the GSC certificate store."
......@@ -63,3 +65,5 @@ Write-Output "The certificate is now in use"
Write-Output "and will expire on $(($certInfo.NotAfter).ToString("dd MMMM yyyy"))"
Write-Output "========================="
Write-Output ""
Stop-Transcript
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment