Powershell:没有评估的Set-Content

时间:2015-08-06 13:47:30

标签: powershell

如何在没有评估的情况下设置内容(使用powershell控制台)?

我在PSSession(远程)并且想要设置脚本文件

[Server1]: PS C:\Users\Admin\Documents> Set-Content -Path script.ps1 -Value @"
>>> $isStarted = $false;
>>> try
>>> {
>>>     $isStarted = (Get-NlbClusterDriverInfo).CurrentHostState -eq "Started"
>>> }
>>> catch
>>> {
>>>     Write-Host "3" # Critical
>>>     # Exit 3
>>> }
>>>
>>> if ($isStarted)
>>> {
>>>     Write-Host "0" # OK
>>>     # Exit 0
>>> }else
>>> {
>>>     Write-Host "3" # Critical
>>>     # Exit 3
>>> }
>>> "@

但这是写的:

[Server1]: PS C:\Users\Admin\Documents> Get-Content .\script.ps1

True = False;
try
{
    True = (Get-NlbClusterDriverInfo).CurrentHostState -eq "Started"
}
catch
{
    Write-Host "3" # Critical
    # Exit 3
}

if (True)
{
    Write-Host "0" # OK
    # Exit 0
}else
{
    Write-Host "3" # Critical
    # Exit 3
}

0 个答案:

没有答案