You will need to allow the user inside the remoting section on the SPE.config
file as below.
<configuration xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore role:require="Standalone or ContentManagement">
<powershell>
<services>
<remoting enabled="true" requireSecureConnection="false">
<authorization>
<add Permission="Allow" IdentityType="Role" Identity="sitecore\PowerShell Extensions Remoting" />
<!-- Grant permission to the user to excute powershell scripts-->
<add Permission="Allow" IdentityType="User" Identity="sitecore\{{UserName}}" desc="{{UserName}}" />
</authorization>
</remoting>
</services>
</powershell>
</sitecore>
</configuration>
On the above configuration, username to allow to execute the remote script is added. You can find more details regarding SPE remoting
on my blog.
Once the user is added, you need to create script session with the above user as below.
$session = New-ScriptSession -ConnectionUri "{{CMS_Instance_Url}}" -Username {{Username}} -Password {{Password}}
https://sitecorefoundation.in/2024/06/21/deep-dive-into-sitecore-powershell-remoting-module/
Hope this helps!!!