Getting the error from net use

Welcome Forums General PowerShell Q&A Getting the error from net use

This topic contains 1 reply, has 2 voices, and was last updated by

1 year, 9 months ago.

  • Author
  • #71425

    Points: 1
    Rank: Member

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

    $out = net use z: “\\\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) [], 
        + 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


  • #71428

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    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.

The topic ‘Getting the error from net use’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort