Last active
June 30, 2021 20:42
-
-
Save dansmith65/0f7a961e5fda1b839e812d83048aa075 to your computer and use it in GitHub Desktop.
perform common tasks on a fresh server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
# Common Windows Server Setup (code downloaded from another Gist) | |
Invoke-Expression ((Invoke-WebRequest "https://gist.githubusercontent.com/dansmith65/010e9ae85a09ce9855206b7558a67b37/raw/WindowsServerSetup.ps1").Content) | |
# Open FileMaker-specific ports | |
# NOTE: you might want to add 80 and 443 to the list of ports below, but I haven't needed to in my testing on AWS yet | |
New-NetFirewallRule -DisplayName "FileMaker Server" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 5003,16000 | |
# Install FileMaker Server: CONFIG | |
$assistedInstallContents = @" | |
[Assisted Install] | |
License Accepted=1 | |
Organization=TODO | |
Deployment Options=0 | |
FileMaker Server User=0 | |
Admin Console User=TODO | |
Admin Console Password=TODO | |
Admin Console PIN=TODO | |
Launch Deployment Assistant=1 | |
License Certificate Path= | |
Skip Dialogs=1 | |
"@ | |
$dlUrl = '' # hint: use the installer link from your software download page | |
# Install FileMaker Server | |
if ($dlUrl -and -not($assistedInstallContents.Contains("TODO"))) { | |
$interactive = [Environment]::UserInteractive -and (-not ([Environment]::GetCommandLineArgs() | ?{ $_ -like '-NonI*' })) | |
$installerPath = Join-Path $env:TEMP (Split-Path $dlUrl -Leaf) | |
Write-Output "Downloading..." | |
(New-Object Net.WebClient).DownloadFile($dlUrl, $installerPath) | |
# extract downloaded file | |
Set-Location (Join-Path $env:userprofile "Downloads") | |
$7z = ((Get-Command 7z.exe -EA SilentlyContinue).Path) | |
if (! $7z) { $7z = "$env:ProgramFiles\7-zip\7z.exe" } | |
if (! (Test-Path $7z)) { $7z = "${env:ProgramFiles(x86)}\7-zip\7z.exe" } | |
if (Test-Path $7z) { | |
.$7z x $installerPath -o"""$(Join-Path $env:userprofile 'Downloads')""" | |
} elseif ($interactive) { | |
Write-Output "Cancel installation once extraction is complete" | |
Start-Process -FilePath $installerPath -Wait | |
} else { | |
Write-Output "ABORTED: 7zip command line tool is required to install FMS from a non-interactive shell" | |
} | |
# export config files | |
$installerRootDir = (Get-ChildItem "FileMaker Server*" | Sort-Object -Descending CreationTime)[0].FullName | |
# NOTE: FMS18's Setup.exe is in a Files folder, FMS19.2 is not | |
$setupPath = (Join-Path $installerRootDir "\Setup.exe") | |
$assistedInstallContents | Out-File (Join-Path (Split-Path $setupPath -Parent) "Assisted Install.txt") -Encoding unicode | |
# run installer | |
Start-Process -FilePath $setupPath -ArgumentList $(if($interactive){"/s /v/qb+"}else{"/s /v/qn"}) -Wait | |
} else { | |
Write-Output "you must configure before you run this code" | |
} |
Can install FMS with your own license by adding:
$licenseCertContents = @"
TODO: replace this line with your certificate file contents
"@
# add this line right before Start-Process:
[System.IO.File]::WriteAllLines((Join-Path (Split-Path $setupPath -Parent) "LicenseCert.fmcert"), $licenseCertContents) # don't use Out-File because it creates utf8 with BOM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NOTE: This script MUST be modified before using; refer to the Install FileMaker Server: CONFIG section
Can be run on a new AWS EC2 instance by wrapping it in
<powershell></powershell>
. Refer to this link for more info: https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-windows-user-data.htmlOther Gist's referenced by this one: