PowerShell path separator based on OS

I tend to use PowerShell Core on both macOS and Windows so whenever a script of mine needs to refer to some file (like a certificate in the example below) I usually have a snippet like this:

The only thing the above does is use \ or / in the path depending on the OS.

Then I realized I could shorten it a bit coz PowerShell has the $IsWindows, $IsMacOS, $Linux variables so I started using the following instead:

Today I came across a different method thanks to this blog post: Tips for Writing Cross-Platform PowerShell Code. Use Join-Path. Hence I can do:

I also learnt from there of the [IO.Path]::DirectorySeparatorChar property:

More interesting stuff in that blog post above btw so check it out!