function Get-UsersPath { <# .SYNOPSIS Get the path to the root of the Users folder for Windows or macOS. Will optionally append the provided username path as well, when provided. .PARAMETER Username [Optional] The username folder to append. This is provided as a helper parameter. #> [CmdletBinding()] Param( [Parameter(Mandatory = $false, Position = 0)] [string]$Username = "" ) $systemDrive = $env:SystemDrive if ([string]::IsNullOrWhiteSpace($systemDrive)) { $systemDrive = (Get-Item -Path $PSScriptRoot).PSDrive.Root } # (Join-Path C:\ "") -> C:\ # (Join-Path C:\ $null) -> C:\ return (Join-Path (Join-Path $systemDrive "Users") $Username); }