Skip to main content

Use PowerShell to control File Share Cache

This is a way to control the File Share Cache mode via PowerShell.  Notice, that we are actually still using DOS.  I went his route because to get this to work on a Server, you would have to install the Desktop Experience in order to gain access to the Offline Files API.  I still had some difficulty with the Class Libraries  and decided to go this route.

The one difference in each line is the final command: Programs, Manual, Documents, and None.

 

# Sets the Cache to:
# All Files and Programs that users open from the shared folder are automatically available offline.
# Also, Optimized for performance is checked.

([WMIClass]"\\lon-dc1\root\cimv2:win32_Process").Create("cmd /C net share PS /Cache:Programs")


# Sets the Cache to:
# Only the files and programs that users specify are available offline.

([WMIClass]"\\lon-dc1\root\cimv2:win32_Process").Create("cmd /C net share PS /Cache:Manual")


# Sets the Cache to:
# All Files and Programs that users open from the shared folder are automatically available offline.
# Optimized for performance is not checked.

([WMIClass]"\\lon-dc1\root\cimv2:win32_Process").Create("cmd /C net share PS /Cache:Documents")

# Sets the Cache to:
# No files or programs from the shared folder are available offline.

([WMIClass]"\\lon-dc1\root\cimv2:win32_Process").Create("cmd /C net share PS /Cache:None"
)

Comments