Hello everyone!
We’re trying to set up our first app. We splitted the project in two parts:
- Scheduled script to collect the data of our activedirectorys and store it into the cache
- Simple App which try to get the data from cache and display it with some funny pie charts
After collecting the data i store it with this line:
$Cache:ADData = $myPreparedHashTable
Later in the app i try to access to it with UDChartJS like this one:
New-UDChartJS @Page:PieOptions -DataProperty "Anzahl" -LabelProperty "UserStatus" -Data $Cache:ADData["contoso.com"].UserState;
$Cache:ADData should be an hashtable with contoso.com as key and some other values in another hashtable stored as value of ADData[“contoso.com”].
I started the debugger to inspect into my cache-variable, but the debugger shows, there is no $Cache:ADData at all.
The script, the schedule-job and the app are all running in a separate environment with persistent runspace called “MyApp_PS7”, using Powershell 7 within system context.
After this i tried to changed my script to use the server-level cache:
Set-PSUCache -Key "Overview2_Data" -Value $ergTable -AbsoluteExpirationFromNow([TimeSpan]::FromHours(1)) -TrustCertificate:$true;
But if i try this, i can run the script manually with success (i can see the cache entry, but it looks weird)
But if i try to store the cache by running the script via scheduled job i run into an error:
Unauthenticated. Specify an app token, use default credentials or enable permissive security model.
I can give the scheduled job some credentials but even then, the same error message.
I’ve read the documentation but didn’t found any further hints what to do to get the job done. I don’t want to get my collect-data-code into my app, because the script may run about several minutes in worst case and i don’t want my users wait for an loading app forever (and if i combine the script code with the app-code, the app-code is terrible to read and understand for my co-workers)
Additionally the “absolute expiration date from now” didn’t changed since i stored the values in Cache. Is there a way to delete cache entries like this somewhere?
Thank you for your time and any help is appreciated!
Greetings, Ronny K