Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

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
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Basic #auth #HTTP #Powershell
ADD COMMENT
Topic
Name
4+5 =