Public/FTLInformation.ps1
function Get-PiHoleInfoMessage { <# .SYNOPSIS Get Pi-hole diagnosis messages Request Pi-hole diagnosis messages #> [CmdletBinding()] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword", "Password")] param ( [Parameter(Mandatory = $true)] [System.URI]$PiHoleServer, [Parameter(Mandatory = $true)] [string]$Password, [bool]$IgnoreSsl = $false, [bool]$RawOutput = $false ) try { $Sid = Request-PiHoleAuth -PiHoleServer $PiHoleServer -Password $Password -IgnoreSsl $IgnoreSsl $Params = @{ Headers = @{sid = $($Sid) } Uri = "$($PiHoleServer.OriginalString)/api/info/messages" Method = "Get" SkipCertificateCheck = $IgnoreSsl ContentType = "application/json" } $Response = Invoke-RestMethod @Params if ($RawOutput) { Write-Output $Response } else { $ObjectFinal = @() foreach ($Item in $Response.messages) { $Object = $null $Object = [PSCustomObject]@{ Id = $Item.id Timestamp = (Convert-PiHoleUnixTimeToLocalTime -UnixTime $Item.timestamp).LocalTime Type = $Item.type Plain = $Item.plain Html = $Item.html } Write-Verbose -Message "Name - $($Object.Id)" Write-Verbose -Message "Timestamp - $($Object.Timestamp)" Write-Verbose -Message "Type - $($Object.Type)" Write-Verbose -Message "Plain - $($Object.Plain)" Write-Verbose -Message "Html - $($Object.Html)" $ObjectFinal += $Object } Write-Output $ObjectFinal } } catch { Write-Error -Message $_.Exception.Message break } finally { if ($Sid) { Remove-PiHoleCurrentAuthSession -PiHoleServer $PiHoleServer -Sid $Sid -IgnoreSsl $IgnoreSsl } } } function Get-PiHoleInfoHost { <# .SYNOPSIS Get info about various host parameters This API hook returns a collection of host infos. #> #Work In Progress [CmdletBinding()] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword", "Password")] param ( [Parameter(Mandatory = $true)] [System.URI]$PiHoleServer, [Parameter(Mandatory = $true)] [string]$Password, [bool]$IgnoreSsl = $false, [bool]$RawOutput = $false ) try { $Sid = Request-PiHoleAuth -PiHoleServer $PiHoleServer -Password $Password -IgnoreSsl $IgnoreSsl $Params = @{ Headers = @{sid = $($Sid) } Uri = "$($PiHoleServer.OriginalString)/api/info/host" Method = "Get" SkipCertificateCheck = $IgnoreSsl ContentType = "application/json" } $Response = Invoke-RestMethod @Params if ($RawOutput) { Write-Output $Response } else { $ObjectFinal = @() foreach ($Item in $Response.host) { $Object = $null $Object = [PSCustomObject]@{ DomainName = $Item.uname.domainname Machine = $Item.uname.machine NodeName = $Item.uname.nodename Release = $Item.uname.release SysName = $Item.uname.sysname Version = $Item.uname.version } $ObjectFinal += $Object Write-Output $ObjectFinal } } } catch { Write-Error -Message $_.Exception.Message break } finally { if ($Sid) { Remove-PiHoleCurrentAuthSession -PiHoleServer $PiHoleServer -Sid $Sid -IgnoreSsl $IgnoreSsl } } } |