Product: PowerShell Universal
Version: 5.1.2
Hello,
it’s me, again.
Currently, we are trying to integrate an assessment script into PowerShell Universal. This script is supposed to assess data from our internal AD and then write it to the PowerShell Universal Cache so that this information can be displayed in an app.
The cache is written in the script with the following command:
Set-PSUCache -Key "Overview_Data" -Value $OutputTable -AbsoluteExpirationFromNow([TimeSpan]::FromHours(1)) -TrustCertificate:$True
The script runs in the context of a user with the appropriate rights. When executed manually, everything works fine. However, when we try to start the script via a schedule, it always results in the following error:
Unauthenticated. Specify an app token, use default credentials, or enable permissive security model.
Our solution approach was to use an app token. If we include this as a string in the script, it also works. However, if we try to store the app token as a PowerShell Universal Secret (Secret String) and then call it in the script with
$Secret:AppToken
we get the aforementioned error again. After some debugging, we found that the secret remains empty when called through automation. This also happens when we run the schedule in the context of the same user (as with the script).
What are we doing wrong?