This PowerShell module provides the ability to stow away an item, and to then unstow that item. By "stowing", we mean moving the item away for safekeeping, and then to unstow means to restore it to its original location.
In some networked environments, there is a size limit on your USERPROFILE directory. You can keep its size down by stowing directories before you log off and then unstow these directories after you log in.
You will need PowerShellGet. It is included in Windows 10 and WMF5. If you are using PowerShell V3 or V4, you will need to install PowerShellGet.
After installing PowerShellGet, you can simply run
Install-Module PSStow -Scope CurrentUserYou can download the PSStow folder from this repository and copy it to one of your modules directory, using this Microsoft guide to Installing a PowerShell Module.
Both Stow-Item and Unstow-Item return a pscustomobject with the properties:
Success- can be eithertrueorfalsedepending on if it succeeded, ornullif it can't be classified as either.Item- the path of the item being stowed or unstowed.Store- the (root) path of the store containing the stowed/unstowed item.Message- a message to help with diagnosing any issues that arise.
To stow a directory C:\Users\<username>\.android into a store C:\_store, use the Stow-Item function:
Stow-Item -Path "$env:USERPROFILE\.android" -Store C:\_storeTo unstow the stowed directory, you call Unstow-Item passing in the same arguments as you did to Stow-Item:
Unstow-Item -Path "$env:USERPROFILE\.android" -Store C:\_storeTypically there are a set of offending User Profile directories that are too large to be sent over the network as part of a roaming profile. You can define two functions to deal with this situation:
stowUserProfileDirs- this will move massive directories out ofUSERPROFILEintoC:\_store.unstowUserProfileDirs- this will move the massive directories back for use.
$global:stowStore = "C:\_store";
$global:userProfileDirsToStow = @(
"$env:LOCALAPPDATA\Google\Chrome\" # Chrome dir settings
, "$env:LOCALAPPDATA\Microsoft\VisualStudio\" # Visual Studio settings (different versions)
, "$env:USERPROFILE\.nuget\" # nuget cache
, "$env:USERPROFILE\.android\" # visual studio's android files
, "$env:LOCALAPPDATA\Microsoft\SQL Server Management Studio\" # SSMS settings (different versions)
, "$env:LOCALAPPDATA\atom" # atom program dir
, "$env:USERPROFILE\.atom\" # atom settings dir
, "$env:LOCALAPPDATA\ApexSQL" # ApexSQL settings dir
);
Function stowUserProfileDirs {
$global:userProfileDirsToStow | Stow-Item -Store $global:stowStore
}
Function unstowUserProfileDirs {
$global:userProfileDirsToStow | Unstow-Item -Store $global:stowStore
}You would put the above in your PowerShell profile, and when you log on you call stowUserProfileDirs and before you log off, you call unstowUserProfileDirs.
The alternative is to have stowUserProfileDirs to be called automatically on log on, and unstowUserProfileDirs called automatically before log off, which can be done using Group Policy Editor.
This project is under the MIT licence.