Functions/Generic/WANIPConnection.ps1
function Add-AvmIpPortMapping { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Add-AvmIpPortMapping .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Add-AvmIpPortMapping .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)] [ValidateNotNullOrEmpty()] [System.String]$NewRemoteHost, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.UInt16]$NewExternalPort, [Parameter(Mandatory)] [ValidateSet("UDP","TCP")] [System.String]$NewProtocol, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.UInt16]$NewInternalPort, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.String]$NewInternalClient, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.Byte][System.Boolean]$NewEnabled, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.String]$NewPortMappingDescription, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.UInt32]$NewLeaseDuration ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:WANIPConnection:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/wanipconnection1" $AvmWebrequestBody.Action = "AddPortMapping" $AvmWebrequestBody.InnerBody = @" <s:NewRemoteHost>{0}</s:NewRemoteHost> <s:NewExternalPort>{1}</s:NewExternalPort> <s:NewProtocol>{2}</s:NewProtocol> <s:NewInternalPort>{3}</s:NewInternalPort> <s:NewInternalClient>{4}</s:NewInternalClient> <s:NewEnabled>{5}</s:NewEnabled> <s:NewPortMappingDescription>{6}</s:NewPortMappingDescription> <s:NewLeaseDuration>{7}</s:NewLeaseDuration> "@ -f $NewRemoteHost, $NewExternalPort, $NewProtocol, $NewInternalPort, $NewInternalClient, $NewEnabled, $NewPortMappingDescription, $NewLeaseDuration [System.Collections.Hashtable]$SplatParameters = @{ Insecure = $Insecure Url = $Url Port = $Port Credential = $Credential SoapAction = $AvmWebrequestBody.GenerateSoapAction() UrlPath = $AvmWebrequestBody.UrlPath Body = $AvmWebrequestBody.GenerateBody() XmlResponse = $AvmWebrequestBody.GenerateXmlResponse() } Connect-AvmDevice @SplatParameters } function Get-AvmIpDnsServer { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpDnsServer .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpDnsServer .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:WANIPConnection:1#X_GetDNSServers" UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/wanipconnection1" XmlResponse = "X_GetDNSServersResponse" } Connect-AvmDevice @SplatParameters } function Get-AvmIpExternalAddress { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpExternalAddress .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpExternalAddress .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:WANIPConnection:1#GetExternalIPAddress" UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/wanipconnection1" XmlResponse = "GetExternalIPAddressResponse" } Connect-AvmDevice @SplatParameters } function Get-AvmIpGenericPortMappingEntry { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpGenericPortMappingEntry .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpGenericPortMappingEntry .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)] [ValidateNotNullOrEmpty()] [System.UInt16]$NewPortMappingIndex ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:WANIPConnection:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/wanipconnection1" $AvmWebrequestBody.Action = "GetGenericPortMappingEntry" $AvmWebrequestBody.InnerBody = "<s:NewPortMappingIndex>{0}</s:NewPortMappingIndex>" -f $NewPortMappingIndex [System.Collections.Hashtable]$SplatParameters = @{ Insecure = $Insecure Url = $Url Port = $Port Credential = $Credential SoapAction = $AvmWebrequestBody.GenerateSoapAction() UrlPath = $AvmWebrequestBody.UrlPath Body = $AvmWebrequestBody.GenerateBody() XmlResponse = $AvmWebrequestBody.GenerateXmlResponse() } Connect-AvmDevice @SplatParameters } function Get-AvmIpInfo { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpInfo .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpInfo .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:WANIPConnection:1#GetInfo" UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/wanipconnection1" XmlResponse = "GetInfoResponse" } Connect-AvmDevice @SplatParameters } function Get-AvmIpConnectionTypeInfo { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpConnectionTypeInfo .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpConnectionTypeInfo .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:WANIPConnection:1#GetConnectionTypeInfo" UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/wanipconnection1" XmlResponse = "GetConnectionTypeInfoResponse" } Connect-AvmDevice @SplatParameters } function Get-AvmIpNatRsipStatus { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpNatRsipStatus .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpNatRsipStatus .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:WANIPConnection:1#GetNATRSIPStatus" UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/wanipconnection1" XmlResponse = "GetNATRSIPStatusResponse" } Connect-AvmDevice @SplatParameters } function Get-AvmIpPortMappingEntry { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpPortMappingEntry .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpPortMappingEntry .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:WANIPConnection:1#GetPortMappingNumberOfEntries" UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/wanipconnection1" XmlResponse = "GetPortMappingNumberOfEntriesResponse" } Connect-AvmDevice @SplatParameters } function Get-AvmIpSpecificPortMappingEntry { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpSpecificPortMappingEntry .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpSpecificPortMappingEntry .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)] [ValidateNotNullOrEmpty()] [System.String]$NewRemoteHost, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.String]$NewExternalPort, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.String]$NewProtocol ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:WANIPConnection:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/wanipconnection1" $AvmWebrequestBody.Action = "GetSpecificPortMappingEntry" $AvmWebrequestBody.InnerBody = @" <s:NewRemoteHost>{0}</s:NewRemoteHost> <s:NewExternalPort>{1}</s:NewExternalPort> <s:NewProtocol>{2}</s:NewProtocol> "@ -f $NewRemoteHost, $NewExternalPort, $NewProtocol [System.Collections.Hashtable]$SplatParameters = @{ Insecure = $Insecure Url = $Url Port = $Port Credential = $Credential SoapAction = $AvmWebrequestBody.GenerateSoapAction() UrlPath = $AvmWebrequestBody.UrlPath Body = $AvmWebrequestBody.GenerateBody() XmlResponse = $AvmWebrequestBody.GenerateXmlResponse() } Connect-AvmDevice @SplatParameters } function Get-AvmIpStatusInfo { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpStatusInfo .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmIpStatusInfo .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:WANIPConnection:1#GetStatusInfo" UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/wanipconnection1" XmlResponse = "GetStatusInfoResponse" } Connect-AvmDevice @SplatParameters } function Remove-AvmIpPortMapping { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Remove-AvmIpPortMapping .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Remove-AvmIpPortMapping .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)] [ValidateNotNullOrEmpty()] [System.String]$NewRemoteHost, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.UInt16]$NewExternalPort, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.String]$NewProtocol ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:WANIPConnection:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/wanipconnection1" $AvmWebrequestBody.Action = "DeletePortMapping" $AvmWebrequestBody.InnerBody = @" <s:NewRemoteHost>{0}</s:NewRemoteHost> <s:NewExternalPort>{1}</s:NewExternalPort> <s:NewProtocol>{2}</s:NewProtocol> "@ -f $NewRemoteHost, $NewExternalPort, $NewProtocol [System.Collections.Hashtable]$SplatParameters = @{ Insecure = $Insecure Url = $Url Port = $Port Credential = $Credential SoapAction = $AvmWebrequestBody.GenerateSoapAction() UrlPath = $AvmWebrequestBody.UrlPath Body = $AvmWebrequestBody.GenerateBody() XmlResponse = $AvmWebrequestBody.GenerateXmlResponse() } Connect-AvmDevice @SplatParameters } function Set-AvmIpConnectionTrigger { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmIpConnectionTrigger .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmIpConnectionTrigger .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)] [ValidateNotNullOrEmpty()] [System.String]$NewConnectionTrigger ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:WANIPConnection:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/wanipconnection1" $AvmWebrequestBody.Action = "SetConnectionTrigger" $AvmWebrequestBody.InnerBody = "<s:NewConnectionTrigger>{0}</s:NewConnectionTrigger>" -f $NewConnectionTrigger [System.Collections.Hashtable]$SplatParameters = @{ Insecure = $Insecure Url = $Url Port = $Port Credential = $Credential SoapAction = $AvmWebrequestBody.GenerateSoapAction() UrlPath = $AvmWebrequestBody.UrlPath Body = $AvmWebrequestBody.GenerateBody() XmlResponse = $AvmWebrequestBody.GenerateXmlResponse() } Connect-AvmDevice @SplatParameters } function Set-AvmIpConnectionType { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmIpConnectionType .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmIpConnectionType .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)] [ValidateSet("Unconfigured","IP_Routed","IP_Bridged")] [System.String]$NewConnectionType ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:WANIPConnection:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/wanipconnection1" $AvmWebrequestBody.Action = "SetConnectionType" $AvmWebrequestBody.InnerBody = "<s:NewConnectionType>{0}</s:NewConnectionType>" -f $NewConnectionType [System.Collections.Hashtable]$SplatParameters = @{ Insecure = $Insecure Url = $Url Port = $Port Credential = $Credential SoapAction = $AvmWebrequestBody.GenerateSoapAction() UrlPath = $AvmWebrequestBody.UrlPath Body = $AvmWebrequestBody.GenerateBody() XmlResponse = $AvmWebrequestBody.GenerateXmlResponse() } Connect-AvmDevice @SplatParameters } function Set-AvmIpIdleDisconnectTime { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmIpIdleDisconnectTime .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmIpIdleDisconnectTime .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)] [ValidateNotNullOrEmpty()] [System.UInt32]$NewIdleDisconnectTime ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:WANIPConnection:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/wanipconnection1" $AvmWebrequestBody.Action = "SetIdleDisconnectTime" $AvmWebrequestBody.InnerBody = "<s:NewIdleDisconnectTime>{0}</s:NewIdleDisconnectTime>" -f $NewIdleDisconnectTime [System.Collections.Hashtable]$SplatParameters = @{ Insecure = $Insecure Url = $Url Port = $Port Credential = $Credential SoapAction = $AvmWebrequestBody.GenerateSoapAction() UrlPath = $AvmWebrequestBody.UrlPath Body = $AvmWebrequestBody.GenerateBody() XmlResponse = $AvmWebrequestBody.GenerateXmlResponse() } Connect-AvmDevice @SplatParameters } function Set-AvmIpRouteProtocolRx { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmIpRouteProtocolRx .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmIpRouteProtocolRx .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()] [System.String]$NewRouteProtocolRx = "Off" ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:WANIPConnection:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/wanipconnection1" $AvmWebrequestBody.Action = "SetRouteProtocolRx" $AvmWebrequestBody.InnerBody = "<s:NewRouteProtocolRx>{0}</s:NewRouteProtocolRx>" -f $NewRouteProtocolRx [System.Collections.Hashtable]$SplatParameters = @{ Insecure = $Insecure Url = $Url Port = $Port Credential = $Credential SoapAction = $AvmWebrequestBody.GenerateSoapAction() UrlPath = $AvmWebrequestBody.UrlPath Body = $AvmWebrequestBody.GenerateBody() XmlResponse = $AvmWebrequestBody.GenerateXmlResponse() } Connect-AvmDevice @SplatParameters } function Start-AvmIpConnection { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Start-AvmIpConnection .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Start-AvmIpConnection .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:WANIPConnection:1#RequestConnection" UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/wanipconnection1" XmlResponse = "RequestConnectionResponse" } Connect-AvmDevice @SplatParameters } function Stop-AvmIpConnection { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Stop-AvmIpConnection .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Stop-AvmIpConnection .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:WANIPConnection:1#ForceTermination" UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/wanipconnection1" XmlResponse = "ForceTerminationResponse" } Connect-AvmDevice @SplatParameters } |