0

I would like to know how to implement Powershell script run into Command Line successfully?

Actually, I tried to run it and show an error message like that:

Basic : The term 'Basic' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.

enter image description here Anyone can help me? Thanks.

Powershell Script

Invoke-WebRequest -Uri "http://XX.XX.XX.XXX/123.cgi" -Headers @{ "Authorization"="Basic WjVfb3AljjFkjZluOm7hAE9pbjQx"} -OutFile '123.csv'
user11343272
  • 77
  • 1
  • 1
  • 9
  • Can you please share how you're calling the command via CMD? There's a syntax error and *Basic* is being considered something it shouldn't. Probably due to the double quotes being used where they shouldn't. – alexzelaya May 28 '21 at 10:09

1 Answers1

1

Guessing what your question really is, perhaps your preferred one these will suffice:

%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NoLogo -Command "Invoke-WebRequest -Uri \"http://XX.XX.XX.XXX/123.cgi\" -Headers @{ \"Authorization\" = \"Basic WjVfb3AljjFkjZluOm7hAE9pbjQx\" } -OutFile \"123.csv"\"
%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NoLogo -Command "Invoke-WebRequest -Uri 'http://XX.XX.XX.XXX/123.cgi' -Headers @{ 'Authorization' = 'Basic WjVfb3AljjFkjZluOm7hAE9pbjQx' } -OutFile '123.csv'"

Please note that this, as did yours, does not provide a full path for the CSV file for output, and will therefore use whatever your current working directory is.

Compo
  • 36,585
  • 5
  • 27
  • 39