This thread comes from here. I just tried to split it up because the actual question there has already been answered.
Whatever, forget New-PSDrive cmdlet. I tried it out with mapping. Here's my new error:
Exception calling "MapNetworkDrive" with "5" argument(s): "The network path was not found." At D:\PowerShellScripts\Automatische Installation\scripts\Applications\Notepad++\Notepad++.ps1:14 char:1+ $net.MapNetworkDrive("Y:", $nas, $false, $serveraccname, $serveraccpwd)+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException+ FullyQualifiedErrorId : ComMethodTargetInvocation Join-Path : Cannot find drive. A drive with the name 'Y' does not exist. At D:\PowerShellScripts\Automatische Installation\scripts\Applications\Notepad++\Notepad++.ps1:15 char:12+ $install = Join-Path "Y:" "\Notepad++\Notepad.exe"+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : ObjectNotFound: (Y:String) [Join-Path], DriveNot FoundException+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.Join PathCommand Start-Process : Cannot validate argument on parameter 'FilePath'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again. At D:\PowerShellScripts\Automatische Installation\scripts\Applications\Notepad++\Notepad++.ps1:16 char:37+ $process = (Start-Process -FilePath $install -ArgumentList '/S' -Wait -Verb RunA ...+ ~~~~~~~~+ CategoryInfo : InvalidData: (:) [Start-Process], ParameterBindi ngValidationException+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Power Shell.Commands.StartProcessCommand Errorcode: Start-Process : Cannot validate argument on parameter 'FilePath'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again. At D:\PowerShellScripts\Automatische Installation\scripts\Applications\Notepad++\Notepad++.ps1:27 char:25+ Start-Process -FilePath $install -ArgumentList '/S' -Wait -Verb RunAs+ ~~~~~~~~+ CategoryInfo : InvalidData: (:) [Start-Process], ParameterBindi ngValidationException+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Power Shell.Commands.StartProcessCommand Installation of Notepad++ finished.
I used Write-Host for each $XXX to check myself, if the data is correct (e.g the login data) and yes it is correct. No extra spaces, no doublequotes and also I added the domainname, in front of the accountname.
Once again, I used the same command, and directly typed the networkpath, account and pw into the command. It worked. I first had the error, that the new drivename "NAS01:" is invalid, it's because it was too long already, so I used "Y:".
Here's the part of the script which is important:
$net = New-Object -ComObject WScript.Network $net.MapNetworkDrive("Y:", $nas, $false, $serveraccname, $serveraccpwd)
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' '