Script: *list-fritzbox-devices.ps1* ======================== This PowerShell script lists FRITZ!Box's known devices. Parameters ---------- ```powershell PS> ./list-fritzbox-devices.ps1 [[-Username] ] [[-Password] ] [] -Username Specifies the user name to FRITZ!Box Required? false Position? 1 Default value Accept pipeline input? false Accept wildcard characters? false -Password Specifies the password to FRITZ!Box Required? false Position? 2 Default value Accept pipeline input? false Accept wildcard characters? false [] This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` Example ------- ```powershell PS> ./list-fritzbox-devices.ps1 ``` Notes ----- Author: Markus Fleschutz | License: CC0 Related Links ------------- https://github.com/fleschutz/PowerShell Script Content -------------- ```powershell <# .SYNOPSIS Lists FRITZ!Box's known devices .DESCRIPTION This PowerShell script lists FRITZ!Box's known devices. .PARAMETER Username Specifies the user name to FRITZ!Box .PARAMETER Password Specifies the password to FRITZ!Box .EXAMPLE PS> ./list-fritzbox-devices.ps1 .LINK https://github.com/fleschutz/PowerShell .NOTES Author: Markus Fleschutz | License: CC0 #> #Requires -Version 3 param([string]$Username = "", [string]$Password = "") if ($Username -eq "") { $Username = read-host "Enter username for FRITZ!Box" } if ($Password -eq "") { $Password = read-host "Enter password for FRITZ!Box" } write-progress "Contacting FRITZ!Box ..." [string]$HostURL = "https://fritz.box:49443" [string]$SOAPAction="urn:dslforum-org:service:Hosts:1#X_AVM-DE_GetHostListPath" [string]$SOAPrequest = @" "@ $SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force $Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword $XmlResult = invoke-restMethod ` -Method POST ` -Headers @{'SOAPAction'=($SOAPAction)} ` -Uri ($HostURL+"/upnp/control/hosts") ` -Credential $Credentials ` -ContentType 'text/xml' ` -Body $SOAPrequest $HostList = invoke-restMethod -Uri ($HostURL+($XmlResult.Envelope.Body.'X_AVM-DE_GetHostListPathResponse'.'NewX_AVM-DE_HostListPath')) $HostTable = $HostList.List.Item.GetEnumerator() $HostTable | format-table -property Active,IPAddress,MACAddress,HostName,InterfaceType,X_AVM-DE_Speed exit 0 # success ``` *(generated by convert-ps2md.ps1 using the comment-based help of list-fritzbox-devices.ps1 as of 01/25/2024 13:36:52)*