WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

PowerShell
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get Assemblies from Powershell

 Keywords:  GetAssemblies Get-Member Create AddScript BeginInvoke EndInvoke System.Management.Automation System.Management.Automation.PowerShell AppDomain CurrentDomain

;***************************************************************************
;**    Get Assemblies from Powershell pipeline
;**
;** Purpose:  Get Assemblies from Powershell pipeline
;** Inputs:  outputfile
;** Outputs: Results in a Reportview 
;** Reference: 
;**       REQUIRES WinBatch 2013A or newer 
;**
;** Developer: Stan Littlefield, Deana Falk 2013.05.06
;*************************************************************************** 
If Version( )< '2013A' 
   Pause('Notice', 'Need 2013A or Newer Version of WinBatch')
   Exit 
EndIf

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Load assemblies into the WinBatch process.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; mscorlib assembly is automatically loaded by WinBatch when the CLR is loaded.
; ObjectClrOption ('use','mscorlib, version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
ObjectClrOption('use', 'System.Management.Automation,version=1.0.0.0,publicKeyToken=31bf3856ad364e35,culture=neutral')


;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Associate a Framework based type name with a value.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
oScope = ObjectType("BOOL",-1)

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Create a class implemented by a managed assembly.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
objAutoPs = ObjectClrNew("System.Management.Automation.PowerShell") 

objPowShell = objAutoPs.Create()
Script = '[appdomain]::currentdomain.GetAssemblies() | Get-Member'
objPowShell.AddScript(Script,oScope)
objAsync = objPowShell.BeginInvoke() 
objPsCollection = objPowShell.EndInvoke(objAsync)

rowcount = objPsCollection.Count
aReport = ArrDimension( rowcount, 3 )
ptr = 0
ForEach objItem In objPsCollection
   objCast = objItem.BaseObject()
   aReport[ptr,0] = objCast.Name ; MemberName
   Switch objCast.MemberType ;MemberType 
      Case 2048
         strType = 'Event'
         break
      Case 64
         strType = 'Method'
         break
      Case 4
         strType = 'Property'
         break
      Case default
         strType = objCast.MemberType 
  EndSwitch
   aReport[ptr,1] = strType; objCast.MemberType ;MemberType 
   aReport[ptr,2] = objCast.Definition ;Definition
   ptr = ptr + 1
Next

MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`GetAssemblies`
MyDialogX=002
MyDialogY=059
MyDialogWidth=766
MyDialogHeight=353
MyDialogNumControls=003
MyDialogProcedure=`DEFAULT`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`231,333,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`499,333,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`019,011,706,298,REPORTVIEW,"ReportView_1",aReport,DEFAULT,DEFAULT,30,2097152,DEFAULT,DEFAULT,"192|192|192"`

ButtonPushed=Dialog("MyDialog")
Exit

Article ID:   W17823
Filename:   Get Assemblies from Powershell.txt
File Created: 2013:05:06:14:04:22
Last Updated: 2013:05:06:14:04:22