Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the empty output of the plugin #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions agent/officepack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,13 @@ Function getOfficeOSPPInfos
$objOffice = @{}
$index = 0
$path = 'C:\Program Files (x86)\Microsoft Office\Office' + $version + '\OSPP.VBS'
If ($osType -eq '64')
{

if (Test-Path $path -PathType Leaf) {
Write-Host "The path $path exist."
}else {
Write-Host "The path $path does not exist."
$path = 'C:\Program Files\Microsoft Office\Office' + $version + '\OSPP.VBS'
}
}
cscript.exe $path /dstatus > $env:USERPROFILE\output.txt
If (Test-Path $env:USERPROFILE\output.txt -PathType Leaf)
{
Expand Down Expand Up @@ -298,11 +301,16 @@ Function schKey
$oOfficeOSPPInfos.Length -gt 0
)
{
$oProd = $oOfficeOSPPInfos[0]['LicenseName']
If ($oOfficeOSPPInfos[0] -ne $null -and $oOfficeOSPPInfos.Length -gt 0) {
$oProd = $oOfficeOSPPInfos[0]['LicenseName']
}
Else{
$oProd = $oOfficeOSPPInfos['LicenseName']
}
}
If ($oProd.Length -eq 0)
{
$oProd = 'Unidentifiable Office' + $oVer
$oProd = 'Unidentifiable Office ' + $oVer
}
If ($oProdID -ine 'No ProductID')
{
Expand All @@ -311,7 +319,7 @@ Function schKey
$oProd = $oProd + ' OEM'
}
}
If ($oProd -match 'Microsoft Office [\s\S]+? ' + $oVer)
If ($oProd -match 'Office' -and $oProd -notmatch ('Unidentifiable Office ' + [regex]::Escape($oVer)))
{
writeXML -oVer $oVer -oProd $oProd -oProdID $oProdID -oBit $osType -oGUID $oGUID -oInstall $oInstall -oKey $oKey -oNote $oNote
}
Expand Down