locked
New-TemporaryDirectory works in ISE but not anywhere else RRS feed

  • Question

  • Hi all!

    I discovered I can create a temporary folder using the New-TemporaryDirectory command in Powershell ISE, much like creating a temporary file using New-TemporaryFile. The New-TemporaryDirectory works properly(creates a temporary folder and stores desired files, etc) when run in the ISE but not when I run my program containing it on the cmd. I get this error message: 

    New-TemporaryDirectory : The term 'New-TemporaryDirectory' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or 
    if a path was included, verify that the path is correct and try again

    Does anyone know another way in powershell that allows me to create a temporary directory - or knows the error here?

    Thanks. 

    Thursday, May 31, 2018 11:24 PM

All replies

  • That command is not  PowerShell command.  It is part of a third party module that is likely not in your path.  It is also possible that yu have a PS1 with that name accessible to ISE.

    In ISE run this.

    Get-Command New-TemporaryDirectory | select *

    Look at where it is installed.


    \_(ツ)_/

    Thursday, May 31, 2018 11:41 PM
  • Aditional to what @jrv says I think that you're trying to run it from the CMD (bat console).

    you would need to open a Powershell Console to make that work. and check the version using  $PSVersionTable


    • Edited by j0rt3g4 Friday, June 1, 2018 2:34 AM
    Friday, June 1, 2018 2:33 AM
  • Aditional to what @jrv says I think that you're trying to run it from the CMD (bat console).

    you would need to open a Powershell Console to make that work. and check the version using  $PSVersionTable


    Nope.  Not the case.  THe CMD shell cannot produce the error reported: "New-TemporaryDirectory : The term 'New-TemporaryDirectory' is not recognized as the name of a cmdlet, function, script file, or operable program"

    Only PowerShell can report that error in that way.  The CmdLet is clearly not available to the CLI version of PowerShell.


    \_(ツ)_/

    Friday, June 1, 2018 2:40 AM