-Credential \$cred

subash_biswas
Kilo Expert

Can someone please enlighten me on how to pass credentials to a custom PowerShell probe?

It seems like I can create a PowerShell probe and add the above line to pass credentials at run time from the Credentials table.

I looked at the Windows - MSSQL Probe (sqlinfo.ps1) and the skeleton of my PS probe is below.

$job=Start-Job -ScriptBlock {

……

……

} —Credential $cred

Wait-Job $job

Receive-Job $job

Is this all I need to add to pass credentials to my ScriptBlock? Does Discovery iterate through all active Windows credentials to find a match?

Expert guidance appreciated, thanks,

Subash Biswas

1 ACCEPTED SOLUTION

doug_schulze
ServiceNow Employee
ServiceNow Employee

Subash,



You are correct we do go through all credentials till we find a match the first time.   Once we are able to authenticate we set an affinity to the IP and successful credential so the 2nd, 3rd, 10th time we discover the target we know the right one to use.   If at any time it fails again we try others hoping to find a match..



From the Powershell probe:



The Powershell script is provided as the value of a parameter with name ending in ".ps1".   Two variables are available to the script:


$computer - the computer pointed to as the "source" for this probe


$cred - a Powershell credential using a user/password from the Credentials table that successfully logs into $computer.


View solution in original post

4 REPLIES 4

doug_schulze
ServiceNow Employee
ServiceNow Employee

Subash,



You are correct we do go through all credentials till we find a match the first time.   Once we are able to authenticate we set an affinity to the IP and successful credential so the 2nd, 3rd, 10th time we discover the target we know the right one to use.   If at any time it fails again we try others hoping to find a match..



From the Powershell probe:



The Powershell script is provided as the value of a parameter with name ending in ".ps1".   Two variables are available to the script:


$computer - the computer pointed to as the "source" for this probe


$cred - a Powershell credential using a user/password from the Credentials table that successfully logs into $computer.


Thanks Doug!


StephenHey
Mega Guru

Side comment:   If you're using Runbook to execute specific commands to do stuff (NOT discovery), you can specify a 'credential tag' in the work flow activity that will direct you to a specific credential (or list of credentials if you have the same tag specified for multiple credentials).


DanielK_
Giga Contributor