Gilgamech Technologies

From the sublime to the ridiculous.



12/31/2021 - Wintertime acceleration traction.

Ice is well known for having much less friction than bituminous tarmacadam (aka asphalt), a situation that often confounds drivers in winter. Indeed, ice's coefficient is about 5%, while dry asphalt's is up to 70%, with 40% for wet asphalt, for an all-season radial tire. Untreaded racing slicks increase this to 90% when dry - and this falls to 10% when wet, which is why racecar drivers make a pitstop when it starts raining, to change to all season radials.

This compounds the internal combustion engine's "initial inertia" issue - how to get a vehicle started from a full stop. Moving a vehicle from 0 MPH means adding momentous energy to it until it reaches 1 MPH, and so on and so forth, until it reaches the desired speed. The internal combustion engine has a minimum rotation speed (usually around 800 RPMs) to remain operational - lower than this and an individual combustion doesn't have the energy to rotate the engine. So there's a gap between the 800 RPM minimum and the, like, 1 RPM needed to reach that 1 MPH. How to bridge it? Rails for trains have a coefficient of max 50% when dry and 30% when wet, which is right around the 40% for wet asphalt. So trains essentially "spin out" until the train gets close to the wheel's speed. And while fine with steel wheels, Ken Block eats styrene-butadiene tires for breakfast.

Energy transmission and conversion.

So how do cars solve this? Transmissions, which convert some of the rotational energy into more torque. Several types are common:

Most of these are designed around a minimum friction coefficient around that of all season tires on wet asphalt of 40%, which creates another gap with ice's 5% coefficient.

Relationship with tire speed:

The other side of this issue is the maximum wheel torque possible to maintain friction. Asphalt has a much, much higher capacity for heat, and so can absorb and withstand significantly more torque than ice before changing states to liquid. (This can still happen in the summer heat.) The friction coefficient represents this, where 1 minus the coefficient is turned into heat, and the friction coefficient becomes the percentage of energy that can be transferred without melting the surface. Liquids basically have viscosity instead of friction, and liquid water has low viscosity, causing the tire to spin once too much energy has been transferred - as the water transitions from solid to liquid, its abiltiy to frictionally transfer energy plummets. So this is an equation with a minimum rotation based on engine speed, and a maximum rotation based on the coefficient, meaning the equation sometimes doesn't balance. This results in the system having either too-low rotational energy (engine stall) or too high rotational energy (spin out), or sometimes both at once. There is no Goldilocks here.

And there are yet more solutions to bridge this:

Electric cars (both BEV and Hybrid) can use a type of eAWD. These cars are known for high torque output at zero RPMs, which is a struggle described above for internal combustion. The drivetrains are decoupled from any minimum rotations needed by an internal combustion engine, and are free to output the motor's maximum. And often an electric car's accelerator pedal inputs are written pretty aggressively to the motor outputs, to showcase performance on dry pavement. Which reintroduces the power gap described above for internal combustion.

Many come with another option: Eco mode

Eco mode makes the accelerator pedal a lot less sensitive, like there's a spring between it and the throttle body, which is perfect for snow and ice (and sand and gravel, but those are other stories). Going just 1 or 2 MPH becomes effortless, and while you're not racing around downtown like a 4x4 lifted truck, you're not stuck in a parking lot either. Plowed roads and packed snow turn into viable routes, and snow goes from being exciting to merely pretty.



12/28/2021 - What's the difference between kilowatts and Newton-meters?

Cars are rated in both - often seeing a peak in KW a lower engine rotational output than Netwon-meters.

These are the SI conversions from traditional measurements of horsepower (HP - the force necessary to lift a total mass of 33,000 pounds upwards by one foot in one minute) and torque (lb-ft, the force necessary to lift a total mass of 1 pounds rotationally at one foot from the pivot point.) Indeed, these can be converted to each other, once resolving the dimensional mismatch: Torque has units of mass and height, but HP has units of mass and height, and time which will have to be divided off. So torque can be converted to HP/min, giving 1 HP/min = 33,000 lb-ft. But there's still the rotation - the 33,000 has to be divided around a circle, aka by 2π, so 1 HP/min = 5252 lb-ft.

A little history.

Horsepower was originally determined from the amount of work a horse performed over a day while pulling a mill wheel. Torque comes from the Roman name for the twisting patterns of Celtic necklaces, and now means the forces involved in twisting or rotation.

So what's being measured here?

Converting them to SI units are a clue. Broadly speaking, Horsepower is energy delivered across a span of time, while torque is energy delivered at a moment in time. (Humans are capable of generating more than 1 HP in short bursts.) Torque is the ability to spin the wheels, while kW/HP is the ability to convert fuel into raw velocity. Combustion engines give different RPM values for these as energy output doesn't scale linearly with fuel consumption, partly due to engine timing differences, and partly due to the gearbox which is basically mandatory with internal combustion.

Last notes:

Horsepower is a time-dependent metric, but people often rattle it off without the time dimension, making it meaningless. Pay attention to torque and 0-60 numbers.



12/25/2021 - Information transmission with quantum entanglement.

Entangled particles have no propagation delay, despite the distances between them. And they will always have inverted polarity. So we have a sender and receiver, and the receiver always measures the polarization in the Z-down direction. The sender is transmitting a binary stream, and so measures in the Z-up direction for 1s, and for 0s measures in the X-down direction. Measuring "resets" the polarity along the measured direction, in the same way that all photons passing through a polarized film (aka sunglasses) are polarized in the same direction from the film's tiny slits. (This polarization is a huge part of the double-slit experiment.) And so the recipient would measure in the Z-down direction foreach of these, and converting the positive Z-down outcome as 1s, leaving the rest to zeroes. X-down measurement will result in an X-up polarization of the remote particle, so in theory this would always generate a negative result in a Z-down measurement. - the actual measurement vector of the binary zero might be a different measurement. And of course data would travel through data redundancy tools like Hamming codes, just like CDs and RAM, to prevent single-bit transmission losses.



12/23/2021 - Code chunk to update SG:

#Step 1: Prereq Variables

[string]$AvailabilityZone = "us-west-2a"
$DefaultSecurityGroupID = "sg-123456" #Update with your hosting SG.

#Step 2: Prereq Functions

#These can be found in my December 1st post, among others.

#Function Flip-BytesToText
#Function Reset-AwsApiKey
#Function New-RdpSecurityGroup

#Step 3: Main Code

Set-DefaultAWSRegion -Region ($AvailabilityZone.Substring(0,$AvailabilityZone.Length-1))
$currentServer = (Get-EC2Instance).Instances
[string]$SubnetID = $currentServer.subnetID
$Subnet = get-ec2subnet $SubnetID
[int]$CurrentSecurityGroupName = (Get-EC2SecurityGroup | where {$_.description -match "Created on"}).GroupName
Reset-AwsApiKey
$newSecurityGroupID = New-RdpSecurityGroup
$newServer = (Get-EC2Instance $newServer.instanceid).Instances
Edit-EC2InstanceAttribute -InstanceId $newServer.InstanceId -Group @($DefaultSecurityGroupID, $newSecurityGroupID)
Remove-EC2SecurityGroup -GroupId (Get-EC2SecurityGroup -GroupName $CurrentSecurityGroupName).GroupId -Force


12/22/2021 - If a tree falls in the forest, and there's nobody around, is it art?

...imitates life imitates art imitates life imitates art...

Life and art oscillate through an imitation field as they travel through time, not unlike electric and magnetic fields.

If you're comprehending this, then you're a set of chemical and physical processes complex enough to have developed a consciousness, and maybe emotions too. As sounds are merely vibrations until turned into electomechanical sensations by our bodies and brains, so too art is merely a collection of objects (or vibrations, see music) until turned into electromechanical sensations by our bodies and brains.

A lot of living objects are incapable of perceiving art, and so cannot imitate it. And some living objects *are* art, as they make other living objects feel emotions, such as the desire to smash/pairbond/eat the earlier life. As though life and art are two aspects of the same coin - life is art, and art creates impulses that drive life.

A tree falling in a forest - it makes me feel glad I'm not there for the tree to injure.



12/21/2021 - Inverted dice values making a moire pattern.

Table 1: Started with a classic 2d6 table:

+123456
1234567
2345678
3456789
45678910
567891011
6789101112

This shows all possible values, with the classic diagonal gradient, showing how entropy makes 2d6 sum to 7 more often than any other value, across the diagonal from the lower-left corner to the upper-right corner. The two d6 are the axes, and the dice rolls are the center of the chart. It's a nice and pretty gradient going from the upper-left corner to the lower-right corner. But what if we pretended these were waves, with the even numbers being the wave's positive amplitude, while odd numbers are the negative crests?

Table 2

+-12-34-56
-1-21-43-65
214-16-38
-3-4-1-61-83
43618-110
-5-6-3-8-1-101
658310112

It seems like a moire pattern at first glance. After staring at it for a bit, the first thing I saw was that only even numbers seem to follow the same gradient pattern as the above chart, but they flip-flop from positive to negative as they move across the diagonal from lower-left to upper-right - very wavelike! The second thing I noticed was that odd numbers do have diagonals, but they're the other diagonal (upper-left to lower-right, just like the 7s in the top table), and also flip-flop from positive to negative.

Table 3: Flipping this pattern, from odd-negative to even-negative, just reverses the signs of Table 2.

+1-23-45-6
12-14-36-5
-2-1-41-63-8
3416-18-3
-4-3-6-1-81-10
5638110-1
-6-5-8-3-10-1-12

For diagonal clarity, we can call lower-left to upper-right "red diagonals" the others, upper-left to lower-right are "blue diagonals".

Some numbers become unavailable with this odd-negative system from Table 2: -12, 0, 7, 9, 11, and any odd negative number. This is because numbers which sum with their like types (even + even and odd + odd) increase in magnitude (away from 0), but those that cross (even + odd) decrease in magnitude towards 0. And summing like types results in even numbers, while crossing types produces odd numbers. 7, 9, and 11 are unavailable because they're larger than the largest d6 role, meaning they can't be reached subtractively, only additively - but being odd, they can only be built from a cross-type sum, which can only decrease in magnitude towards zero in this system. In other words, no code paths lead to their output in this finite state machine. -11, -9, and -7 are similar, with the added caveat that both even and odd halves of the cross-type sum would have to be negative, so are doubly unlikely. -12 being unavailalble is an artifact of only being rechable if the largest d6 role is negative, and that being false here, making this code path also unavailable. Zero is unavailable as there are no equal opposite values.

Table 4: One step further.

+-12-34-56
103-25-47
-2-30-52-74
32507-29
-4-5-2-70-92
54729011
-6-7-4-9-2-110

Mix an even-negative die and odd-negative die. This gives a very different pattern, with a 0 down the middle red diagonal, and numbers reflected across that middle red diagonal - if the upper-right half were "positive", the lower-left half would be "negative", as numbers are the same magnitude but with opposite sign. And unusually, even and odd have switched places, with even numbers on the blue diagonals, and odd numbers on the red diagonals.

Numbers -12, -10, -8, -6, -1, 1, 6 8, 10, 12 are unavailable here, almost exclusively even numbers. Unlike Table 2, like-type addition decreases in magnitude while cross-type increases in magnitude, but summing like types still results in even numbers (and crossing types produces odd numbers). So even numbers can only be reached by reducing in magnitude, making those equal or above the d6 max roll off limits. And odd numbers can only be reached by increasing in magnitude, blocking off 1 and -1 (which are odd for our purposes here).

Not sure what to do with this info? You're not alone, as I'm not sure what to do with it either.

Table 5: Moar Analysis - rebuilding the original table.

The red diagonals from the third and fourth tables combine to remake the first table, but with alternating positive and negative rows:

+1/-1-2/23/-3-4/45/-5-6/6
1234567
-2-3-4-5-6-7-8
3456789
-4-5-6-7-8-9-10
567891011
-6-7-8-9-10-11-12

Table 6: Reverting the negatives.

This brings back Table 1:

+123456
1234567
2345678
3456789
45678910
567891011
6789101112

Table 7: The other half.

What do you get when you combine the blue diagonals from the third and the fourth tables? This is like the opposite of Table 5:

+-1/12/-2-3/34/-4-5/56/-6
10-1-2-3-4-5
-2-101234
3210-1-2-3
-4-3-2-1012
543210-1
-6-5-4-3-2-10

Table 8: Reverting Table 7's negatives.

This gives us a subtraction table:

-123456
10-1-2-3-4-5
210-1-2-3-4
3210-1-2-3
432-10-1-2
543210-1
6543210

Is this the inverse or complement of Table 1?



12/20/2021 - The Log4J hack explained.

The hack itself is pretty simple, as explained by FitMC: just send "${JDNI:LDAP" followed by any command (and eventually the closing curly brace). Here's how it works:

And that's pretty much it. This exploit uses built-in Java notation to escape Log4J program, and a built-in Java directory lookup service, which seems to allow arbitrary code execution. Evil here isn't the result of people acting maliciously and writing evil code with their "evil hats" on, but the result of gaps between good intentions. Unlike Batman or Charlie's Angels, there's no Mr Robot to punch away and stop future hacks. Instead, a resurgence of code analysis tools and code evaluation techniques will likely create the greatest benefit at the least cost.



12/15/2021 - Capitalism levels.

Capitalism is a system for transferring and exchanging physical, liquid, and intangible assets. It has 2 categorizes for resources: money, and everything that can be bought with money - which includes the time of humans to perform work that legally belongs to you.

  1. Provide Raw Materials: From mining, lumberjacking, farming, shipping (traveling merchants), etc.
  2. Build Components: Take raw materials and turn them into tools. (Foundry forms refined ores into sheets, wires, tubes, and other forms.)
  3. Assemble Components: Take tools as components and assemble into composite products (Radio maker takes coils, crystals, speakers, wires, & wooden boxes, and outputs radios.)
  4. Expand the Market: Transform products into new forms that open up new uses and/or new customers. (Miniaturize the cabinet-sized radio into a pocket radio.)
  5. Advertising: People tend to do what they're told, so tell them to buy your radio.
  6. Market Capture: Merge with old competition and acquire new competition. Spin off irrelevant SBUs in other markets to maintain regulatory compliance.
  7. ?


12/14/2021 - Legends and Theories.

Legends and theories are both stories. Legends are supposed to always be false if they are falsifiable, while theories must be falsifiable but can be true. But sometimes legends become true too.

FalsifiableFalseTrue
LegendEitherAlwaysNever
TheoryAlwaysEitherEither
OopsYesNoYes

So is a falsifiable legend that becomes true actually a theory?



12/11/2021 - Two Megabytes of World History!!1!.

The World History page, including over 6,000 past and future events, now weighs in a at a beefy 2,098,673 bytes of history in a big table. This project was started in 2016, but didn't hit the 1 MB mark until shortly after going online in August, so that's 1 MB or 3000 entries in 120 days, or 25 per day. Most of these were periodic events like reigns of kings, emperors, pharoahs, and cicadas. Based on an average rate of 10 per day, we should reach 3 MB or 9000 total entries in October 2022. Future plans include "We didn't start the fire" for January and maybe February, depending on how long it takes. Then catching up on the nigh-infinite backlog. Happy reading!



12/7/2021 - This backpack is a game-charger.

This has been in the back of my mind for over 20 years - a laptop backpack that you could plug in. APC killed off this idea around 2007 by releasing an inferior product - a laptop bag with some USB ports and a built-in USB battery. So here is the kit:

It enables a portable IT generalist to use their laptop across a variety of modes:

Freedom to game and travel around the planet can be yours for just $699. Order yours now!.



12/6/2021 - Birds and squirrels plant seeds.

As winter approaches, birds, squirrels, and other small woodland creatures hide seeds to eat through the darker months, when the self-assembling solar-powered machines (plants) are receiving too little solar radiation and ambient heat to effectively grow and produce fruit. Many of these critters have common hiding places of under specific rocks, branches, roots, etc - in the ground, where it could seed and grow in the spring. But first the bird or squirrel retrieves it for a meal...unless an owl, fox, or car got to the critter first, in which case the hidden snacks are already in the ground to start growing next spring.

Yes, seeds transport in a great many ways (defecation vacation), but this pattern has struck me for some time as uniquely special - animals planting seeds - and has a symmetry with bees having to brush past plant gentials to get the tasty syrup. Like one organism where the DNA needed to survive is split between lineages in two different biological kingdoms.



12/5/2021 - This is now called "bong science".

"The photon goes through both slits, and because we're not watching very closely, it interferes with itself as it goes through, so it hits the back wall in this pattern of lines. Isn't quantum physics weird, man?"

It's like there are two schools of thought on quantum physics:

It's Sabine Hossenfelder that's popular among first group lately, and her videos have reignited much of my interest in quantum physics.

The second group are pushing what I'm calling "bong science" - everyone circle around with your cannabis vape pens and get a load of how strange are these quantum particles. Can you believe quarks live in a threesome? In the double-slit experiment, Copenhagen says we aren't able to know which slit the photon chooses to go through, unless we "observe" and then it stops making the cool lines. - taking ideas from different theories like science is a salad bar, Frankensteining a theory which is mostly wrong, a little made up, very entertaining, and entirely useless. But at least it sells those ad clicks!



12/2/2021 - What new democratization of technology will not be foreseen by futurists before it arrives?

Why did no futurist predict the iPhone? Why did nobody foretell the Model T in popular culture?

One oft-noted futuristic prediction is the proto-nuclear submarine in that foundational underwater science fiction classic, 20k Leagues Under The Sea. The powerplant enables indefinite submerged operation, unlike the other alternatives - diesel-electric (with huge batteries that last for days) or steam (which required an overwhelming ship and may have lasted for days). In the 1980s, pressurized air became a supplementary power storage option, adding maybe a day to the diesel-electric option.

Ford's Model T was like the iPhone or PSVR of cars. It democratized the technology and brought it down to a price point where everyone could afford one and rich people could afford 5. This didn't happen for trains because of the difficulty in sharing rails as compared to sharing roadways, where you can just signal and change lanes, and don't need a switched section of roadway to hop to a neighboring lane. (In roads, narrow curbs can still be added between lanes to prevent lane-changing and shape traffic flow around congested areas.) Instead, the "block" system was developed in the 1800s to prevent two trains from using the same section of track, after numerous deadly train collisions in the UK.



12/1/2021 - Site rotation code update.

#It's become a tradition on this blog to start the month with a new iteration of the same old code. Added annotation for steps to be done "remote" (your own laptop etc) vs "server" (the one you're building). Fun fact: The "code" sections below are actually grey (same #ccc as always) and only look red due to the contrast with the "bubble" div.

#Remote

#Step 1: Initializing server variables

#Step 1a: Manual variables - update with your private values:

[string]$AvailabilityZone = "us-west-2a"
[string]$DefaultSecurityGroupID = "DEFAULTSG"
[string]$Keypair = "KEYPAIRNAME"
[string]$PemFile = "C:\Secure\Location\$Keypair.pem"

#Step 1b: Dynamic variables - just run these.

Set-DefaultAWSRegion -Region ($AvailabilityZone.Substring(0,$AvailabilityZone.Length-1))
$currentServer = (Get-EC2Instance).Instances
[string]$SubnetID = $currentServer.subnetID
$Subnet = get-ec2subnet $SubnetID
[int]$CurrentSecurityGroupName=(Get-EC2SecurityGroup | where {$_.description -match "Created on"}).GroupName

#Prerequisite 1: utility function:

#This function takes bytes as input, and outputs ASCII (or Unicode) characters.

Filter Flip-BytesToText {
    Param(
      [switch]$Unicode
    ); #end Param
    [int]$Unicode2 = 0
    $ReturnString = ""
    if ($_) {
      if ($Unicode) {
        $ReturnString = [System.Text.Encoding]::Unicode.GetString(($_,$Unicode2))
      } else {
        $ReturnString = [System.Text.Encoding]::ASCII.GetString($_)
      }; #end if Unicode
      if ($ReturnString -ne "") {
        return $ReturnString
      }; #end if ReturnString
    }; #end if _
}; #end Flip-BytesToText

#Prerequisite 2: Rotate AWS key

#Updating this function with a progress bar to countdown the 30 seconds.

Function Reset-AwsApiKey {
    $oldKey = (Get-AWSCredential default).GetCredentials().AccessKey
    $key = New-IAMAccessKey
    Set-AWSCredential -AccessKey $key.AccessKeyId -SecretKey $key.SecretAccessKey -StoreAs default
    0..30| %{Write-Progress -Activity "Sleeping for keys to settle down." -Status "Countdown to 30 seconds: $_" -PercentComplete ($_*3.33);sleep 1}
    Remove-IAMAccessKey -AccessKeyId $oldKey -Force
}

#Step 2: New Security Group

#Updating this function with a better name for the SG.

Function New-RdpSecurityGroup {
    [ipaddress]$IpAddress = (((iwr https://checkip.amazonaws.com).content | Flip-BytesToText ) -replace "`n","" -join "")
    [string]$IpCidr = ($IpAddress.IPAddressToString+"/32")

    [string]$GroupDesc="Created on "+(Get-date -f d)+" - access from "+$IpCidr
    New-EC2SecurityGroup -Description $GroupDesc -GroupName ($CurrentSecurityGroupName+1) -VpcId $Subnet.VpcId

    $cidrBlocks = New-Object 'collections.generic.list[string]'
    $cidrBlocks.add($IpCidr)

    $ipPermissions = New-Object Amazon.EC2.Model.IpPermission
    $ipPermissions.IpProtocol = "tcp"
    $ipPermissions.FromPort = 3389
    $ipPermissions.ToPort = 3389
    $ipPermissions.IpRanges = $cidrBlocks

    Grant-EC2SecurityGroupIngress -GroupName ($CurrentSecurityGroupName+1) -IpPermissions $ipPermissions
}

#Step 3: Build Windows server

#This step ends in a 5 minute wait for the new server to complete building.

Reset-AwsApiKey
$newSecurityGroupID = New-RdpSecurityGroup
$newServer = (New-EC2Instance -ImageId (Get-EC2ImageByName "WINDOWS_2016_BASE").ImageId -SecurityGroupId $newSecurityGroupID -InstanceType "t2.micro" -AvailabilityZone $AvailabilityZone -KeyName $Keypair -SubnetId $Subnet.SubnetId).instances
0..300| %{Write-Progress -Activity "Sleeping for server $($newServer.instanceid) to complete." -Status "Countdown to 300 seconds: $_" -PercentComplete ($_*.333);sleep 1}
$newServer = (Get-EC2Instance $newServer.instanceid).Instances

#Step 4: Login and configure

#Step 4a: Server login

#This retrieves the password and launches MSTSC (MS-RDP) to the server. Instead of storing the server password, store this command.

Get-EC2PasswordData -InstanceId $newServer.InstanceId -PemFile $PemFile -Decrypt | clip
mstsc.exe /v:($newServer.publicIPaddress)

#Server

#Step 4b: Client variables - manual

#Again, update these with your own values

[string]$rootDomain = "Example.com"
[string]$subDomain = "Subdomain"
[string]$CFAuthKey = 'CFAUTHKEYGOESHERETHISONEISLONG'
[string]$CFAuthEmail = 'YourEmail@$rootDomain'
[string]$PFXPass = '$tr0ngPa$$W0rdG03$|-|3r3'

#Step 4c: Client variables - dynamic

#Just run 'em.

[array]$Domains = ("*.$rootDomain","*.$subDomain.$rootDomain","$rootDomain")
[string]$ContactEmail = 'Contact@$rootDomain'
[string]$DownloadPath = "C:\LetsEncryptCerts\$((Get-Date).ToString('yyyyMM'))"
[array]$Computer = ((hostname))
[string]$FriendlyName = ("LetsEncrypt_$((Get-Date).AddDays(90).ToString('yyyy-MM-dd'))")

#Step 4d: Install software

#These install IIS, upgrade .NET's outbound security protocol to TLS 1.2, and install the Posh-ACME module. Posh-ACME is the toolkit that lets us request the LE cert. The TLS upgrade is needed because TLS 1.1 is used for compatibility, but more secure hosts disconnect instead of negotiating.

Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module -Name Posh-ACME -Force

#Step 5: Request LE Cert

#Step 5a: Information Gathering

#Feel free to copy website code to c:\inetpub\wwwroot before/while running these steps.

Set-PAServer LE_PROD
$CFParams = @{CFAuthEmail=$CFAuthEmail; CFAuthKey=$CFAuthKey}
$NewCertificate = New-PACertificate $Domains -AcceptTOS -Contact $ContactEmail -DnsPlugin Manual -FriendlyName $FriendlyName -PluginArgs $CFParams -DNSSleep 180 -PfxPass $PFXPass -Force

#Step 5b: Goto your registrar and add the A records for _acme-challenge et al.

#Leave off the domain when adding to the registrar website or console. This process uses manual domain verification, until Google Domains automation can be developed.

C:\Programs\BIND\dig.exe txt `@8.8.8.8 _acme-challenge.$rootDomain

#Step 5c: Copy to fileserver

mkdir $DownloadPath -Force
$Path = Get-PACertificate | select -ExpandProperty CertFile
$Path = $Path.Substring(0,$Path.LastIndexOf('\'))
Copy-Item "$Path\cert.cer" $DownloadPath -Force
Copy-Item "$Path\cert.key" $DownloadPath -Force
Copy-Item "$Path\cert.pfx" $DownloadPath -Force

#Step 5d: Import PFXPassword, ComputerList and Thumbprint

$PFXPassword = $PFXPass | ConvertTo-SecureString -AsPlainText -Force
$Thumbprint = $NewCertificate.Thumbprint

#Step 5e: Deploy

Copy-Item "$DownloadPath\Cert.pfx" "\\$Computer\c$"
Import-PfxCertificate -FilePath "C:\cert.pfx" -CertStoreLocation Cert:\LocalMachine\My\ -Exportable:$false -Password $PFXPassword
$Cert = Get-ChildItem Cert:\LocalMachine\My\$Thumbprint
$Cert.FriendlyName = $FriendlyName

#Step 5f: Cleanup

Remove-Item "\\$Computer\c$\cert.pfx"
Get-ChildItem Cert:\LocalMachine\My\ | Where-Object {($_.Subject -eq "CN=*.$rootDomain") -and ($_.ThumbPrint -ne $Thumbprint)} | Remove-Item -Force

#Step 6: Bind port 443 to IIS

#Now that we've populated the SSL cert, we can bind applications to port 443.

New-WebBinding -Name "Default Web Site" -IPAddress "*" -Port 443 -Protocol "https"
(Get-WebBinding -Name "Default Web Site" -Port 443 -Protocol "https").AddSslCertificate($Thumbprint, "my")

#Remote

#Step 7: Add hosting access to server

#This lets the public internet reach the server on ports 80 and 443. Updated to lookup the sole instance ID.

Edit-EC2InstanceAttribute -InstanceId $newServer.InstanceId -Group @($DefaultSecurityGroupID, $newSecurityGroupID)

#Step 8: Transfer domain in Google Domains

#Move the domain to your new server's public IP. This is a todo.

#Step 9: Cleanup old server and SG.

#Deleting the server will remove the public IP too. Then removing the SG completes cleanup.

Remove-EC2Instance -InstanceId $currentServer.InstanceId -Force
Remove-EC2SecurityGroup -GroupId (Get-EC2SecurityGroup -GroupName $CurrentSecurityGroupName).GroupId -Force