I have this command:

curl -s -H "Content-Type: application/json" -H "Authorization: Bearer @(Invoke-Command {gcloud auth application-default print-access-token})" https://speech/googleapis.com/v1/speech:recognize -d @X:\Dropbox\andela-docs\phase-II-docs\google-machine-learning-apis-designing-implementing-solutions\demos\datasets\data-linear16.json 

In linux this command would be run like this:

curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" https://speech/googleapis.com/v1/speech:recognize -d @X:\Dropbox\andela-docs\phase-II-docs\google-machine-learning-apis-designing-implementing-solutions\demos\datasets\data-linear16.json 

I am trying to get the windows powershell equivalent of this portion $(gcloud auth application-default print-access-token)" of my curl command so I can pass in the token


Point of note:

PowerShell can use curl.exe just as you can from cmd.exe. However, using the command curl without the extension '.exe', means you are using the PowerShell alias and thus not the same thing. So, either use 'curl.exe' directly, in PowerShell with its normal command specifications, or you'd need to look deeper at IVR thus changing how you approach this.

As per the builtin PowerShell help.

Get-Help -Name Invoke-WebRequest | 
Format-List -Force

CommonParameters         : True
WorkflowCommonParameters : False
details                  : @{name=Invoke-WebRequest; noun=WebRequest; verb=Invoke}
Syntax                   : @{syntaxItem=System.Object[]}
parameters               : @{parameter=System.Object[]}
inputTypes               : @{inputType=}
relatedLinks             : @{navigationLink=System.Management.Automation.PSObject[]}
returnValues             : @{returnValue=}

aliases                  : iwr

remarks                  : Get-Help cannot ...
PSSnapIn                 : 
alertSet                 : 
description              : 
examples                 : 
Synopsis                 : 
                           Invoke-WebRequest [-Uri] ...

ModuleName               : Microsoft.PowerShell.Utility
nonTerminatingErrors     : 
xmlns:command            : http://schemas.microsoft.com/maml/dev/command/2004/10
xmlns:dev                : http://schemas.microsoft.com/maml/dev/2004/10
xmlns:maml               : http://schemas.microsoft.com/maml/2004/10
Name                     : Invoke-WebRequest
Category                 : Cmdlet
Component                : 
Role                     : 
Functionality            : 

When using any external PowerShell command, quoting and special handling if required.

See also about Redirection

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.