Windows Virtual Desktop (Windows 10 Multi-Session) PS Script

Welcome Forums General PowerShell Q&A Windows Virtual Desktop (Windows 10 Multi-Session) PS Script

Viewing 3 reply threads
  • Author
    Posts
    • #258734
      Participant
      Topics: 1
      Replies: 0
      Points: 14
      Rank: Member

      I am trying to clear out everyone’s download folder that logs into our WVD which we have set 15 users. I run this PS script but it only clears the download folder for who is logged in. Remove-Item -Path $env:UserProfile\Downloads\*.* -Recurse -ForceĀ  I am sure it just needs tweaking but I can’t seem to figure it out. Any help would be great thanks!

       

      Also new to PS

    • #259801
      Participant
      Topics: 7
      Replies: 137
      Points: 668
      Helping Hand
      Rank: Major Contributor

      I thought about the same solution as you, but not having familiarity with profiles in a VDI MultiSession environment, this threw me off somewhat:

      “I run this PS script but it only clears the download folder for who is logged in”

      This implied to me that maybe the profiles are not similar, like they are virtual and generated only when a user is logged in??

    • #259843
      Senior Moderator
      Topics: 10
      Replies: 184
      Points: 980
      Helping Hand
      Rank: Major Contributor

      This implied to me that maybe the profiles are not similar, like they are virtual and generated only when a user is logged in??

      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:

      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:

      (in case the profiles aren’t stored in C:\Users)

      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:

      how are you running your script ?

      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.

    • #259855
      Participant
      Topics: 7
      Replies: 137
      Points: 668
      Helping Hand
      Rank: Major Contributor

      Thanks for the info grokkit.

      I wrote a script a while back to sync roaming profiles … I wonder if any of this would work/help?

      Not sure how to get rid of the html chars, it should be ‘Win32_UserProfile’

      • This reply was modified 3 weeks, 6 days ago by grokkit. Reason: code formatting - please read the guide
Viewing 3 reply threads
  • You must be logged in to reply to this topic.