Author Posts

May 24, 2017 at 3:03 pm

A Powershell script uses the "net use" command to map a shared folder.
The command look like the following:

$out = net use z: “\\192.168.1.1\share1” /user:$myuser $mypassword 2>&1

If the command fails, $out contains the following error (I'm afraid, it's Italian, but the meaning is "Impossible to locate the name in the network"):

net.exe : Errore di sistema 67.
In riga:77 car:19
+         $out = net < <<&1
    + CategoryInfo          : NotSpecified: (Errore di sistema 67.:String) [], 
    RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
Impossibile trovare il nome della rete.

How can I save in two variables the meaningful informations, that are:

Errore di sistema 67
Impossibile trovare il nome della rete

Regards
marius

May 24, 2017 at 3:05 pm

So, that error is just a big string, which means you're going to have to parse it out yourself. You could start by seeing if $out[0] and $out[7] returned what you wanted.