Functions/Generic/MyFritz.ps1
function Get-AvmMyFritzInfo { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmMyFritzInfo .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmMyFritzInfo .NOTES Author: Gincules Website: https://github.com/Gincules/avmtools License: https://github.com/Gincules/avmtools/blob/main/LICENSE .LINK https://github.com/Gincules/avmtools https://github.com/Gincules/avmtools/blob/main/LICENSE #> Param ( [Alias("i")] [Parameter()] [System.Management.Automation.SwitchParameter]$Insecure = $false, [Alias("r")] [Parameter()] [System.Management.Automation.SwitchParameter]$RemoteAccess = $false, [Alias("u")] [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.String]$Url, [Alias("p")] [Parameter(Mandatory)] [ValidateRange(0,65535)] [System.UInt16]$Port, [Alias("c")] [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential]$Credential ) [System.Collections.Hashtable]$SplatParameters = @{ Insecure = $Insecure Url = $Url Port = $Port Credential = $Credential SoapAction = "urn:dslforum-org:service:X_AVM-DE_MyFritz:1#GetInfo" UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_myfritz" XmlResponse = "GetInfoResponse" } Connect-AvmDevice @SplatParameters } function Get-AvmMyFritzNumberOfService { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmMyFritzNumberOfService .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmMyFritzNumberOfService .NOTES Author: Gincules Website: https://github.com/Gincules/avmtools License: https://github.com/Gincules/avmtools/blob/main/LICENSE .LINK https://github.com/Gincules/avmtools https://github.com/Gincules/avmtools/blob/main/LICENSE #> Param ( [Alias("i")] [Parameter()] [System.Management.Automation.SwitchParameter]$Insecure = $false, [Alias("r")] [Parameter()] [System.Management.Automation.SwitchParameter]$RemoteAccess = $false, [Alias("u")] [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.String]$Url, [Alias("p")] [Parameter(Mandatory)] [ValidateRange(0,65535)] [System.UInt16]$Port, [Alias("c")] [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential]$Credential ) [System.Collections.Hashtable]$SplatParameters = @{ Insecure = $Insecure Url = $Url Port = $Port Credential = $Credential SoapAction = "urn:dslforum-org:service:X_AVM-DE_MyFritz:1#GetNumberOfServices" UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_myfritz" XmlResponse = "GetNumberOfServicesResponse" } Connect-AvmDevice @SplatParameters } function Get-AvmMyFritzServiceByIndex { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmMyFritzServiceByIndex .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmMyFritzServiceByIndex .NOTES Author: Gincules Website: https://github.com/Gincules/avmtools License: https://github.com/Gincules/avmtools/blob/main/LICENSE .LINK https://github.com/Gincules/avmtools https://github.com/Gincules/avmtools/blob/main/LICENSE #> Param ( [Alias("i")] [Parameter()] [System.Management.Automation.SwitchParameter]$Insecure = $false, [Alias("r")] [Parameter()] [System.Management.Automation.SwitchParameter]$RemoteAccess = $false, [Alias("u")] [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.String]$Url, [Alias("p")] [Parameter(Mandatory)] [ValidateRange(0,65535)] [System.UInt16]$Port, [Alias("c")] [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential]$Credential, [Parameter()] [ValidateRange(0,4294967295)] [System.UInt32]$NewIndex ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:X_AVM-DE_MyFritz:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_myfritz" $AvmWebrequestBody.Action = "GetServiceByIndex" $AvmWebrequestBody.InnerBody = "<s:NewIndex>{0}</s:NewIndex>" -f $NewIndex [System.Collections.Hashtable]$SplatParameters = @{ Insecure = $Insecure Url = $Url Port = $Port Credential = $Credential Body = $AvmWebrequestBody.GenerateBody() SoapAction = $AvmWebrequestBody.GenerateSoapAction() UrlPath = $AvmWebrequestBody.UrlPath XmlResponse = $AvmWebrequestBody.GenerateXmlResponse() } Connect-AvmDevice @SplatParameters } function Remove-AvmMyFritzServiceByIndex { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Remove-AvmMyFritzServiceByIndex .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Remove-AvmMyFritzServiceByIndex .NOTES Author: Gincules Website: https://github.com/Gincules/avmtools License: https://github.com/Gincules/avmtools/blob/main/LICENSE .LINK https://github.com/Gincules/avmtools https://github.com/Gincules/avmtools/blob/main/LICENSE #> Param ( [Alias("i")] [Parameter()] [System.Management.Automation.SwitchParameter]$Insecure = $false, [Alias("r")] [Parameter()] [System.Management.Automation.SwitchParameter]$RemoteAccess = $false, [Alias("u")] [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.String]$Url, [Alias("p")] [Parameter(Mandatory)] [ValidateRange(0,65535)] [System.UInt16]$Port, [Alias("c")] [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential]$Credential, [ValidateRange(0,4294967295)] [System.UInt32]$NewIndex ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:X_AVM-DE_MyFritz:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_myfritz" $AvmWebrequestBody.Action = "DeleteServiceByIndex" $AvmWebrequestBody.InnerBody = "<s:NewIndex>{0}</s:NewIndex>" -f $NewIndex [System.Collections.Hashtable]$SplatParameters = @{ Insecure = $Insecure Url = $Url Port = $Port Credential = $Credential Body = $AvmWebrequestBody.GenerateBody() SoapAction = $AvmWebrequestBody.GenerateSoapAction() UrlPath = $AvmWebrequestBody.UrlPath XmlResponse = $AvmWebrequestBody.GenerateXmlResponse() } Connect-AvmDevice @SplatParameters } function Set-AvmMyFritzServiceByIndex { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmMyFritzServiceByIndex .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmMyFritzServiceByIndex .NOTES Author: Gincules Website: https://github.com/Gincules/avmtools License: https://github.com/Gincules/avmtools/blob/main/LICENSE .LINK https://github.com/Gincules/avmtools https://github.com/Gincules/avmtools/blob/main/LICENSE #> Param ( [Alias("i")] [Parameter()] [System.Management.Automation.SwitchParameter]$Insecure = $false, [Alias("r")] [Parameter()] [System.Management.Automation.SwitchParameter]$RemoteAccess = $false, [Alias("u")] [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.String]$Url, [Alias("p")] [Parameter(Mandatory)] [ValidateRange(0,65535)] [System.UInt16]$Port, [Alias("c")] [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential]$Credential, [Parameter(Mandatory)] [ValidateRange(0,4294967295)] [System.UInt32]$NewIndex, [Parameter(Mandatory)] [System.Byte][System.Boolean]$NewEnabled, [Parameter(Mandatory)] [System.String]$NewName, [Parameter(Mandatory)] [System.String]$NewScheme, [Parameter(Mandatory)] [ValidateRange(0,65535)] [System.UInt16]$NewPort, [Parameter()] [System.String]$NewURLPath, [Parameter()] [ValidateSet("","servicetype_app_camera")] [System.String]$NewType, [Parameter()] [System.String]$NewIPv4Address, [Parameter()] [System.String]$NewIPv6Address, [Parameter()] [System.String]$NewIPv6InterfaceID, [Parameter()] [System.String]$NewMACAddress, [Parameter(Mandatory)] [System.String]$NewHostName ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:X_AVM-DE_MyFritz:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_myfritz" $AvmWebrequestBody.Action = "SetServiceByIndex" $AvmWebrequestBody.InnerBody = @" <s:NewIndex>{0}</s:NewIndex> <s:NewEnabled>{1}</s:NewEnabled> <s:NewName>{2}</s:NewName> <s:NewScheme>{3}</s:NewScheme> <s:NewPort>{4}</s:NewPort> <s:NewURLPath>{5}</s:NewURLPath> <s:NewType>{6}</s:NewType> <s:NewIPv4Address>{7}</s:NewIPv4Address> <s:NewIPv6Address>{8}</s:NewIPv6Address> <s:NewIPv6InterfaceID>{9}</s:NewIPv6InterfaceID> <s:NewMACAddress>{10}</s:NewMACAddress> <s:NewHostName>{11}</s:NewHostName> "@ -f $NewIndex, $NewEnabled, $NewName, $NewScheme, $NewPort, $NewURLPath, $NewType, $NewIPv4Address, $NewIPv6Address, $NewIPv6InterfaceID, $NewMACAddress, $NewHostName [System.Collections.Hashtable]$SplatParameters = @{ Insecure = $Insecure Url = $Url Port = $Port Credential = $Credential Body = $AvmWebrequestBody.GenerateBody() SoapAction = $AvmWebrequestBody.GenerateSoapAction() UrlPath = $AvmWebrequestBody.UrlPath XmlResponse = $AvmWebrequestBody.GenerateXmlResponse() } Connect-AvmDevice @SplatParameters } |