Add-content : The network name cannot be found. RRS feed

  • Question

  • Hi All,

    Trying to write a log file on a cloud server machine (ServerMachine1), execution is done through the same machine where I am having all the admin access.

    Commands are:

    PS E:\Aashu> $Logfile = "\\ServerMachine1\E$\Aashu\Logs\LogFile.log"

    Add-content $Logfile -value "Log Value start here"

    Getting error as below:

    Add-content : The network name cannot be found.
    At line:3 char:1
    + Add-content $Logfile -value "Log Value start here"
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : WriteError: (\\ServerMachine1\E$\L...LogFile.log:String) [Add-Content], IOException
        + FullyQualifiedErrorId : GetContentWriterIOError,Microsoft.PowerShell.Commands.AddContentCommand

    This is working fine if I am not giving the log path as a network Path, like this: 
    $Logfile = "E:\Aashu\Logs\LogFile.log"

    I have multiple environments and it worked everywhere else, apart from this server ServerMachine1

    I am new to Power-Shell,  Google results are ambiguous for me as this is not similar behavior on other machines of the same environment.

    Please Help me.

    Sunday, July 2, 2017 9:21 AM

All replies

  • You cannot write to a cloud server use NetBIOS UNCs.

    If you can't list a file with "dir" or "Get-Item" then the server is not available.


    Sunday, July 2, 2017 9:29 AM
  • We use UNC paths all the time to pass data to various servers in our Azure and AWS environments from On-Prem servers.

    AASHU29: Can you perform a \\ServerMachine1\C$ successfully from any other machine?  If so, UNC paths work fine.  When you map via drive letter 'E', do you specify any different credentials than when you map via \\ServerMachine1\E$ approach?

    Thanks for your help! SdeDot

    Sunday, July 2, 2017 1:51 PM
  • Hi,

    >>Add-content : The network name cannot be found.

    can this way be found? "\\ip address \E$\Aashu\Logs\LogFile.log"

    DNS resolution issue?

    Best regards,


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, July 3, 2017 2:50 AM