
Interfax CloudOps (Upland Software) asked a question.
I'm running a PS script and get an error I can't explain. Please assist me to realize what is wrong.
Thank you.
The error is:
Starting 1 blank original '1 blank original'
The result is Method invocation failed because [NmPowerShell.ScriptContext] does not contain a method named 'LogMessage'.:
FAILED
the script is:
function ComposeQuery {
$Result = "SELECT count(*) FROM doc_autoshare WHERE EntityType ='group' AND entityid =''"
$Result
}
function CheckDelayed {
param (
[ref]$Status, [ref]$Description
)
$DSN = "IF_WUG_Mirror"
$strQuery = $null
$objConn = $null
$objRS = $null
$intCount = $null
##On Error Resume next
##Create connection and recordset objects
$Comp_Path = Get-ItemPropertyValue -Path HKLM:\Software\ODBC\ODBC.INI 'WUG_PS_COMPONENTS_PATH'
$temp = $Comp_Path + "\ConnectionWrapper.dll"
$AccType1= Add-Type -Path $temp -PassThru
$objConn = New-Object IFConnectionWrapper.ConnectionWrapper
$temp = $Comp_Path + "\RecordSetWrapper.dll"
$AccType0 = Add-Type -Path $temp -PassThru
$objRS = New-Object RecordSetWrapper.RsWrapper
##Open and connect to the database
$objConn.Open($DSN)
##SND query
$strQuery = ComposeQuery
$objRS.Open($strQuery, $objConn)
$intCount = [long] $objRS.Fields(0).Value
if($intCount -gt 0) {
$Status.Value = 1
$Description.Value = "Found $intCount blank entityid in autoshare group'"
$objRS.Close()
$objRS = $null
$objConn = $null
return
}
##
## If got till here - OK
##
$Status.Value = 0
$Description.Value = "OK"
$objRS = $null
$objConn = $null
}
##'Active Script Monitor CS - blank entityid in autoshare group "'
## WUG Script for count transactions stuck in reportedoutboundfax table in state ForCharge'
##
$S = $null
$D = $null
<#
$Comp_Path = Get-ItemPropertyValue -Path HKLM:\Software\ODBC\ODBC.INI 'WUG_PS_COMPONENTS_PATH'
$temp = $Comp_Path + "\RecordSetWrapper.dll"
$AccType3 = Add-Type -Path $temp -PassThru
$Context = New-Object RecordSetWrapper.WUG_Context
#>
$Context.LogMessage( "Checking blank entityid in autoshare group")
CheckDelayed -Status ([ref] $S) -Description ([ref] $D)
$Context.SetResult($S, $D)
You are using "$Context.LogMessage( "Checking blank entityid in autoshare group")" which the $Context.LogMessage is not used in the WhatsUp Gold PowerShell name space. You can use Write-Host to output to the debug window when you test it. If you want a log, you will have to write a function to have PowerShell output to a file.