Search notes:

System.Type - InvokeMember

COM / Excel example

set-strictMode -version latest

$xls = new-object -com excel.application

$xls.Gettype().InvokeMember(
   'Visible',                                      # Name
   [System.Reflection.BindingFlags]::SetProperty,  # Invoke attributes
   $null,                                          # Binder
   $xls,                                           # Target
   @($true),                                       # Arguments
   $null                                           # Culture
)

$wbs = $xls.GetType().InvokeMember(
   'Workbooks',
   [System.Reflection.BindingFlags]::GetProperty,
   $null,
   $xls,
   @(),
   $null
)

$wb = $wbs.GetType().InvokeMember(
   'Add',
   [System.Reflection.BindingFlags]::InvokeMethod, # also seemd to work with GetProperty!
   $null,
   $wbs,
   @(),
   $null
)


#
#    Use named parameters for SaveAs
#

$wb = $wb.GetType().InvokeMember(
   'SaveAs',
   [System.Reflection.BindingFlags]::InvokeMethod,
   $null,
   $wb,
   @(                                              # Values of parameters
      "$env:temp\test.xlsm",
      52  # xlOpenXMLWorkbookMacroEnabled
   ),
   $null,                                          # Modifiers
   $null,                                          # Culture
   [string[]] @(                                   # Names of parameters
      'FileName',
      'FileFormat'
   )
)

$xls.Gettype().InvokeMember(
   'Quit',
   [System.Reflection.BindingFlags]::InvokeMethod,
   $null,
   $xls,
   @(),
   $null
)
Github repository .NET-API, path: /System/Type/InvokeMember/COM-Excel.ps1

See also

System.Reflection.BindingFlags
System.Reflection.DefaultMemberAttribute
System.Type

Links

This stackoverflow answer was very helpful for the COM / Excel example.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Microsof...', 1758200859, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Microsoft/dot-net/namespaces-classes/System/Type/InvokeMember/index(112): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78