Showing posts with label FSLogix. Show all posts
Showing posts with label FSLogix. Show all posts

Friday, February 4, 2022

How to Prune a FSLogix Profile

  

Last year, I put out a Blog on FSLogix's quick Default Exclusions explanation. Here FSLogix Default Exclusions Explanation and Quick Fix (mycugc.org)

 That solution is working very well. But anything that remains in the FSLogix Profile before I reversed the GPO to purge the %Temp% and INetcache doesn't purge from the user's profile. I needed a quick solution to achieve this, and I recall reading about this somewhere, but I couldn't remember. Later that night, I went to bed with it heavy on my mind, and while I was sleeping, Around 3 am or so, I raised out of best remembering reading Aaron Parker FSLogix blogs a couple of years. At this time, I hopped on the computer and did a quick google search. "How to purge Fslogix Profiles." Sure enough, the name "Steal Puppy stuck out." Most often, it's a usual way of life for me. I am always thinking of what I don't know, how I can do whatever I am dealing with, and even how to get to the next level. Sadly, it consumes me mentally, yet I always find a solution from other talented people in Industry. Ok, let's get back on track. Here is the article I was referencing.

A Practical Guide to FSLogix Containers Capacity Planning and Maintenance (stealthpuppy.com)

 

Please understand that I copied the pruned material and put it here to understand what I am talking about in my references. 

 

Prune the Profile

"Not all profile locations are candidates for adding to the redirections.xml and excluding from the Profile Container. Consider history and cookie folders that would negatively impact user experience if they were not maintained across sessions. In this case, we can run regular maintenance on additional folder locations inside the profile to keep the size in check. This approach won't directly reduce the size of the profile per se, but will assist in containing growth."

"I've written a PowerShell script - Remove-ProfileData.ps1, that can prune or delete a set of target files and folders. The script reads an XML file that defines a list of files and folders to remove from the profile."

"Actions on a target path can be:"

  • "Prune - the XML can include a number that defines the age in days for last write that the file must be older than to be deleted"

  • "Delete - the target directory will be deleted. The Delete action will delete the entire folder and sub-folders"

  • "Trim - where the target path contains sub-folders, this action will remove all sub-folders except for the most recent. This approach is implemented to clean up applications such as GoToMeeting that can store multiple versions in the profile"

"The script supports -WhatIf and -Verbose output and returns a list of files removed from the profile. Add -Verbose will output the total size of files removed from the user profile and processing time at the end of the script. All targets (files / folders) that are deleted, will be logged to a file. Deleting files from the profile can result in data loss, so testing is advised and the use of -Confirm:$false is required for the script perform a delete. To prune the profile, run the script as a logoff action."

"A word of caution - this script is unsupported. If you would like to help improve the script, pull requests are welcome."

 

 

In my testing, I needed to prune a section of the profile. I have an application that uses IE (Soon Chrome Edge), but I need to get all this trash out for now. It seems IE is cache-heavy for the Web-based application. But the IE cache isn't just for IE. Other trash goes into here, and if I prune it, the area is empty.

As you can see below,  the INetcache folder is dumping it to the local_username. But it's not getting the old stuff because the GPO was updated and put in after I realized it wasn't working in my previous blog. Anything before the GPO was updated does not purge the data.

 

As you can see here in my example, the username_local is moving it to the scratch area. But notice the date on the folders. It moving new stuff only!

\\VDI\c$\Users\local_Test01\INetCache

Graphical user interface, application

Description automatically generated

 

Perhaps this may still be a factor for the IE app because it shares the INetcache. But look at the actual location of what isn't redirected. You can see that the old stuff is still lingering around. This means that IE is looking at the INetCache for the overall "Cache storage."  Some Web applications like the one I have in this environment, once the overall Cache Storage location is used up. Well, the application becomes extremely slow.

\\VDI\c$\Users\Test01\AppData\Local\Microsoft\Windows\INetCache

Table

Description automatically generated with medium confidence

 

To ensure this location is purged, we can schedule the "Remote-Profile.ps1 script to run and take care of this. The script needs a Target file. The Target file is called with the parameters to understand what needs to remove from the FSLogix profile.

A reminder of how it works

"a PowerShell script - Remove-ProfileData.ps1, that can prune or delete a set of target files and folders. The script reads an XML file that defines a list of files and folders to remove from the profile."

Text

Description automatically generated

 

 

Before

The screenshot shows the old data.

Table

Description automatically generated with medium confidence

 

 

After

I remoted to a VDI machine, and then I executed the script.

C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -File "\\Domain\NETLOGON\CitrixScripts\WemExternalTask\ProfilePrune\Remove-ProfileData2.ps1" -Targets "\\Domain\NETLOGON\CitrixScripts\WemExternalTask\ProfilePrune\targets.xml" -LogPath \\Domain\NETLOGON\CitrixScripts\WemExternalTask\ProfilePrune\logs -verbose

Location of InetCache throug UNC

\\VDI69\c$\Users\Test01\AppData\Local\Microsoft\Windows\INetCache

 

It looks like this has done the job for me, and there are many ways to implement this. I don't advise you to do it at logon, though, as it would impact the logon performance. You can do a Logoff script, scheduled task, or use a UEM tool

 

Graphical user interface, application

Description automatically generated



I am a big WEM fan myself. I don't use anything else at the moment. That alone is a whole other topic 😊 


Open the WEM Admin Console>External Task

Graphical user interface, application, Word

Description automatically generated


Click Add at the bottom, and fill in the data to the script location.


It is calling Powershell then the argument is to the location where the meat and potatoes reside


Argument

-Executionpolicy bypass -File "\\ sillyrabbit.org\\NETLOGON\CitrixScripts\WemExternalTask\ProfilePrune\Remove-ProfileData2.ps1" -Targets "\\sillyrabbit.org\NETLOGON\CitrixScripts\WemExternalTask\ProfilePrune\targets.xml" -LogPath \\ sillyrabbit.org\\NETLOGON\CitrixScripts\WemExternalTask\ProfilePrune\logs -verbose

Graphical user interface, application

Description automatically generated


Now, Click Assignments>add to the desired assignment.

Graphical user interface, text, application, Word

Description automatically generated

Select what Filter you have. I keep it elementary most times and do "Always True."

Graphical user interface, text, application, email

Description automatically generated

Graphical user interface, application

Description automatically generated


Now it's ready to go. Of course, you can refresh the WEM agent and force it. 


Thursday, September 23, 2021

FSLogix Default Exclusions explanation and quick Fix

 FSLogix Default Exclusions explanation and quick Fix


As you know, FSLogix does have profile exclusions, and more importantly, they have 2 significant FSLogix profile exclusions built-in. But in this quick little blog, I will focus on a  little FSLogix Gotcha, but not really. It's More of an MS GPO that many of us have set for specific scenarios that we needed in older Profile cases. Well, with FSLogix, it will backfire. In my case, if IE will slow down and get tons of calls (Yes, I know IE stinks, and it's moving from soon 😊), This blog post is not about putting in extra exclusions, and it's not about if you should or shouldn't. 

I noticed that my INetcahce was not being cleared when I users logged out, and it was causing the issue for some legacy applications that require IE in my use case. I research the default FSLogix Exclusion, and the MS article states this



Profile Container content - FSLogix | Microsoft Docs

How to resolve the FsLogix INetCache access denied issue (stefanos.cloud)


At first, I was like, ok, cool, but it's not working. When the users log into any VDI/RDSH or where FSLogix is applied, you will see that the Local_Username will have its exclusions. You should see the folder here for any exclusions you add. However, not that FSLOGIX wasn't designed for many exclusions. I still do it today, but with caution, and I don't go nuts.  If you want to learn more about this, you can read this Microsoft link. As I stated above, it's not about adding more to the default list.

Profile Container content - FSLogix | Microsoft Docs



Here is an Example of Teams and those cases where I think you should

https://techcommunity.microsoft.com/t5/azure-virtual-desktop/wvd-fslogix-reduce-profile-container-size-exclude-teams-cache/td-p/1503683



Back on track now.

But for some reason, its not doing this. But why? So, I reached out to my fellow Slack buddies and got some good advice.


Kasper Johansen educated me that if I have the GPO set then it will not do what its designed to do. Extra information from and on this as well, which helped me. He also mentioned it would list it in the event log. Which it did 😊


Nick Panaccio,  posted You must assign the "Prohibit User from manually redirecting Profile Folders" registry action to all users, which sets "DisablePersonalDirChange"
 to 0 at logon
 -If you do not apply this setting, WEM sets the value to 1, and FSLogix will fail to redirect INetCache successfully


Dennis Mohrmann also updated on if WEM folder redirection is on it will affect this.



So, after going through my environment, I found this, and this GPO will not allow INetCache.  In my case, to be deleted correctly. Or, in better words, move it to the local_Username. This means the cache will not get disregarded on logoff, and then you have to come behind it and put in extra GPO as I did because I did not know this.



The GPO to avoid while using FSLogix

"Prohibit User from manually redirecting Profile Folders"


After you have this set, you will see in this location that the key exists.

Inside the HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer

You will see DisablePersonalDirChange set to value = 1.

 

Now you can set the policy to not configured, but it will not change the registry value back as it tattoos the registry for the user hive. Now its clear you can come back around and set this with Citrix WEM or any UEM tool, or simply set the GPO to disabled. Which will remove the entry altogether and reverse it to the way it should have been.

As you can see here, it will log into the Event logs as not Working 

You will also notice that it will create the TEM and INetcache folder in the Local_username, but it will not move the contents either.

You will see the Cache and Temp folder in the normal profile paths. Such as c:\users\%username\Appdata\Local\Miscrosoft\Windows\Inetcache for example. 

After setting this to disabled

You will see that it's working now.



I understand this is very basic. However, for me, it was a big deal in my environment, and anything that was in the INetCache now will be disregarded, and it will fix an issue that I am having with Slow IE browsing after about 5 hours for my web applications.

I understand many of you are using more modern browsers, but in some environments, things are behind, and IE is still the go-to for some things. I hope you find this helpful as I did.