Make request from remote computer with using PowerShell Make request from remote computer with using PowerShell powershell powershell

Make request from remote computer with using PowerShell


use invoke-command and wrap your code into the sciptblock like :

icm -computername $hosts -scriptBlock{try     {        Write-Host "Pinging web address for server: $url ..."        $request = [System.Net.WebRequest]::Create("http://google.com")        $response = $request.GetResponse()        Write-Host "Web Request Succeeded."       } catch     {        Write-Host ("Web Request FAILED!!! The error was '{0}'." -f $_)    } finally     {        if ($response)         {            $response.Close()            Remove-Variable response        }    }}