diff --git a/src/targets/powershell/common.ts b/src/targets/powershell/common.ts index 9cf395def..cca01e366 100644 --- a/src/targets/powershell/common.ts +++ b/src/targets/powershell/common.ts @@ -16,11 +16,19 @@ export const generatePowershellConvert = (command: PowershellCommand) => { allHeaders, }) => { const { push, join } = new CodeBuilder(); - const methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS']; - - if (!methods.includes(method.toUpperCase())) { - return 'Method not supported'; - } + const methods = [ + 'DEFAULT', + 'DELETE', + 'GET', + 'HEAD', + 'MERGE', + 'OPTIONS', + 'PATCH', + 'POST', + 'PUT', + 'TRACE' + ]; + const methodArg = methods.includes(method.toUpperCase()) ? '-Method' : '-CustomMethod'; const commandOptions = []; @@ -65,7 +73,7 @@ export const generatePowershellConvert = (command: PowershellCommand) => { commandOptions.push(`-Body '${postData.text}'`); } - push(`$response = ${command} -Uri '${fullUrl}' -Method ${method} ${commandOptions.join(' ')}`); + push(`$response = ${command} -Uri '${fullUrl}' ${methodArg} ${method} ${commandOptions.join(' ')}`); return join(); }; return convert; diff --git a/src/targets/powershell/restmethod/fixtures/custom-method.ps1 b/src/targets/powershell/restmethod/fixtures/custom-method.ps1 index 8eb41a680..114e893a4 100644 --- a/src/targets/powershell/restmethod/fixtures/custom-method.ps1 +++ b/src/targets/powershell/restmethod/fixtures/custom-method.ps1 @@ -1 +1 @@ -Method not supported \ No newline at end of file +$response = Invoke-RestMethod -Uri 'http://mockbin.com/har' -CustomMethod PROPFIND \ No newline at end of file diff --git a/src/targets/powershell/webrequest/fixtures/custom-method.ps1 b/src/targets/powershell/webrequest/fixtures/custom-method.ps1 index 8eb41a680..5f587e405 100644 --- a/src/targets/powershell/webrequest/fixtures/custom-method.ps1 +++ b/src/targets/powershell/webrequest/fixtures/custom-method.ps1 @@ -1 +1 @@ -Method not supported \ No newline at end of file +$response = Invoke-WebRequest -Uri 'http://mockbin.com/har' -CustomMethod PROPFIND \ No newline at end of file