PutFiles() access is denied in powershell but batch and gui works (solution)

PutFiles() access is denied in powershell but batch and gui works (solution)

I'm moving from a legacy batch file to a powershell script and ran into an issue when trying to execute $transferResult = $session.PutFiles($localPath, $remotePath), I kept getting access is denied. I triple checked my $sessionOptions and everything was correct. After hours of debugging turns out that I was missing a / in the $remotePath variable...