Public/Get-SfDevices.ps1

<#
    .SYNOPSIS
    Queries salesforce for devices.
 
    .DESCRIPTION
    Used to query for devices in the salesforce org. Can query all devices or just devices for one patient.
 
    .INPUTS
    None. You cannot pipe objects to Get-SfDevices.
 
    .OUTPUTS
    An array of PSCustomObject with the properties:
        Id
        phecc__Device_ID__c
        phecc__Device_Master_Id__c
        phecc__Device_Model__c
        phecc__Patient__c
        phecc__Site_Name__c
        phecc__Site__c
 
    .EXAMPLE
    PS> $devicesAssignedToPatients = Get-SfDevices | Where-Object {$_.phecc__Patient__c}
 
    .LINK
    Set-FileConfig
 
    .NOTES
    Assumes config is initialized for org access.
#>

function Get-SfDevices {
    param($Patient)
    if ($Patient) {
        Invoke-SfQuery "SELECT Id,Name,phecc__Device_ID__c,phecc__Device_Master_Id__c,phecc__Device_Model__c,phecc__Patient__c,phecc__Site_Name__c,phecc__Site__c FROM phecc__Device__c WHERE phecc__Patient__c = '$($Patient.sfPatient.Id)'"
    } else {
        Invoke-SfQuery "SELECT Id,Name,phecc__Device_ID__c,phecc__Device_Master_Id__c,phecc__Device_Model__c,phecc__Patient__c,phecc__Site_Name__c,phecc__Site__c FROM phecc__Device__c"
    }
}