I am new to using the API for bigfix and was hoping someone can provide me with an example of how to trigger a baseline using powershell. I want to create a baseline for a group in our office and allow them to kick it off remotely and not sure how to do this using the API. Also would like them to use the API to create computer groups. Any help with this would be great appreciated and if it can be done using powershell even better.
Hi @rkurowski
This is perfectly possible.
First of all, here you have some good help:
For Powershell, I use the invoke-restcommand to trigger my GET/POST:
function client-refresh {
param(
$cred
)
$PostUrl = 'https://x.x.be:52311/api/actions'
$body = @"
<?xml version="1.0" encoding="UTF-8"?>
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
<SourcedFixletAction>
<SourceFixlet>
<Sitename>ActionSite</Sitename>
<FixletID>2907</FixletID>
<Action>Action1</Action>
</SourceFixlet>
<Target>
<ComputerID>9383551</ComputerID>
</Target>
<Settings>
<HasEndTime>false</HasEndTime>
</Settings>
</SourcedFixletAction>
</BES>
"@
try{
Invoke-RestMethod -Uri $PostUrl -Method Post -Credential $cred -Body $body
[void][System.Windows.Forms.MessageBox]::Show("Client Refresh Action successfully created" , "Force Client Refresh")
}catch{
[void][System.Windows.Forms.MessageBox]::Show("Client Refresh Action failed" , "Force Client Refresh")
}
}
I have extra logging/forms enabled etc, but you can filter that out. You can give your fixletID with it (baseline or task, doesn’t matter), the computerID and between the tags “settings” you can give extra settings (like offer, message, reboot,…). Just make an action with the desired settings,export it, look at the xml and copy the settings.
The same you can use for creating a group.
1 tip: Put the following code on top of your script, or you’ll get SSL errors:
dd-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
Hope this helps.
1 Like