Create a temporary directory in PowerShell?

前端 未结 8 1728
一生所求
一生所求 2021-02-01 14:36

PowerShell 5 introduces the New-TemporaryFile cmdlet, which is handy. How can I do the same thing but instead of a file create a directory? Is there a New-TemporaryDirec

8条回答
  •  长情又很酷
    2021-02-01 15:06

    I love one liners if possible. @alroc .NET also has [System.Guid]::NewGuid()

    $temp = [System.Guid]::NewGuid();new-item -type directory -Path d:\$temp
    
    Directory: D:\
    
    
    Mode                LastWriteTime     Length Name                                                                                                                        
    ----                -------------     ------ ----                                                                                                                        
    d----          1/2/2016  11:47 AM            9f4ef43a-a72a-4d54-9ba4-87a926906948  
    

提交回复
热议问题