Offline Folders - Deep Divers
Good Morning,
The last few Weeks i had to analyze some Offline Folder Issues.
Sometimes we had to guess about some behavior scenarios.
As i checked the Win32_OfflineFilesItem in WMI to get some further Information about the Cached Items. So according to
msdn there are many attributes for every item, and I did a small powershell to make a csv line for every cached item.
As no one except the interactive User can see the items, it is necessary to run the Script as User with Offline Folder Problems.
May someone has similar Scripts to Offline Folders ?
# OfflineFileBrowser Extrahiert alle Offline Files und zeigt die Attribute an
# muss als interaktiver User ausgefhrt werden - welcher die OfflineFiles besitzt / not working Remote !
# (p) by steini'12
# Importend Values Offline Reason,Pinned,ConnectState
# Hole alle Offline Files
$q = Get-WmiObject -query "SELECT * FROM Win32_OfflineFilesItem"
Function resConnectState ($val)
{
Switch ($val){
0 {"STATE_UNKNOWN"}
1 {"STATE_OFFLINE"}
2 {"STATE_ONLINE"}
3 {"TRANSPARENTLY_CACHED"}
4 {"PARTLY_TRANSPARENTLY_CACHED"}
default {"res Error:$val"}
}
}
Function resOfflineReason($val)
{
switch($val){
0 {"UNKNOWN"}
1 {"NOT_APPLICABLE"}
2 {"CONNECTION_FORCED"}
3 {"CONNECTION_SLOW"}
4 {"CONNECTION_ERROR"}
5 {"ITEM_VERSION_CONFLICT"}
6 {"ITEM_SUSPENDED"}
default {"res Error:$val"}
}
}
Function resPinInfo($val)
{
switch($val){
0 {"Not pinned"}
1 {"Pinned"}
2 {"Pinned inherit"}
default {"res Error:$val"}
}
}
Function resItemType($val)
{
switch($val){
0 {"File"}
1 {"Directory"}
2 {"Share"}
3 {"Server"}
default {"res Error:$val"}
}
}
$out = @()
$q |foreach{
# Infos @ http://msdn.microsoft.com/en-us/library/windows/desktop/bb530659(v=vs.85).aspx
$out += New-Object -TypeName PSobject -Property @{
#OfflineFilesItem http://msdn.microsoft.com/en-us/library/windows/desktop/bb309196(v=vs.85).aspx
ItemPath=$_.ItemPath
ItemType =resItemType($_.ItemType) #Values (File, Directory, Share, Server) , ValueMap (0, 1, 2, 3)
Sparse=$_.Sparse #TRUE if the item is sparsely cached, or FALSE otherwise. A sparsely-cached item exists in the Offline Files cache but not all of its contents are cached. Such items are not available offline
#ChangeInfo all booleans http://msdn.microsoft.com/en-us/library/windows/desktop/bb530504(v=vs.85).aspx
CreatedOffline=$_.ChangeInfo.CreatedOffline
DeletedOffline=$_.ChangeInfo.DeletedOffline
Dirty=$_.ChangeInfo.Dirty
ModifiedAttributes=$_.ChangeInfo.ModifiedAttributes
ModifiedData=$_.ChangeInfo.ModifiedData
ModifiedTime=$_.ChangeInfo.ModifiedTime
#ConnectionInfo Describes the connection state of an item in the Offline Files cache. Enum http://msdn.microsoft.com/en-us/library/windows/desktop/bb530644(v=vs.85).aspx
#8tung ConnectState liefert mehr als in WMI erwhnt ?
#ConnectState=$_.ConnectionInfo.ConnectState
#Values (Unknown, Offline, Online) , ValueMap (0, 1, 2) OFFLINEFILES_CONNECT_STATE_TRANSPARENTLY_CACHED
= 3, OFFLINEFILES_CONNECT_STATE_PARTLY_TRANSPARENTLY_CACHED
= 4
ConnectState=resConnectState($_.ConnectionInfo.ConnectState)
#OfflineReason=$_.ConnectionInfo.OfflineReason #Values (Unknown, Not applicable, Working offline, Slow connection, Net disconnected, Need to sync item, Item suspended) , ValueMap (0, 1, 2, 3, 4, 5, 6)
OfflineReason=resOfflineReason($_.ConnectionInfo.OfflineReason)
#DirtyInfo amount of unsynchronized data
http://msdn.microsoft.com/en-us/library/windows/desktop/bb736327(v=vs.85).aspx
LocalDirtyByteCount=$_.DirtyInfo.LocalDirtyByteCount
RemoteDirtyByteCount=$_.DirtyInfo.RemoteDirtyByteCount
#FileSysInfo all booleans http://msdn.microsoft.com/en-us/library/windows/desktop/bb309195(v=vs.85).aspx
LocalAttributes=$_.FileSysInfo.LocalAttributes
LocalChangeTime=$_.FileSysInfo.LocalChangeTime
LocalCreationTime=$_.FileSysInfo.LocalCreationTime
LocalLastAccessTime=$_.FileSysInfo.LocalLastAccessTime
LocalLastWriteTime=$_.FileSysInfo.LocalLastWriteTime
LocalSize=$_.FileSysInfo.LocalSize
OriginalAttributes=$_.FileSysInfo.OriginalAttributes
OriginalChangeTime=$_.FileSysInfo.OriginalChangeTime
OriginalCreationTime=$_.FileSysInfo.OriginalCreationTime
OriginalLastAccessTime=$_.FileSysInfo.OriginalLastAccessTime
OriginalLastWriteTime=$_.FileSysInfo.OriginalLastWriteTime
OriginalSize=$_.FileSysInfo.OriginalSize
RemoteAttributes=$_.FileSysInfo.RemoteAttributes
RemoteChangeTime=$_.FileSysInfo.RemoteChangeTime
RemoteCreationTime=$_.FileSysInfo.RemoteCreationTime
RemoteLastAccessTime=$_.FileSysInfo.RemoteLastAccessTime
RemoteLastWriteTime=$_.FileSysInfo.RemoteLastWriteTime
RemoteSize=$_.FileSysInfo.RemoteSize
#PinInfo http://msdn.microsoft.com/en-us/library/windows/desktop/bb309197(v=vs.85).aspx
Pinned=$_.PinInfo.Pinned #TRUE if the item is pinned for any reason, or FALSE otherwise.
PinnedForComputer=resPinInfo($_.PinInfo.PinnedForComputer) #Qualifiers: Values (Not pinned, Pinned, Pinned inherit) , ValueMap (0, 1, 2)
PinnedForFolderRedirection=resPinInfo($_.PinInfo.PinnedForFolderRedirection) #Values (Not pinned, Pinned, Pinned inherit) , ValueMap (0, 1, 2)
PinnedForUser=resPinInfo($_.PinInfo.PinnedForUser) #Values (Not pinned, Pinned, Pinned inherit) , ValueMap (0, 1, 2)
PinnedForUserByPolicy=resPinInfo($_.PinInfo.PinnedForUserByPolicy) #Values (Not pinned, Pinned, Pinned inherit) , ValueMap (0, 1, 2)
#SuspendInfo http://msdn.microsoft.com/en-us/library/windows/desktop/bb309198(v=vs.85).aspx
Suspended=$_.SuspendInfo.Suspended #TRUE if the item is suspended, or FALSE otherwise.
SuspendedRoot=$_.SuspendInfo.SuspendedRoot #TRUE if the item is a suspended root, or FALSE otherwise. If the item is not suspended, this value is always FALSE.
}
}
$out |select ItemPath,ItemType,Sparse,Dirty,ConnectState,OfflineReason,Pinned,PinnedForFolderRedirection,Suspended,RemoteSize |out-gridview
$out |export-csv c:\temp\rmtDumperv2.csv
August 3rd, 2012 8:59am
Awesome script! I have not given it a go yet but it looks like you grabbed all the info I could think of for later analysis. Well done. I am curently playing around with some methods to transitionoffline the CSC for a particular folder
e.g.
# Grab the local computer hostname
$hostname = [System.Net.Dns]::GetHostName()
# Set the WMI Object as a .NET class to enable extended functionality
$objWMI = [wmiclass]"\\$hostname\root\cimv2:Win32_OfflineFilesCache"
# Transition files offline
$objWMI.TransitionOffline("\\domain.local\Data\ShareRoot1")
# Transition files online
$objWMI.TransitionOnline("\\domain.local\Data\ShareRoot1")
Take care,
Chris
Free Windows Admin Tool Kit Click here and download it now
August 3rd, 2012 5:05pm
Hi Chris,
Yes there are many nice Methods around in WMI. Actually im looking around for the Sync Method.
For Transition i have this as oneliner:
(get-wmiobject -List "win32_offlinefilescache").TransitionOnline((Get-Item env:HomeShare).Value,2).returnvalue
The target server should be online at the execution time.
cheers
steini
August 4th, 2012 4:48am


