I have a local Windows machine with a self-hosted Azure Pipeline agent on which I want to run some scripts that require access to files stored on network drives. However, they don't seem to be accessible as I get "Path not found" or similar errors. Running net use in Powershell does return a list of the network drives I want to access, but their status are set to "Unavailable".
I suspect this has something to do with authentication, but I'm not sure how to solve that. I should note that I do not have administrator permissions, but my user does have access to the drives normally and the agent is configured using my username.
Azure Pipelines: Accessing network drives on self-hosted Windows agent?
When you execute the build, all build tasks should run under your build service account such as AzuredevopsAccount1.
So, you need make sure if the build service account has permission to access network drives.
Besides, if you have username and password to access the network drives, we could try to use it to to access the network drives.
For example, I use powershell scripts to copy the sources files with the specific username and password provided to the network drives:
$Source = $env:BUILD_SOURCESDIRECTORY
$Dest = "\\172.17.xx.xx\SourceFiles\xxx"
$Username = "domain\username"
$Password = ConvertTo-SecureString "PasswordHere" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential($Username, $Password)
New-PSDrive -Name J -PSProvider FileSystem -Root $Dest -Credential $mycreds -Persist
Copy-Item -Path $Source -Recurse -Force -Destination $Dest
The test result:

Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With