API Endpoint run under different user context

Product: PowerShell Universal
Version: 3.9.5

I have several API Endpoint that connects to the files hare and do some specific actions. However, the storage connection limit is being reached what the Endpoint script does is map the file share as a drive so it can define credential that has permission to the file share, then once successfully mapped, it does what it requires to do. However, it fails when several attempts are being made because of storage limitation. Storage suggested to connect directly via UNC and not map the drive. How can I do that on the API Endpoint. I tried directly invoking it using on powershell window under user context that has access to the file share but it fails with access denied error?