You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add ability to create a temporary file with a specific extension to New-TemporaryFile #4215
Reacted by Flavien MICHALECZEK, Javier Collado, Andrew Dennison, Jared Kauppila, Christof Luick, Joseph Livecchi, JB Lewis, Keith Hill, Gašper Čefarin, Ben Waechter and 8 more
Whenever you need to create a temporary file to be processed by a utility that requires a specific filename extension.
Using PowerShell itself as an example, say you want to create a throw-away script dynamically, whose path you want to pass to another PowerShell instance via the CLI (powershell -File ...).
Such a throw-away script only works if it has extension *.ps1.
Reacted by JB Lewis, Gašper Čefarin, Rain Sallow (/u/ta11ow) and zett42
I opened the pull request above for it. Please ignore the commits above except for the last one as I squashed the commits in my branch into one commit at the end.
Well it's currently on track for .Net 5, meaning we could get it maybe at the end of this year for PS 7.1 if the API arrives in time (the change in PowerShell should be quite small once the API is there) dotnet/runtime#2048
Since .Net 5 and PS 7.1 have already shipped while dotnet/runtime#2048 is still "Open" with a milestone of "Future", does that mean this issue is effectively closed with the GitHub equivalent of WONTFIX?
EDIT:
Please consider to support it. My use case is relatively simple, generate a temp file with generated content in stdin (html files) and open in with msedge. Edge can't take html stdin input so I reside to making a temp file, but it couldnt read tmp file there. So I need to create a proper file and delete them instead, which is unnecessary verbose.
Activity
iSazonov commentedon Jul 11, 2017
What practical scenarios exist when do we need to change the extention?
mklement0 commentedon Jul 11, 2017
Whenever you need to create a temporary file to be processed by a utility that requires a specific filename extension.
Using PowerShell itself as an example, say you want to create a throw-away script dynamically, whose path you want to pass to another PowerShell instance via the CLI (
powershell -File ...).Such a throw-away script only works if it has extension
*.ps1.SteveL-MSFT commentedon Jul 13, 2017
Michael Klement (@mklement0) with a recent PR, if you use -File, it doesn't have to have a .ps1 extension :)
mklement0 commentedon Jul 13, 2017
Steve Lee (@SteveL-MSFT): Good point; I should have used a different example, such as
*.csvfor files to be processed by Excel, for instance.bergmeister commentedon Aug 18, 2017
I opened the pull request above for it. Please ignore the commits above except for the last one as I squashed the commits in my branch into one commit at the end.
12 remaining items
AspenForester commentedon Jun 4, 2020
Given that I just had a situation where this functionality would have helped me, I would say that this is still relevant in in June 2020
bergmeister commentedon Jun 4, 2020
Well it's currently on track for .Net 5, meaning we could get it maybe at the end of this year for PS 7.1 if the API arrives in time (the change in PowerShell should be quite small once the API is there)
dotnet/runtime#2048
Zian commentedon Aug 30, 2021
Since .Net 5 and PS 7.1 have already shipped while dotnet/runtime#2048 is still "Open" with a milestone of "Future", does that mean this issue is effectively closed with the GitHub equivalent of WONTFIX?
groutoutlook commentedon Aug 20, 2025
behold stale bot.
EDIT:
Please consider to support it. My use case is relatively simple, generate a temp file with generated content in stdin (html files) and open in with
msedge. Edge can't take html stdin input so I reside to making a temp file, but it couldnt readtmpfile there. So I need to create a proper file and delete them instead, which is unnecessary verbose.