We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

JEA v2 based discovery return error during WMIFetch $computer variable is empty

OlegKrylov
Kilo Explorer

Trying to implement JEAv2 discovery, and always getting the same error in the agent log on the MID server
After running  this part

execute(& { fetchMultipleWMI -wmi "false"  -output_format "json"  -WMI_FetchData "root\virtualization\v2\Msvm_ComputerSystem.Name,HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/Domain,HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/Hostname,root\MSCluster\MSCluster_Resource.PrivateProperties,root\MSCluster\MSCluster_Resource.Name,root\MSCluster\MSCluster_Node.Name,root\MSCluster\MSCluster_Cluster.Name,root\MSCluster\MSCluster_ClusterToResource.GroupComponent,root\MSCluster\MSCluster_ClusterToResource.PartComponent,root\MSCluster\MSCluster_ClusterToNode.Antecedent,root\MSCluster\MSCluster_ClusterToNode.Dependent,root\virtualization\Msvm_ComputerSystem.Name,root\MSCluster\MSCluster_Resource.Type,Win32_ComputerSystem.Domain,Win32_ComputerSystem.Name,Win32_OperatingSystem.Caption,Win32_OperatingSystem.Version" ; } | Out-String | ForEach-Object { [Console]::WriteLine($_) })

 Getting this:

 -----START OF STDERR-----
 -----START OF STDOUT-----
<SNC_LOG>2026-02-26 15:34:32 Running CreateNewPSSession without explicit credential</SNC_LOG>
<SNC_LOG>2026-02-26 15:34:32 Running create session script: New-PSSession -ComputerName  -Port 5986 -UseSSL -Authentication NegotiateWithImplicitCredential</SNC_LOG>
New-PSSession : Missing an argument for parameter 'ComputerName'. Specify a parameter of type 'System.String[]' and try again.
At line:1 char:15
+ New-PSSession -ComputerName  -Port 5986 -UseSSL -Authentication Negot ...
+               ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [New-PSSession], ParameterBindingException
   + FullyQualifiedErrorId : MissingArgument,Microsoft.PowerShell.Commands.NewPSSessionCommand
 
 executeRemote : Failed to create remote Powershell Session
 At C:\Servicenow\ServiceNow MID Server MIDServerName\agent\scripts\PowerShell\WMIFetch.psm1:1122 char:16

 + ...      $rtn = executeRemote -computer "$computer" -scriptBlock "$script ...
 +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,executeRemote
  
 {
 }

 
 -----END OF STDERR-----
 -----END OF STDOUT-----

But earlier in the same session I could see how $computer variable was assigned by target server FQDN (I don't have IP address in the WinRM Trusted Hosts).
Looks like $computer variable was cleared somehow... How I could understand why? 

Thanks a lot in advance!

0 REPLIES 0