Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add global variables for result object #65

Open
easitanth opened this issue Mar 28, 2024 · 0 comments
Open

Add global variables for result object #65

easitanth opened this issue Mar 28, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@easitanth
Copy link
Collaborator

We should provide a easy way to return a "result object" back to Easit GO when a scripts completes.

A suggestion is to create a PSCustomObject in 'Set-EPREnvironment' and add it as a global variable, for example 'eprResult'.

$eprResult = [PSCustomObject]@{
    eprErrorMessage = $null
    eprReturnMessage = $null
    eprReturnCode = 0
}
New-Variable -Name "eprResult" -Scope 'Global' -Value

Usage:

begin {
    Set-EPREnvironment
}
process {
    try {
        $fileContent = Get-Content -Path "$PSScriptRoot\myfile.txt" -Raw
    } catch {
        $eprResult.eprReturnMessage = "Unable to get content from file"
        $eprResult.eprErrorMessage = $_.Exception
        $eprResult.eprReturnCode= 1
    }
}
end {
    Send-ToEasitGO -Url 'urltoEasitGO' -Apikey 'myApikey' -ImportHandlerIdentifier 'resultFromEPR' -Item $eprResult
}
@easitanth easitanth added the enhancement New feature or request label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant