如何在PowerShell中查看变量值

3lxsmp7m  于 2023-06-23  发布在  Shell
关注(0)|答案(1)|浏览(243)

我正在设置一个变量,但无法返回值。我该如何解决问题?

PS C:\Users\manuchadha> Set-Variable OPENAI_API_BASE=https://aoai-try-mc.openai.azure.com
PS C:\Users\manuchadha> Get-Variable OPENAI_API_BASE
Get-Variable : Cannot find a variable with the name 'OPENAI_API_BASE'.
At line:1 char:1
+ Get-Variable OPENAI_API_BASE
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (OPENAI_API_BASE:String) [Get-Variable], ItemNotFoundException
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.GetVariableCommand
iqjalb3h

iqjalb3h1#

您使用该命令的方式意味着

Set-Variable OPENAI_API_BASE=https://aoai-try-mc.openai.azure.com

将创建一个名为"$OPENAI_API_BASE=https://aoai-try-mc.openai.azure.com"的变量,没有值。您可以使用Set-Variable -name OPENAI_API_BASE -value https://aoai-try-mc.openai.azure.com,也可以在PS提示符下仅使用$OPENAI_API_BASE=https://aoai-try-mc.openai.azure.com。要调用内容,请在PS提示符下使用Get-Variable OPENAI_API_BASE$OPENAI_API_BASE

相关问题