Sync-SfItem : Object reference not set to an instance of an object.
Hello,
when I use the switch -recurse I got the following error, without the switch I don't get any error but I could not copy the subfolders and their content.
Script :
#Variable
$sfClientFile = "C:\Temp\MySubdomain.sfps"
$LocalFolder = "C:\temp\ShareFile"
$Folder = 'Reporting & Insights'
#Prerequisite
#Adding the PsDrive
Write-Host "Adding the PSSnapIn ShareFile" -ForegroundColor Yellow
Add-PSSnapIn ShareFile
#Use an existing login token
Write-Host "Connecting to ShareFile" -ForegroundColor Yellow
$sfClient = Get-SfClient -Name $sfClientFile
#Adding the PsDrive
Write-Host "Adding the PSDrive ShareFile" -ForegroundColor Yellow
New-PSDrive -Name source -PSProvider ShareFile -Root "/" -Client $sfClient
#Copying
Write-Host "Copying the file locally from source:/$Folder to $LocalFolder" -ForegroundColor Yellow
Sync-SfItem -ShareFilePath "source:/$Folder" -Download -LocalPath "$LocalFolder" -Recursive
Error :
Sync-SfItem : Object reference not set to an instance of an object. At C:\Temp\Copy-ShareFileToSharePoint.ps1:39 char:9
-
Sync-SfItem -ShareFilePath "source:/$Folder" -Synchronize -Do ... -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : NotSpecified: (:) [Sync-SfItem], NullReferenceException
- FullyQualifiedErrorId : System.NullReferenceException,ShareFile.Api.Powershell.SyncSfItem
Thank for helping.
I am getting the same error message, but it's only an error with one specific "Users" folder. I posted about this in the ShareFile Community Support board...
https://community.sharefilesupport.com/citrixsharefile/topics/powershell-script-for-syncing-sharefile-folder-to-server
I created a PowerShell script to sync the "Users" ShareFile folder to D:\Shares\UserShares\Remote Users. The Server folder needs to reflect exactly what's in the ShareFile "Users" folder. I looked at the script examples and came up with the one below... Sync-SfItem -ShareFilePath "/Users/" -Synchronize -Download -LocalPath "D:\Shares\UserShares\Remote Users" -Recursive -Strict This works for other folders when testing this on Server 2012 R2, but not the Users folder. When I copy any of the User folders to another folder I used for testing it also didn't work, but I removed the folder and then it worked again. I think there's some kind of bug that's causing this issue and it's not a Permission issue. I get the error below. Does anyone have suggestions?
At line:1 char:1
- Sync-SfItem -ShareFilePath "/Users/" -Synchronize -Download -LocalPath "D:\S ...
-
+ CategoryInfo : NotSpecified: (:) [Sync-SfItem], NullReferenceException + FullyQualifiedErrorId : System.NullReferenceException,ShareFile.Api.Powershell.SyncSfItem
Sync-SfItem -ShareFilePath "/Users/" -Synchronize -Download -LocalPath "D:\Shares\UserShares\Remote Users" -Recursive -Strict
hi charliebrush
I know this is like 3 years old, but we are getting a similar error, did you ever solve this?