Попробуйте это нормально:
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
$query = "INSERT blah blah blah...";
$result = mysqli_query($link, $query);
echo mysqli_insert_id($link);
Попробуйте и доложите ...
# Use a basic WMI connection check before checking the Network Adapter details
(Get-ADComputer -Filter *).Name |
foreach {
If((gwmi -ComputerName $PSItem -Class win32_process))
{
try
{
gwmi -class 'Win32_NetworkAdapterConfiguration' -ComputerName $PSItem |
select DNSHostName, MACAddress, IPAddress, Description |
where IPAddress -NotLike "" |
where Description -NotLike '*VMware*'
}
catch
{
Write-Warning "When processing $PSItem, some other error occurred!"
}
}
Else
{
Write-Warning -Message "WMI connection failed for host $PSItem, thus not reachable"
}
}
Обновление для OP
Что касается…
Спасибо за предложение, но я все еще получаю то же сообщение об ошибке (HRESULT: 0x800706BA)
blockquote>Как утверждают другие, RPC - это не особенность PowerShell, а уровень обслуживания / ресурсов.
Я считаю, что проблема связана с циклом For
. Передача имени $c
не передает имя как фактическое имя компьютера, а как пользовательский объект PS. Вы можете увидеть это, если сделаете Write-Host
:
$computerlist = Get-ADComputer -Filter * | select Name
foreach($c in $computerlist)
{
Write-Host $c
}
@{Name=C1234}
. Вам просто нужно сослаться на свойство, например, $c.Name
Ваш код выглядит так:
$computerlist = Get-ADComputer -Filter * | select Name
foreach($c in $computerlist)
{
try
{
gwmi -class "Win32_NetworkAdapterConfiguration" -ComputerName $c.Name `
|select DNSHostName, MACAddress, IPAddress, Description `
|where IPAddress -NotLike "" `
|where Description -NotLike "VMware*" `
}
catch
{
Write-Warning "$c is unreachable!"
}
}