How to upload file in http on IIS 10 / Windows 2016 with powershell RRS feed

  • Question

  • Hello, I'm trying to upload log files on a IIS 10.

    So I setup IIS/Web feature on a Windows 2016 Desktop Experience.

    Under the Default web site, I created a Virtual directory : logs which target a local directory on my server D:\mylogs

    On d:\mylogs, I gave Full access to IIS_IUSRS.

    I also try to set a Physcal Path Credentials using a admin account

    But in both cases, when I try to upload, I get a 404 error.

    Here is the code run from my Windows 7 workstation.

    $sourceFilePath = "D:\LocalData\myaccount\Desktop\vso.log"

    $siteAddress = "http://myserver.mycompany.com/logs"

    $urlDest = "{0}/{1}" -f ($siteAddress, "vso.log")

    $webClient = New-Object System.Net.WebClient;

    $webClient.Credentials = New-Object System.Net.NetworkCredential("myuserr", "password")

    write-host "$sourceFilePath ==> $urlDest"

    $ret = $webClient.UploadFile($urlDest,"PUT",$sourceFilePath)write-host $ret

    Later, I would like to givre IIS_IUSRS the right to write only on D:\mylogs

    Here is the output

    D:\LocalData\myaccount\Desktop\vso.log ==> http://myserver.mycompany.com/logs/vso.log
    Exception calling "UploadFile" with "3" argument(s): "An exception occurred during a WebClient request."
    At C:\Users\myser\Desktop\uploadtest.ps1:7 char:1
    + $ret = $webClient.UploadFile($urlDest,"PUT",$sourceFilePath)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : WebException

    The vso.log do not exists on the web server, but this is the file I would like to upload.

    Perhaps, I'm wrong to try to use http to upload files, do anonymous ftp is better ?

    Thanks for any help




    • Edited by mldmld Tuesday, June 27, 2017 3:49 PM
    • Moved by Bill_Stewart Wednesday, July 26, 2017 7:51 PM This is not IIS support forum
    Tuesday, June 27, 2017 3:49 PM

All replies