Forum Discussion
Syncing SharePoint Document Libraries on Non-Persistent Virtual Computers
I have had some inconsistencies with the script and have made the following changes that seem to work very well in my environment.
Change the following:
$DomainServer = $env:LOGONSERVER.Substring(2) + '.' + $env:USERDNSDOMAIN
$UserName = $env:USERNAME
to:
$DomainServer = [System.Net.Dns]::GetHostByName($env:LOGONSERVER.Substring(2)).HostName
$UserName = [Environment]::UserName
I will update the OP to reflect this change.
Thank you TonyBryant ! I found this tutorial which has a similar script methodology for synching Sharepoint sites:
https://youtu.be/Zoac9lbUuG0?t=1050
It uses "whoami /upn" to set the UPN variable, which seems to be working for AzureAD accounts:
$userUPN= cmd /c "whoami /upn"
Their script is hosted on GitHub and seems to work well:
https://github.com/tabs-not-spaces/CodeDump/blob/master/Sync-SharepointFolder/Sync-SharepointFolder.ps1
However it may be a bit more complex than is needed with the Error and Success messages being returned. For my purposes having the script run silently is best, so I will likely be using a combo of code from your script and the Intune Training Channel folks.
I have been working on deploying Sharepoint site synchronizations via Intune as a Win32App. Intune does have a feature for mapping Sharepoint sites, but it's ridiculously slow. It takes anywhere from 8 hours to 5 days before the libraries show up on the computer as Synched.
- Press_StartJan 28, 2022Copper ContributorWe got the script working well following the instructions of jsmithianasher. The only issue now is that with every login after the first one you get the message that library is already synced. Is there a way to check if it is synced first before syncing it?