Trying to upload XML files with Powershell

  • Hello, I am trying to powershell my way into uploading XML files to one or many SG-3100's, and I am a little stuck on the page action. Since it is showing as a form with 2 sections, I am unsure that my code is doing the correct action, and well, it is not uploading. Here is how I'm trying to do it (after making the session, which does connect successfully):

    $Arguments = @{
                       conffile = $RestoreFile;
    $LoopResult = Invoke-WebRequest -TimeoutSec $Timeout -WebSession  $LoopSession -Uri "https://$Luri/diag_backup.php" -Method Post -Body $LoopArguments -InFile $LoopRestoreFile

    Here is the contents of $Arguments variable:

    Name : decrypt
    Value : yes

    Name : restorearea
    Value : aliases

    Name : restore
    Value : restore

    Name : conffile
    Value : C:\path\aliasestest.xml

    Name : __csrf_magic
    Value : sid:091673177ee74bbeb3b0c6c15f34135bb8e53921,1599253539

    Is there anything glaringly wrong about my method, URL or arguments?
    Thanks for your help!


  • After taking another look at the webpage code here, I see that it is only a standard form for the backup/download config area, and the restore area does not have a post action, so Powershell doesn't like that at all. I read on Reddit a little talk about this working after PS v6.1, so I'm investigating that now.

Log in to reply