Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Need to access files on a NAS (with credentials); New-PSDrive, Net Use?

$
0
0

I simply tried to access a Nas with "Join-Path" but sadly you can not use credentials for that. Now Powershell tells me about "New-PSDrive" to use and in the internet I find plenty of pages about "Net Use". I looked them up both but none of them were understandable for me.

Which one would you use and can you explain why and propably also how, so I will understand how that works?

Here's my script so far:

$serveraccname = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Swisscom\SWDPSInstaller" -Name "Server Accountname")."Server Accountname"
$serveraccpwd = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Swisscom\SWDPSInstaller" -Name "Server Accountpwd")."Server Accountpwd" | ConvertTo-SecureString
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $serveraccname, $serveraccpwd
$install = Join-Path ($config.Installer.GlobalSettings.SourcePath) "\Notepad++\Notepad.exe" -Credential $cred

Of course, that's not all. It's just the part where I need to connect to the NAS.

($config.Installer.GlobalSettings.SourcePath)

That part is the NAS and the folder on the NAS. It's something like this: \\NAS01\Folder (I used XML there)


The following is my signature:

Powershell Programmer & Advanced Lua Programmer

Location: Switzerland

Beside that, whenever you see a reply, you think is helpful, click "Vote As Helpful"! And whenever you see a reply being an answer to the main question of the thread, click "Mark As Answer" (if you opened the thread).

I published the URL's for the icons in my signature.

Please contact me, before reporting me, thank you.

[string](0..21|%{[char][int]([int]("{0:d}" -f 0x28)+('577076797174-87661607769657424-8687168065964').substring(($_*2),2))})-replace' '


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>