forked from compwiz32/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path!Scratchpad.ps1
More file actions
48 lines (27 loc) · 1.23 KB
/
!Scratchpad.ps1
File metadata and controls
48 lines (27 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
##Out-File longfilepath.txt ; cmd /c "dir /b /s /a" | ForEach-Object { if ($_.length -gt 250) {$_ | Out-File -append longfilepath.txt}}
cmd /c "dir /b /s /a" | ForEach-Object { if ($_.length -gt 250) {$_ | Write-Host $_.length, $_ }}
cmd /c "dir /b /s /a" | ForEach-Object Write-Host $_.length, $_ }
# $obj = New-Object psobject
Get-ChildItem C:\Scripts -Recurse | ForEach-Object {
$FilePath = $_.FullName
# $obj | Add-Member NotePropertyColumnA $FilePath.Length $obj | Add-Member NotePropertyColumnB $FilePath $obj
Write-Host $FilePath.Length, $FilePath
}
$array = @{}
Get-ChildItem C:\Scripts -Recurse | ForEach-Object {
$Path = $_.FullName
$PathLength = $a.Length
$array.Path = $Path
$array.PathLength = $PathLength
}
$LastCommand = Get-History -Count 1
if ($lastCommand) { $RunTime = ($lastCommand.EndExecutionTime - $lastCommand.StartExecutionTime).TotalSeconds }
if ($RunTime -ge 60) {
$ts = [timespan]::fromseconds($RunTime)
$min, $sec = ($ts.ToString("mm\:ss")).Split(":")
$ElapsedTime = -join ($min, " min ", $sec, " sec")
}
else {
$ElapsedTime = [math]::Round(($RunTime), 2)
$ElapsedTime = -join (($ElapsedTime.ToString()), " sec")
}