TypeData/PoshRSJob.Types.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<Types>
  <Type>
    <Name>RSJob</Name>
    <Members>
      <ScriptProperty>
        <Name>HasMoreData</Name>
        <GetScriptBlock>            
            $Flags = 'nonpublic','instance','static'
            $_Worker = $This.innerjob.GetType().GetField('worker',$Flags)
            if ($_Worker -eq $null) { $_Worker = $This.innerjob.GetType().GetField('_worker',$Flags) }
            $Worker = $_Worker.GetValue($This.innerjob)

            $_CRP = $worker.GetType().GetProperty('CurrentlyRunningPipeline',$Flags)
            $CRP = $_CRP.GetValue($Worker, $Null)
            $State = If (-NOT $This.handle.IsCompleted -AND -NOT [bool]$CRP) {
                [System.Management.Automation.PSInvocationState]::NotStarted
            }
            Else {
                $This.InnerJob.InvocationStateInfo.State
            }
            If ($PSVersionTable['PSEdition'] -and $PSVersionTable.PSEdition -eq 'Core') {
                $IsReceived =$This.IsReceived
            }
            Else {
                $Field = $This.gettype().GetField('IsReceived',$Flags)
                $IsReceived = $Field.GetValue($This)
            }
            If ($IsReceived) {
                $False
            }
            Else {
                If ($State -eq 'Completed' -AND $This.Handle.IsCompleted -AND (-Not $This.Completed)) {
                    $Output = $This.Innerjob.GetType().GetProperty('OutputBuffer',$Flags)
                    $Results = $Output.GetValue($This.Innerjob)
                    If ($Results.count -gt 0 -AND (-NOT [string]::IsNullOrEmpty($Results))) {
                        $True
                    }
                    Else {
                        $False
                    }
                }
                Else {
                    If ($This.Output -AND (-NOT [string]::IsNullOrEmpty($This.Output))) {
                        $True
                    }
                    Else {
                        $False
                    }
                }
            }
        </GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>RSJob</Name>
    <Members>
      <ScriptProperty>
        <Name>State</Name>
        <GetScriptBlock>
            $Flags = 'nonpublic','instance','static'
            $_Worker = $This.innerjob.GetType().GetField('worker',$Flags)
            if ($_Worker -eq $null) { $_Worker = $This.innerjob.GetType().GetField('_worker',$Flags) }
            $Worker = $_Worker.GetValue($This.innerjob)

            $_CRP = $worker.GetType().GetProperty('CurrentlyRunningPipeline',$Flags)
            $CRP = $_CRP.GetValue($Worker, $Null)
            If (-NOT $This.handle.IsCompleted -AND -NOT [bool]$CRP) {
                [System.Management.Automation.PSInvocationState]::NotStarted
            }
            Else {
                $This.InnerJob.InvocationStateInfo.State
            }
        </GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>RSJob</Name>
    <Members>
      <ScriptProperty>
        <Name>HasErrors</Name>
        <GetScriptBlock>
         If ($psversiontable.psversion.major -ge 3){
            $this.innerjob.HadErrors
         }
         Else {
            ($this.innerjob.Streams.Error.Count -ne 0)
         }
        </GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>RSJob</Name>
    <Members>
      <ScriptProperty>
        <Name>Verbose</Name>
        <GetScriptBlock>
          $this.InnerJob.Streams.Verbose
        </GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>RSJob</Name>
    <Members>
      <ScriptProperty>
        <Name>Debug</Name>
        <GetScriptBlock>
          $this.InnerJob.Streams.Debug
        </GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>RSJob</Name>
    <Members>
      <ScriptProperty>
        <Name>Warning</Name>
        <GetScriptBlock>
          $this.InnerJob.Streams.Warning
        </GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>RSJob</Name>
    <Members>
      <ScriptProperty>
        <Name>Progress</Name>
        <GetScriptBlock>
          $this.InnerJob.Streams.Progress
        </GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>RSRunspacePool</Name>
    <Members>
      <ScriptProperty>
        <Name>AvailableJobs</Name>
        <GetScriptBlock>
          $this.Runspacepool.GetAvailableRunspaces()
        </GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>RSRunspacePool</Name>
    <Members>
      <ScriptProperty>
        <Name>State</Name>
        <GetScriptBlock>
          $this.RunspacePool.RunspacePoolStateInfo.State
        </GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
</Types>