Answers for "Basic auth HTTP Powershell"

0

Basic auth HTTP Powershell

1..255 | %{
$IP = "192.168.2.$_"
    If (Test-Connection -count 1 -comp $IP -quiet) {
        $user = 'admin'
        $pass = 'admin'
        $pair = "$($user):$($pass)"
        $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
        $basicAuthValue = "Basic $encodedCreds"
        $Headers = @{
            Authorization = $basicAuthValue
        }
        $URL = "http://"+$IP+"/servlet?key=Reboot"
        Invoke-WebRequest -Uri $URL -Headers $Headers
    }
}
Posted by: Guest on April-12-2022

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language