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.