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'
1
  • 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. Commented May 28, 2021 at 10:09

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your help. The problem was solved! :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.