-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCreate.View.ps1
More file actions
38 lines (27 loc) · 1003 Bytes
/
Create.View.ps1
File metadata and controls
38 lines (27 loc) · 1003 Bytes
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
#region Use format manifest
# Create new object using type casting
$obj = [pscustomobject]@{Name='Kurt Roggen'; FirstName='Kurt'; LastName='Roggen'}
Add-Member -InputObject $obj -MemberType AliasProperty -Name FullName -Value Name
Add-Member -InputObject $obj -MemberType ScriptProperty -Name MyFullName -Value { $this.Firstname + ' ' + $this.LastName.ToUpper() }
Add-Member -InputObject $obj -MemberType ScriptProperty -Name IsUNC -Value {$this.Name -match "^\\w*"}
$obj
$obj | gm
# Using PSTypeNames
$obj.PSTypeNames
# Insert your object type new PSTypeName
$obj.PSTypenames.Insert(0,'MyObject')
$obj.PSTypeNames
$obj | gm
# Use format manifest
$File = 'D:\PS\ITPROceed\ITPROceed.format.ps1xml'
# Open format manifest
ise $File
# See the current view of the object
$obj
# Update format data (in memory)
Update-FormatData -AppendPath $File
# See the new view 'Extended' of the object
$obj
$obj | fl -View Extended
$obj | gm
#endregion Use format manifest