Marco Blessing
3d90d912ee
All checks were successful
continuous-integration/drone/push Build is passing
#### 📖 Summary <!-- Provide a summary of your changes. Describe the why and not how. --> #### 📑 Test Plan > 💡 Select your test plan for the code changes. - [x] Tested via Drone.io pipeline - [ ] Custom test - [ ] No test plan ##### Details / Justification <!-- Add your test details or justification for missing tests here. --> #### 📚 Additional Notes <!-- A place for additional detail notes. --> Co-authored-by: OCram85 <marco.blessing@googlemail.com> Reviewed-on: #62
63 lines
1.7 KiB
PowerShell
63 lines
1.7 KiB
PowerShell
function Get-DefaultCredentialStorePath {
|
|
<#
|
|
.SYNOPSIS
|
|
Returns the default CredentialStore path based on the current OS.
|
|
|
|
.DESCRIPTION
|
|
This is a low level helper function.
|
|
|
|
.INPUTS
|
|
[None]
|
|
|
|
.OUTPUTS
|
|
[string]
|
|
|
|
.EXAMPLE
|
|
$Path = Get-DefaultCredentialStorePath
|
|
#>
|
|
|
|
[CmdletBinding()]
|
|
[OutputType([string])]
|
|
param (
|
|
[Parameter(Mandatory = $false)]
|
|
[switch]$Shared
|
|
)
|
|
|
|
begin {}
|
|
|
|
process {
|
|
if ($Shared.IsPresent) {
|
|
if ($IsLinux) {
|
|
return Join-Path -Path '/var/opt' -ChildPath 'PSCredentialStore/CredentialStore.json'
|
|
}
|
|
if ($IsMacOS) {
|
|
return Join-Path -Path '/var/opt' -ChildPath 'PSCredentialStore/CredentialStore.json'
|
|
}
|
|
elseif (
|
|
($isWindows) -or
|
|
($PSVersionTable.PSVersion.Major -lt 6) -or
|
|
($PSVersionTable.PSEdition -eq 'Desktop')
|
|
) {
|
|
return Join-Path -Path $env:ProgramData -ChildPath 'PSCredentialStore/CredentialStore.json'
|
|
}
|
|
}
|
|
else {
|
|
if ($IsLinux) {
|
|
return Join-Path -Path $Env:HOME -ChildPath 'CredentialStore.json'
|
|
}
|
|
if ($IsMacOS) {
|
|
return Join-Path -Path $Env:HOME -ChildPath 'CredentialStore.json'
|
|
}
|
|
elseif (
|
|
($isWindows) -or
|
|
($PSVersionTable.PSVersion.Major -lt 6) -or
|
|
($PSVersionTable.PSEdition -eq 'Desktop')
|
|
) {
|
|
return Join-Path -Path $env:AppData -ChildPath 'CredentialStore.json'
|
|
}
|
|
}
|
|
}
|
|
|
|
end {}
|
|
}
|