-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-FSobjects00.ps1
50 lines (43 loc) · 1.12 KB
/
Get-FSobjects00.ps1
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
44
45
46
47
48
49
50
enum FSItemType {
file
folder
}
class FSobject {
[string]$Id
[string]$Name
[string]$Path
[string]$Source
[FSItemType]$Type
[array]$SubItems
# [array]$SubFolders
[void]FillSubItems(){
$i = 0
While ($i -lt $this.SubItems.Count) {
$j = Get-Item ($this.SubItems[$i] | Resolve-Path -Relative)
$j = $this::new($j)
$this.SubItems[$i] = $j
$i++
}
}
FSObject(){
}
FSObject($obj){
$this.Id = $obj.BaseName
$this.Name = $obj.Name
$this.Path = $obj | Resolve-Path -Relative
If (Test-Path -Path $obj -PathType Container) {
$this.Type = "folder"
$this.Source = $null
$this.SubItems = Get-ChildItem -Path $this.Path
} Else {
$this.Type = "file"
$this.Source = $this.Path -creplace '^[^\\]*\\', ''
$this.SubItems = $null
}
$this.FillSubItems()
}
}
$Location = "C:\Users\Administrator\Desktop\AZK_History\1"
Set-Location $Location
$RootDir = Get-Item $Location
$RootDir = [FSobject]::new($RootDir)