PRASANNA SARAF February 2016

Powershell Script taking too long

I have a powershell script which involves creating multiple directories and command used to create directory is New-Item -ItemType Directory -Force -Path "abc\WEB-INF\classes\".

Log for creating directory path shows that it took 50 seconds(15:36:42 , 15:37:32) to create 2 directories(WEB-INF,classes).This behaviour is completely abnormal.Is there any other way i can create directories to save time.

2016-02-08 15:36:42 [stdout]PSPath            : Microsoft.PowerShell.Core\FileSystem::C:\abc
2016-02-08 15:36:44 [stdout]                    \WEB-INF\classes\
2016-02-08 15:36:46 [stdout]PSParentPath      : Microsoft.PowerShell.Core\FileSystem::C:\abc
2016-02-08 15:36:49 [stdout]                    ment\WEB-INF
2016-02-08 15:36:51 [stdout]PSChildName       : classes
2016-02-08 15:36:53 [stdout]PSDrive           : C
2016-02-08 15:36:55 [stdout]PSProvider        : Microsoft.PowerShell.Core\FileSystem
2016-02-08 15:36:58 [stdout]PSIsContainer     : True
2016-02-08 15:37:00 [stdout]Name              : classes
2016-02-08 15:37:02 [stdout]Parent            : WEB-INF
2016-02-08 15:37:05 [stdout]Exists            : True
2016-02-08 15:37:07 [stdout]Root              : C:\
2016-02-08 15:37:09 [stdout]FullName          : C:\abc\WEB-INF\classes
2016-02-08 15:37:11 [stdout]Extension         : 
2016-02-08 15:37:14 [stdout]CreationTime      : 08/02/2016 12:59:08
2016-02-08 15:37:16 [stdout]CreationTimeUtc   : 08/02/2016 12:59:08
2016-02-08 15:37:18 [stdout]LastAccessTime    : 08/02/2016 13:00:12
2016-02-08 15:37:21 [stdout]LastAccessTimeUtc : 08/02/2016 13:00:12
2016-02-08 15:37:23 [stdout]LastWriteTime     : 08/02/2016 13:00:12
2016-02-08 15:37:25 [stdout]LastWriteTimeUtc  : 08/02/2016 13:00:12
2016-02-08 15:37:27 [stdout]Attributes        : Directory
2016-02-08 15:37:30 [stdout]BaseName          : classes
2016-02-08 15:37:32 [stdout]Mode              : d-----

Answers


PRASANNA SARAF February 2016

Got the bug . It was not actually the command which was running slow. I was using

Start-Transcript -Path "abc\def\ghi.log" -Force -Append

which doesn't check whether directory (abc\def\ghi) exists . It gives below log but commands run after will be run slowly till Stop-Transcript

Transcript started, output file is abc\def\ghi.log

Post Status

Asked in February 2016
Viewed 2,249 times
Voted 13
Answered 1 times

Search




Leave an answer