ps/Modules/Alkami.PowerShell.Common/Public/Get-UsersPath.ps1

25 lines
725 B
PowerShell
Raw Permalink Normal View History

2023-05-30 22:51:22 -07:00
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);
}