Интересно. Пингуется, но test-connection выдаёт false?
Да.
Цитата DJ Mogarych:
Интересно. Пингуется, но test-connection выдаёт false?
Любой компьютер: хоть пингуется или не пингуется, всё равно выдаёт False.
Код: Выделить всё
S C:\1.System> Test-Connection "test_pc" -Count 1
Source Destination IPV4Address IPV6Address Bytes Time(ms)
------ ----------- ----------- ----------- ----- --------
my_pc test_pc 192.168.18.56 32 0
PS C:\1.System> Test-Connection "test_pc" -Count 1 -Quiet
FalseКод: Выделить всё
C:\>ping test_pc
Обмен пакетами с test_pc.domain.ru [192.168.18.56] с 32 байтами данных:
Ответ от 192.168.18.56: число байт=32 времяКод: Выделить всё
PS C:\1.System> Test-Connection test_pc -Count 1 -Quiet
FalseКод: Выделить всё
PS C:\1.System> Test-Connection test_pc
Source Destination IPV4Address IPV6Address Bytes Time(ms)
------ ----------- ----------- ----------- ----- --------
my_pc test_pc 192.168.18.56 32 0
my_pc test_pc 192.168.18.56 32 0
my_pc test_pc 192.168.18.56 32 0
my_pc test_pc 192.168.18.56 32 0Код: Выделить всё
“pager”,“IP”,“name”,“title”,“department”Код: Выделить всё
$ex = (import-csv "C:\Temp\exceptions_ping.csv").pager
$Computers = Import-Csv "C:\User_Comp.csv" |? {$_.pager -and $_.pager -notin $ex}Код: Выделить всё
$ex = (import-csv "C:\Temp\exceptions_ping.csv").pager
$Computers = Import-Csv "C:\User_Comp.csv" |? {$_.pager -and $_.pager -notin $ex}Код: Выделить всё
$p=[ordered]@{
"Pager"=$Computer.Pager
"IP"=$IP
"name"=$Computer.Name
"title"=$Computer.Title
"department"=$Computer.Department
"date"=$CurrentDate
}Код: Выделить всё
$csv = "C:\Pings\Ping_$CurrentDate.csv"Код: Выделить всё
$CurrentDate = Get-Date
$CurrentDate = $CurrentDate.ToString('dd-MMMM-yyy_HH-mm-ss')
$csv = "C:\Pings\Ping_$CurrentDate.csv"
$Results=New-Object System.Collections.Generic.List[PSObject]
$ex = (import-csv "C:\Scripts\Ping_Computers\exceptions_ping.csv").pager
$Computers = Import-Csv "C:\Scripts\Ping_Computers\User_Comp.csv" |? {$_.pager -and $_.pager -notin $ex}
$Computers = $Computers| where-object {$_.pager -ne ""}
foreach ($computer in $Computers)
{
Write-host "Pinging $($Computer.pager)"
$Test = Test-Connection -ComputerName $($Computer.pager) -Count 1 -ErrorAction SilentlyContinue -ErrorVariable Err
if ($test -ne $null)
{
$IP = $Test.IPV4Address.IPAddressToString
$p=[ordered]@{
"Pager"=$Computer.Pager
"IP"=$IP
"name"=$Computer.Name
"title"=$Computer.Title
"department"=$Computer.Department
"canonicalName"=$canonicalName.canonicalName
"date"=$CurrentDate
}
$Obj=New-Object -Type PsObject -Property $p
$Results.Add($Obj)
}
}
$Results | Export-Csv -Encoding UTF8 -Delimiter ";" -Path $csvКод: Выделить всё
domain.ru/OrganizationUnit_1/OrganizationUnit_2/OrganizationUnit_3/OrganizationUnit_4/OrganizationUnit_5/OrganizationUnit_6/OrganizationUnit_7/UserКод: Выделить всё
$csv = "C:\Pings\Ping_$CurrentDate.csv"Код: Выделить всё
"Pager";"IP";"name";"title";"department";"OrganizationUnit_1";"OrganizationUnit_2";"OrganizationUnit_3";"OrganizationUnit_4";"OrganizationUnit_5";"OrganizationUnit_6";"OrganizationUnit_7";"date"Код: Выделить всё
$csv = "C:\Pings\Ping_$CurrentDate.csv"Код: Выделить всё
$csv = "C:\Pings\By_week\Ping_$CurrentDate.csv"