Folder stopped syncing: Get-SfClient : Object reference not set to an instance of an object.
Hello,  We had a folder stop syncing it's files automatically to sharefile through powershell. I'm trying to make sense of the below error message, is anyone else experiencing the same issue or able to help? The error started yesterday Edit: the code we run is: Add-PSSnapIn ShareFileSet-ExecutionPolicy RemoteSigned$sfClient = Get-sfClient -Name “C:\\\\Sharefile\\\\Apipowershell.sfps”New-PSDrive -Name sfdrive -PSProvider ShareFile -Root “/” -Client $sfClientSync-SfItem -LocalPath “c:\\\\Scanback\\\\*.*” -Upload -ShareFilePath “/Shared Folders/PAS Scanback” -MoveRemove-PSDrive sfdriveThe error we receive is: PS C:\\\\Users\\\\Administrator> C:\\\\ShareFile\\\\PAS_Upload.ps1Get-SfClient : Object reference not set to an instance of an object.At C:\\\\ShareFile\\\\PAS_Upload.ps1:3 char:13+ $sfClient = Get-SfClient -Name 'C:\\\\Sharefile\\\\Apipowershell.sfps'+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : NotSpecified: (:) [Get-SfClient], NullReferenceException    + FullyQualifiedErrorId : System.NullReferenceException,ShareFile.Api.Powershell.GetSfClientNew-PSDrive : Cannot bind argument to parameter 'Client' because it is null.At C:\\\\ShareFile\\\\PAS_Upload.ps1:4 char:68+ ... rive -Name sfdrive -PSProvider ShareFile -Root '/'  -Client $sfClient+                                                                 ~~~~~~~~~    + CategoryInfo          : InvalidData: (:) [New-PSDrive], ParameterBindingValidationException    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.NewPSDriveCommandSync-SfItem : Unable to cast object of type 'System.Management.Automation.PSDriveInfo' to type 'ShareFile.Api.Powershell.ShareFileDriveInfo'.At C:\\\\ShareFile\\\\PAS_Upload.ps1:5 char:1+ Sync-SfItem -LocalPath 'c:\\\\Scanback\\\\*.*' -Upload -ShareFilePath '/Sha ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : NotSpecified: (:) [Sync-SfItem], InvalidCastException    + FullyQualifiedErrorId : System.InvalidCastException,ShareFile.Api.Powershell.SyncSfItemRemove-PSDrive : Cannot find drive. A drive with the name 'sfdrive' does not exist.At C:\\\\ShareFile\\\\PAS_Upload.ps1:6 char:1+ Remove-PSDrive sfdrive+ ~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : ObjectNotFound: (sfdrive:String) [Remove-PSDrive], DriveNotFoundException    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.RemovePSDriveCommand 

  • After over a week of troubleshooting, I was able to dial this down to the SFPS credential file. I'm not sure what caused this issue since the credential file is the same exact file that we have on dozens of other systems running this powershell script, the only difference is this is a server and it runs a task scheduler to automatically run the script every minute. My guess is either the server running the script somehow corrupted the credentials or sharefile is doing something to block that API account from uploading to their server.   In any case, I resolved the issue by running a new sfClient script and plugged in my own login (which uses 2FA, the API login is not supposed to have this). After it generated a new SFPS file, the script runs fine.   Solution:   Ran   New-sfClient -Name “C:\\Sharefile\\Apipowershell.sfps”   instead of   $sfClient = Get-sfClient -Name “C:\\Sharefile\\Apipowershell.sfps”   Then onces the new apipowershell.sfps file was created I went back to running the original script and it is uploading as before.
This question is closed.