在 powershell 中回显变量输出

问题描述 投票:0回答:0

我正在尝试在 powershell 脚本中回显/写入输出变量。我尝试了很多不同的方法来查看许多示例,但出于某种原因,我只是无法理解这里出了什么问题。

# Detect the location of this script
Set-Variable "GAMEPATH=(Get-Location).Path"
Write-Output $GAMEPATH

Set-Variable "GAMEEXE=game.exe"

# Make sure Game exists.

Write-Output ""
Write-Output "Step 1. Make sure the game exists!"
if (!(Test-Path $GAMEPATH) -and !(Test-Path $GAMEEXE)) {
    Write-Warning "'$GAMEEXE' absent from both locations"
  }
else 
{
    Write-Output "Step 1. Successful!"
}

我收到错误消息“测试路径:无法将参数绑定到参数‘路径’,因为它为空。”所以我假设路径没有通过 properley。也欢迎任何其他反馈!

powershell if-statement variables path echo
© www.soinside.com 2019 - 2024. All rights reserved.