【发布时间】:2020-01-11 22:54:02
【问题描述】:
类似于$IsLinux 或$IsWindows 的东西。
【问题讨论】:
类似于$IsLinux 或$IsWindows 的东西。
【问题讨论】:
我建议在特定于云 shell 的 try/catch 中运行命令,如果这是您正在寻找的?
try {
$sessioninfo = Get-CloudDrive
if ($sessioninfo) {
Write-Host "Running in Cloud Shell mode..." -ForegroundColor Green
$path = ($home + "/clouddrive/" + "report" + "-$(get-date -Format yyyyddMM_hhmmtt).csv")
}
}
catch {
Write-Host "Running in local PowerShell session mode..." -ForegroundColor Yellow
$path = "C:\localpath\report"+"-$(get-date -Format yyyyddMM_hhmmtt).csv"
}
【讨论】: