Public/Get-SurveyDefinitions.ps1

<#
    .SYNOPSIS
    Query salesforce for all survey definitions
 
    .DESCRIPTION
    Queries for all the surveys, questions and answers
 
    .INPUTS
    None. You cannot pipe objects to Get-SurveyDefinitions.
 
    .OUTPUTS
    A hash table containing the following keys:
        answers
        surveys
        questions
 
    The 'answers' key contains an array of CustomPSObjects with the following members:
        Id
        phecc__Answer__c
        phecc__Survey_Question__c
 
    The 'surveys' key contains an array of CustomPSObjects with the following members:
        Id
        Name
 
    The 'questions' key contains an array of CustomPSObjects with the following members:
        Id
        phecc__Question__c
        phecc__Survey__c
 
    .EXAMPLE
    PS> $surveyDefs = Get-SurveyDefinitions
 
    .LINK
    Set-FileConfig
 
    .NOTES
    Assumes config is initialized for org access.
#>

function Get-SurveyDefinitions {
    Write-Verbose "Reading Org Survey Metadata"
    @{
        surveys = (invoke-sfquery "SELECT Id,Name FROM phecc__Survey__c WHERE IsDeleted = false AND phecc__Status__c = 'Published'")
        questions = (invoke-sfquery "SELECT Id,phecc__Question__c,phecc__Survey__c FROM phecc__Survey_Question__c")
        answers = (invoke-sfquery "SELECT Id,phecc__Answer__c,phecc__Survey_Question__c FROM phecc__Survey_Answer__c")
    }
}