PSCredentialStore/src/Private/Get-TempDir.ps1

42 lines
828 B
PowerShell
Raw Normal View History

function Get-TempDir {
<#
.SYNOPSIS
Returns the valid temp dir of the current OS
.DESCRIPTION
Returns the valid temp dir of the current OS.
.INPUTS
[None]
.OUTPUTS
[string]
.EXAMPLE
Get-TempDir
#>
2022-06-28 08:24:33 +02:00
[CmdletBinding()]
[OutputType([string])]
2022-06-14 09:19:59 +02:00
param ()
2022-06-14 09:19:59 +02:00
begin {}
2022-06-28 08:24:33 +02:00
process {
if ($IsLinux) {
return (Resolve-Path -Path '/tmp/').Path
}
if ($IsMacOS) {
return (Resolve-Path -Path '/tmp/').Path
}
2022-06-28 08:24:33 +02:00
elseif (
($isWindows) -or
($PSVersionTable.PSVersion.Major -lt 6) -or
($PSVersionTable.PSEdition -eq 'Desktop')
) {
return (Resolve-Path -Path $env:TEMP).Path
}
}
2022-06-28 08:24:33 +02:00
end {}
}