Powershell 脚本耗时过长
Powershell Script taking too long
我有一个 powershell 脚本,它涉及创建多个目录,用于创建目录的命令是 New-Item -ItemType Directory -Force -Path "abc\WEB-INF\classes\"
。
创建目录路径的日志显示创建 2 个目录(WEB-INF,类)花费了 50 秒(15:36:42,15:37:32)。此行为完全是 abnormal.Is 还有其他方法可以创建目录以节省时间。
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-----
发现错误。 运行ning 慢的实际上不是命令。我正在使用
Start-Transcript -Path "abc\def\ghi.log" -Force -Append
不检查目录 (abc\def\ghi) 是否存在。它给出了下面的日志,但是命令 运行 之后将 运行 慢慢地直到 Stop-Transcript
Transcript started, output file is abc\def\ghi.log
我有一个 powershell 脚本,它涉及创建多个目录,用于创建目录的命令是 New-Item -ItemType Directory -Force -Path "abc\WEB-INF\classes\"
。
创建目录路径的日志显示创建 2 个目录(WEB-INF,类)花费了 50 秒(15:36:42,15:37:32)。此行为完全是 abnormal.Is 还有其他方法可以创建目录以节省时间。
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-----
发现错误。 运行ning 慢的实际上不是命令。我正在使用
Start-Transcript -Path "abc\def\ghi.log" -Force -Append
不检查目录 (abc\def\ghi) 是否存在。它给出了下面的日志,但是命令 运行 之后将 运行 慢慢地直到 Stop-Transcript
Transcript started, output file is abc\def\ghi.log