1

I want to export the config from my Fritz!Box but couldn't find any PowerShell script for that. So I'm trying to convert the curl statement I've found but it doesn't work:

curl -s -k -o $OUT --form sid=$SID --form ImportExportPassword=$Passwort--form ConfigExport= https://fritz.box/cgi-bin/firmwarecfg

I've tried many things like:

$body = {
        sid = $SID, 
        ImportExportPassword = $Passwort,
        ConfigExport = ""
}
Invoke-WebRequest -Uri "http://$FritzBoxUrl/cgi-bin/firmwarecfg" -Body $body -Method Post -OutFile $BackupPath

Info: The SID is already caught from another Invoke-Webrequest command

Also I put the parameters in the body into double quotes but that didn't work either.

I'm using PS 5.1 (integrated in Windows) which doesn't have the "-Form" Parameter.

What is the correct syntax to get it to work?

  • Pragmatically speaking - assuming that you're running Windows 10 / a server edition that comes with `curl.exe` - you can try your original command with `curl.exe` instead of `curl` – mklement0 Jun 11 '21 at 13:08
  • Thanks, good to know that this exist. I knew that the "curl" command was just an alias for Invoke-Webrequest. Anyway...I've tried it but unfortunately it didn't work. I've tried: `curl.exe -k -o $BackupPath --form sid=$SID --form ImportExportPassword=$Password --form ConfigExport= https://$FritzBoxUrl/cgi-bin/firmwarecfg` But the result was it didn't write anything (even though permissions are set correctly). – nightmare1942 Jun 14 '21 at 16:03
  • Yes, that's why specifying `.exe` explicitly is needed to bypass that alias. Note that the alias is no longer defined in PowerShell _Core_ (v6+). – mklement0 Jun 14 '21 at 16:04

0 Answers0