I want to copy build artifacts from $(System.ArtifactsDirectory) to shared folder on remote Windows Server 2016. I am using "Windows Machine File Copy" task for this. It works when I use this-
- task: WindowsMachineFileCopy@2
displayName: 'Copy build artifacts'
inputs:
SourcePath: '$(System.ArtifactsDirectory)/*'
MachineNames: 'targetHostname'
AdminUserName: 'domain\administrator'
AdminPassword: '******'
TargetPath: 'D:\sharedfolder'
But I do not want to use admin credentials that you see above. I read MS doco- https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/windows-machine-file-copy?view=azure-devops
Admin credential parameters AdminUserName and AdminPassword are optional. But I remove them copy task fails. So my requirement is- we do not want to use username and password. Instead we want to use Azure Service Principal. Is there a way I can achieve copying files using Service Principal instead of username and password?

