Create a temporary file with a custom extension in PowerShell
Just a quick thing I wanted to record for posterity. The trick is using the -PassThru
parameter with the Rename-Item
cmdlet so that this ends up a one-liner thanks to PowerShell's pipeline:
$tempNuspec = Get-ChildItem ([IO.Path]::GetTempFileName()) | Rename-Item -NewName { [IO.Path]::ChangeExtension($_, ".nuspec") } -PassThru
Categories: PowerShell