如何在执行期间转到PowerShell中的任何特定行

时间:2018-12-30 11:30:14

标签: powershell-v2.0

if ((Get-WmiObject -ComputerName . -Class Win32_ComputerSystem).Domain -eq "domain.local") {
    # Check with User if she/he wants to continue or not
    Write-Host "Hurray you are in domain.local domain"
    $FirstCondition = Read-Host -Prompt "Do you want to continue? If yes please press [Y] else press[N] to discontinue"
    if ($FirstCondition = "Y") {
        # Check if server is pinging or not
        if (Test-Connection -ComputerName . -Count 1 -ErrorAction SilentlyContinue) {
            $NetworkAdapter = Get-WmiObject -ComputerName . -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=$true |
                              Select-Object -Property [a-z]* -ExcludeProperty IPX*,WINS*
            Test-Connection $net.DNSServerSearchOrder[0] -Count 1 -ErrorAction Stop
        }
    } else {
        Goto Line:1
    }
}

else {Goto Line:1}部分,我遇到一个问题,因为在执行过程中,我需要此命令来运行第一行if ((Get-WmiObject -ComputerName . -Class Win32_ComputerSystem).Domain -eq "domain.local"),并检查服务器是否在domain.local域中。请帮助我在PowerShell 2.0中找到Goto的替代品。

0 个答案:

没有答案