Skip to content

Instantly share code, notes, and snippets.

@rpunt rpunt/mktemp.ps1
Created Feb 15, 2020

Embed
What would you like to do?
I've wanted mktemp in powershell forever, so... fine.
function mktemp {
param (
[Parameter(mandatory=$false)]$Extension
)
$randomfile = [System.IO.Path]::GetRandomFileName()
if ($Extension) {
$randomfile = [System.IO.Path]::ChangeExtension($randomfile, $Extension)
}
return Microsoft.PowerShell.Management\Join-Path ([System.IO.Path]::GetTempPath()) "$randomfile"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.