Bonjour,
Je suis bloqué dans mon script de test de connexion.
Si je mets en dur le nom de l'ordinateur ça fonctionne, mais je voudrais utiliser les variables ($x et $y).
Est-ce que vous pouvez m'aider? S' il vous plaît
Merci

Code PowerShell : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function TestConnection ([STRING]$x,[STRING]$y)
{    
    write-host $x -ForegroundColor red
    write-host $y -ForegroundColor Yellow
 
    $JobName = Start-Job -ScriptBlock { Test-Connection -ComputerName $x -Count $y -Quiet }
	while ($JobName.JobStateInfo.State -eq "Running")
	{
		"Please wait, I check if this computer is connected to the network"
		Start-Sleep -M 2000
	}
 
Receive-Job -id $JobName.Id 
Get-Job -id $JobName.Id | Remove-Job 
 
 
}
 
 
$test = TestConnection 192.168.1.2 2
echo $test