-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.ps1xml
114 lines (114 loc) · 3.72 KB
/
sample.ps1xml
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?xml version="1.0" encoding="UTF-8"?>
<Types>
<Type>
<Name>System.Byte[]</Name>
<Members>
<ScriptProperty>
<Name>Hex</Name>
<GetScriptBlock>
$this | % {write-host $([String]::Format("{0:X}",$_)) -nonew}
</GetScriptBlock>
</ScriptProperty>
</Members>
</Type>
<Type>
<Name>System.IO.FileInfo</Name>
<Members>
<ScriptMethod>
<Name>GetHash</Name>
<Script>
param([ValidateSet("SHA1","SHA256","SHA384","SHA512","MD5")]$Algorithm="SHA256")
Get-FileHash $this.FullName $Algorithm
</Script>
</ScriptMethod>
<ScriptProperty>
<Name>Sha256</Name>
<GetScriptBlock>
$this.GetHash()
</GetScriptBlock>
</ScriptProperty>
<ScriptProperty>
<Name>MD5</Name>
<GetScriptBlock>
$this.GetHash("MD5")
</GetScriptBlock>
</ScriptProperty>
</Members>
</Type>
<Type>
<Name>System.Management.Automation.CommandInfo</Name>
<Members>
<ScriptProperty>
<Name>Syntax</Name>
<GetScriptBlock>($this | Get-Command -Syntax | Out-String).Trim()</GetScriptBlock>
</ScriptProperty>
<ScriptProperty>
<Name>Synopsis</Name>
<GetScriptBlock>($this | Get-Help).Synopsis.Trim()</GetScriptBlock>
</ScriptProperty>
</Members>
</Type>
<Type>
<Name>Microsoft.PowerShell.Commands.MemberDefinition</Name>
<Members>
<ScriptProperty>
<Name>HelpLink</Name>
<GetScriptBlock>"http://msdn2.microsoft.com/library/$($this.typename).$($this.name).aspx"</GetScriptBlock>
</ScriptProperty>
<ScriptMethod>
<Name>OpenHelpLink</Name>
<Script>
Start-Process $this.HelpLink
</Script>
</ScriptMethod>
</Members>
</Type>
<Type>
<Name>System.String</Name>
<Members>
<ScriptMethod>
<Name>ToBase64</Name>
<Script>
[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($this))
</Script>
</ScriptMethod>
<ScriptMethod>
<Name>FromBase64</Name>
<Script>
[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($this))
</Script>
</ScriptMethod>
</Members>
</Type>
<Type>
<Name>System.Security.SecureString</Name>
<Members>
<ScriptMethod>
<Name>ToPlainText</Name>
<Script>
$plaintext = ""
try {
$BSTR = [System.Runtime.InteropServices.marshal]::SecureStringToBSTR($this);
$plaintext = [System.Runtime.InteropServices.marshal]::PtrToStringAuto($BSTR);
} finally {
if($BSTR -ne [IntPtr]::Zero) {
[System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($BSTR);
}
}
Write-Output $plaintext
</Script>
</ScriptMethod>
</Members>
</Type>
<Type>
<Name>Microsoft.PowerShell.Commands.HistoryInfo</Name>
<Members>
<ScriptProperty>
<Name>Duration</Name>
<GetScriptBlock>
$this.EndExecutionTime - $this.StartExecutionTime
</GetScriptBlock>
</ScriptProperty>
</Members>
</Type>
</Types>