Solved

Logoff Script To Wipe Cache Data Not Working In Citrix PvD

Posted on 2016-10-19
8
58 Views
Last Modified: 2016-11-01
We have a XenDesktop 7.5 environment that uses PvD and UPM.

We are trying to conserve space on each person's PvD so we don't have to manually reset it as often. Currently, the PvDs are getting full too often. Our current attempt is to wipe Google Earth cache data on logoff since that uses up quite a bit of space.

Here is our current script:
@echo off
if %os%==Windows_NT goto WINNT
goto NOCON

:WINNT
echo .Using a Windows NT based system
echo ..%computername%

echo Delete Google Earth Cache
del /q /f /s "%USERPROFILE%\AppData\LocalLow\Google\GoogleEarth\webdata
del /q /f /s "%USERPROFILE%\AppData\LocalLow\Google\GoogleEarth\unified_cache_leveldb_leveldb2
echo deleted!

goto END

:NOCON
echo Error...Invalid Operating System...
echo Error...No actions were made...
goto END

:END

Open in new window


The GPO is working, but we aren't seeing the cached data getting wiped, and I think I know why.
When going to the PvD of my test VM, I can see that Citrix is setting two profiles for the user.
PvD makes two profiles for the user
My understanding is that since the LocalLow folder (where Google Earth cache is stored) isn't handled by UPM, that the LocalLow will stay with the PvD on the local machine.

I think the script is looking in the "testuser.domain" folder and not in the "testuser" folder since the %USERPROFILE% that is logged in the "testuser.domain" account.

How can I get the script to wipe the webdata and unified_cache_leveldb_leveldb2 folders?
0
Comment
Question by:Paul Wagner
  • 3
  • 3
  • 2
8 Comments
 
LVL 53

Expert Comment

by:McKnife
ID: 41851587
Why don't you run it manually, for a start? For example, you could use Chrome's "open file" menu to navigate to cmd.exe, and start a cmd where you can examine, what the deletion commands do/don't do.
Press CTRL-O in chrome, navigate to C:\Windows\System32\cmd.exe, right click it and select "open". Now launch your commands.

Also, make sure that your script runs at all by adding a line
md %userprofile%\test
to set a marker.

And close those " at the end of your del-commands (although it does not matter, here, since there are no blanks).
0
 
LVL 4

Author Comment

by:Paul Wagner
ID: 41852524
What's the difference in launching a cmd from the start menu vs. doing it in chrome? Just a different way of accessing the cmd?

Now launch your commands.
I assume you mean to launch them in the .bat file.
I launched it and it said the system could not find the path specified.

The test folder was created in the "testuser.domain" folder. It looks like the "testuser" folder is only there to store LocalLow information.

Oh! I didn't catch the quotes. Thanks for mentioning that.
0
 
LVL 53

Assisted Solution

by:McKnife
McKnife earned 100 total points
ID: 41852673
The difference: I thought, you would not even have a full session in front of you so that was the only way to access cmd - I was wrong, obviously. You know, some remote desktop solutions don't offer full sessions.

About your problem: I guess it is something easy: your user has 2 profiles, an old one and a current one. The current one is c:\users\testuser.domain. And in that folder, there is no such path that you are trying to delete files in. Or is there a folder c:\users\testuser.domain\AppData\LocalLow\Google\GoogleEarth\webdata ?

What you might not know: when we try to delete test user by removing his user object in local account management, his profile folder is not removed. So when we reinstate that username a 2nd time, the new profile folder won't be the same (c:\username), but instead c:\username.domain - I guess that is what has happened here. You have a new profile, the new profile has no google earth data yet - nothing to delete. You are looking at the wrong profile folder.
0
 
LVL 16

Accepted Solution

by:
Spike99 earned 400 total points
ID: 41852971
The variable %userprofile% generally points to the User's profile folder on the C: drive (%userprofile% points to C:\users\%USERNAME%, usually).

If you log on as that user & type "%userprofile% in Window explorer, does it take you to the C: drive location or to the PvD location?

If that takes you anywhere else other than the network location for the PvD in question, I would change the script to use the user name variable (%USERNAME%) instead of the user profile variable (%USERPROFILE%).

So, assuming the server location for the user's PvD is \\FILESERVER\PvD$\%username%, try changing those lines to this:
del /q /f /s \\FILESERVER\PvD$\%USERNAME%\AppData\LocalLow\Google\GoogleEarth\webdata
del /q /f /s \\FILESERVER\PvD$\%USERNAME%\AppData\LocalLow\Google\GoogleEarth\unified_cache_leveldb_le

del /q /f /s \\FILESERVER\PvD$\%USERNAME%.DOMAIN\AppData\LocalLow\Google\GoogleEarth\webdata
del /q /f /s \\FILESERVER\PvD$\%USERNAME%.DOMAIN\AppData\LocalLow\Google\GoogleEarth\unified_cache_leveldb_le

Open in new window

0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 4

Author Comment

by:Paul Wagner
ID: 41861427
@McKnife
your user has 2 profiles, an old one and a current one.
Not quite. The "testuser" folder only has the LocalLow folder and the "testuser.domain" folder has Local and Roaming. This is the case regardless of how many times I logon/logoff or delete the folders. After talking to a UPM engineer, I realize this behavior is because LocalLow is not handled by UPM, so it makes another folder.


@Spike99
If you log on as that user & type "%userprofile% in Window explorer, does it take you to the C: drive location or to the PvD location?
Going to %userprofile% will take me to the list of folders for the user (desktop, downloads, etc.) but they are all redirects linked to a file server.
With that said, going to "%userprofile%\appdata" will take me to the PvD.

I love the idea to your script, but there's a problem. The PvD isn't stored on a "\\FILESERVER". It is stored with the VM itself, so I used %computername%?

So, it would look this?:
del /q /f /s "\\%computername%\p$\Users\%USERNAME%\AppData\LocalLow\Google\GoogleEarth\webdata"

There's a problem with "%USERNAME%.DOMAIN". I can't navigate to it in explorer.
I found that to get to the testuser.domain profile, I actually need to use %USERPROFILE%.
... BUT, that doesn't really matter because LocalLow and Google Earth cache isn't stored in "testuser.domain", so we don't even need those entries. I made a modified entry for it in case it ever weirdly decided to show up there.

So, with all of that said, here's what I have:
@echo off
if %os%==Windows_NT goto WINNT
goto NOCON

:WINNT
echo .Using a Windows NT based system
echo ..%computername%

echo Delete Google Earth Cache
del /q /f /s "\\%computername%\p$\Users\%USERNAME%\AppData\LocalLow\Google\GoogleEarth\webdata"
del /q /f /s "\\%computername%\p$\Users\%USERNAME%\AppData\LocalLow\Google\GoogleEarth\unified_cache_leveldb_leveldb2"
del /q /f /s "\\%computername%\p$\Users\%USERPROFILE%\AppData\LocalLow\Google"
echo deleted!

goto END

:NOCON
echo Error...Invalid Operating System...
echo Error...No actions were made...
goto END

:END

Open in new window

0
 
LVL 53

Expert Comment

by:McKnife
ID: 41861734
Whatever you say. But if there is a folder
%USERPROFILE%\AppData\LocalLow\Google\GoogleEarth\webdata present, then a del command would work. The script does not work any different to just logging on as user and open a command shell and execute the del commands manually. If those fail (path not found), then there is no doubt: this user does not have that folder.
0
 
LVL 16

Expert Comment

by:Spike99
ID: 41862523
Did that revised script work as you would like it to?
0
 
LVL 4

Author Closing Comment

by:Paul Wagner
ID: 41869254
Yes, the script is working, but I think the issue is that LocalLow is not redirected via UPM with Local and Roaming. Because of this fact, I believe the parameters are not ideal: the profile is splintered.

I am going to keep this script and find a way to redirect LocalLow into UPM so that the entire profile is in one folder. If that happens, I can then worry about one folder instead of two.

Thank you both for your help.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now