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
的替代品。