As I understand it, if you use it within New-UDDashboard (or New-UDApp), it should also work. However, not as you try it, at least that was my own experience so far (I had similar plans).
For static pages there is another way I just found. There the variables are not directly available. Maybe this also works for what you have in mind? Pure conjecture
Ah… shortly after sending it, it came back to me. I had already tested this for myself:
-Role <String[]>
The role required to view this page.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
But for whatever reason the access check had not worked. Unfortunately, I could not solve this so far with us and had postponed this indefinitely.