This is probably not the case - most likely the profiles are standard Roaming User Profiles delivered from Microsoft’s servers. The problem is the path in edwardscott27’s command:
Remove-Item -Path $env:UserProfile\Downloads\*.* -Recurse -Force
which relies on
$env:UserProfile. This is an environment variable that always points to the current user’s home directory, so this command will only ever apply to the current user as it is written.
If there is access to the user profile storage directory in this WVD environment, then sasaz12’s approach should work. The actual path to the directory could be verified like this:
$env:UserProfile | Split-Path -Parent
(in case the profiles aren’t stored in
However, I’m not familiar with the specifics of WVD. It may be that each WVD session has only the profile of the current user who initiated that session, in which case sasaz12’s script won’t do any good because there’s only one profile in
C:\Users anyway. If this is the case, then kvprasoon’s question is very important:[quote quote=259237]how are you running your script ?[/quote]
To amplify, edwardscott27, when you run this command where are you running it from? Is it from an active WVD session? That session probably only has access to your profile. Do you have administrative access to the server that provides the WVD sessions? If you want to clear files for all users, you’ll need to do it from the server side where the user profiles are actually stored (or from a remote session with admin privileges on that server).
Alternatively, if you are able to set up logoff scripts you can implement the original command in such a script and have it execute whenever one of your users logs out of their WVD session, which should accomplish the goal.
It very much depends on what kind of administrative control you have over the WVD environment for your users.