11 Replies Latest reply on Sep 23, 2020 8:05 AM by SCharchouf

    Create Folder in this format | FolderName date Time

    SCharchouf Enthusiast

      I'm trying to create folder to collect LOGs and output session, as these logs will be used later for archive reference and to trace change.

       

      my issue is that I woulde like the folder to have this foirmat :  folder name 2020/09/23 14:56:00

       

      I got the below error

       

      New-Item : The given path's format is not supported.

      At line:5 char:7

      + else {New-Item -itemType Directory -Path E:\Test_Folder -Name ("LOGS  ...

      +       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

          + CategoryInfo          : NotSpecified: (:) [New-Item], NotSupportedException

          + FullyQualifiedErrorId : System.NotSupportedException,Microsoft.PowerShell.Commands.NewItemCommand

       

      ----------------------------------- Script ---------------------------------

       

      $folderName = Get-Date -Format 'yyyy.MM.dd HH:mm:ss'

       

      $checkdir = Test-Path "E:\Test_Folder\LOGS + $FolderName" -PathType Container

      if ($checkdir -eq "*True*"){}

      else {New-Item -itemType Directory -Path E:\Test_Folder -Name ("LOGS " + $FolderName)}