Dealing with drive resources mapped with credentials

Hello, I would like to copy a file(s) from one location to another. In the case of the source folder, it’s a Samba UNIX share and to access that share, I provide a username and password, which is a service account, not my own account.

Currently, under my login context, that Samba share is mapped with a drive letter and I assume it can do this because the credentials I submitted are saved within my session.

At present I can use PowerShell to copy the files without issues, but I’m wondering whether this is a bit of an ugly dependency. If the credentials required to map this resource were to change or I wanted to move the script to run under another user context, presumably this wouldn’t work until that same user had also provided user credentials.

To Summarize – Is there a way, within PowerShell, to make reference to a UNC network path and supply a user/pass to it to ensure it is validated?

submitted by /u/dverbern
[link] [comments]

Leave a Reply