How do you get your public IP address through the Windows command line?

You can use PowerShell Invoke-RestMethod:

PS > Invoke-RestMethod ipinfo.io/ip
99.109.97.210

Or the alias:

PS > irm ipinfo.io/ip
99.109.97.210

You can't. Why? There's no clear definition of a 'public ip address'. I'd note the answer's a massive abstraction, good enough to explain my point, but riddled with minor holes. Feel free to comment on big ones (so I can plug them).

Essentially, all a public ip address is is an address on a subnet that's not been reserved for private use. There's no distinction between a public and private ip address as far as the network stack's concerned. Its just routing between subnets. In theory, in a closed network, while its terrible practice, you could use a public IP address range, and doing the reverse - using a RFC 1918 address on the public internet, would likely break things.

If I run pathping (and while I'm not willing to stick my ip address out on the internet, but its not cgn, and starts with 101)

enter image description here

My ip address isn't anywhere on the route (so... your pc might actually not be aware of its public ip address).

The concept of a public ip address is nebulous too. What would it be behind double nat (eww!), or even triple nat (maybe with overlapping ip address ranges!). What would it be behind CGN or even a closed network?

In essence each router or system simply needs to know the next hop and there's no need or way for your PC to know what its public IP address is.

The reason that an external service can find your 'public' ip address is that's the hop that the message was delivered to as far as the server's concerned. It too will/does not need to know whether that's a end user's computer, a proxy behind which you have a end user's computer, a router/switch or even a toaster.