public/functions/USPController.ps1
|
function Add-AvmUspController { <# .SYNOPSIS Wiki: https://github.com/chikenborgir/avmtools/wiki/Add-AvmUspController .DESCRIPTION Wiki: https://github.com/chikenborgir/avmtools/wiki/Add-AvmUspController .NOTES Author: chikenborgir Website: https://github.com/chikenborgir/avmtools License: https://github.com/chikenborgir/avmtools/blob/main/LICENSE .LINK https://github.com/chikenborgir/avmtools https://github.com/chikenborgir/avmtools/blob/main/LICENSE #> Param ( [Alias("i")] [Parameter()] [System.Management.Automation.SwitchParameter]$Insecure = $false, [Alias("r")] [Parameter()] [System.Management.Automation.SwitchParameter]$RemoteAccess = $false, [Alias("t")] [Parameter()] [System.String]$Token, [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.Byte][System.Boolean]$NewEnable, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.String]$NewEndpointID, [Parameter(Mandatory)] [ValidateSet("websocket","mqtt")] [System.String]$NewMTP, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.String]$NewHostname, [Parameter()] [System.String]$NewPath, [Parameter(Mandatory)] [ValidateRange(0,65535)] [System.UInt16]$NewPort, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.Byte][System.Boolean]$NewUseTLS, [Parameter()] [System.String]$NewMQTTControllerTopic, [Parameter()] [System.String]$NewMQTTResponseTopic, [Parameter()] [System.String]$NewMQTTClientID, [Parameter()] [System.Byte][System.Boolean]$NewAccessRightSmarthome, [Parameter()] [System.Byte][System.Boolean]$NewAccessRightMesh, [Parameter()] [System.Byte][System.Boolean]$NewAccessRightInternet, [Parameter()] [System.Byte][System.Boolean]$NewAccessRightSystem, [Parameter()] [System.Byte][System.Boolean]$NewAccessRightController, [Parameter()] [System.Byte][System.Boolean]$NewAccessRightWiFi, [Parameter()] [System.Byte][System.Boolean]$NewAccessRightVoIP, [Parameter()] [System.String]$NewUsername, [Parameter()] [System.Security.SecureString]$NewPassword ) $SecurePointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($NewPassword) $PlainNewPassword = [Runtime.InteropServices.Marshal]::PtrToStringAuto($SecurePointer) [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($SecurePointer) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:X_AVM-DE_USPController:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_uspcontroller" $AvmWebrequestBody.Action = "AddUSPController" $AvmWebrequestBody.Token = $Token $AvmWebrequestBody.InnerBody = @" <s:NewEnable>{0}</s:NewEnable> <s:NewEndpointID>{1}</s:NewEndpointID> <s:NewMTP>{2}</s:NewMTP> <s:NewHostname>{3}</s:NewHostname> <s:NewPath>{4}</s:NewPath> <s:NewPort>{5}</s:NewPort> <s:NewUseTLS>{6}</s:NewUseTLS> <s:NewMQTTControllerTopic>{7}</s:NewMQTTControllerTopic> <s:NewMQTTResponseTopic>{8}</s:NewMQTTResponseTopic> <s:NewMQTTClientID>{9}</s:NewMQTTClientID> <s:NewAccessRightSmarthome>{10}</s:NewAccessRightSmarthome> <s:NewAccessRightMesh>{11}</s:NewAccessRightMesh> <s:NewAccessRightInternet>{12}</s:NewAccessRightInternet> <s:NewAccessRightSystem>{13}</s:NewAccessRightSystem> <s:NewAccessRightController>{14}</s:NewAccessRightController> <s:NewAccessRightWiFi>{15}</s:NewAccessRightWiFi> <s:NewAccessRightVoIP>{16}</s:NewAccessRightVoIP> <s:NewUsername>{17}</s:NewUsername> <s:NewPassword>{18}</s:NewPassword> "@ -f $NewEnable, $NewEndpointID, $NewMTP, $NewHostname, $NewPath, $NewPort, $NewUseTLS, $NewMQTTControllerTopic, $NewMQTTResponseTopic, $NewMQTTClientID, $NewAccessRightSmarthome, $NewAccessRightMesh, $NewAccessRightInternet, $NewAccessRightSystem, $NewAccessRightController, $NewAccessRightWiFi, $NewAccessRightVoIP, $NewUsername, $PlainNewPassword [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 Enable-AvmUspControllerByIndex { <# .SYNOPSIS Wiki: https://github.com/chikenborgir/avmtools/wiki/Enable-AvmUspControllerByIndex .DESCRIPTION Wiki: https://github.com/chikenborgir/avmtools/wiki/Enable-AvmUspControllerByIndex .NOTES Author: chikenborgir Website: https://github.com/chikenborgir/avmtools License: https://github.com/chikenborgir/avmtools/blob/main/LICENSE .LINK https://github.com/chikenborgir/avmtools https://github.com/chikenborgir/avmtools/blob/main/LICENSE #> Param ( [Alias("i")] [Parameter()] [System.Management.Automation.SwitchParameter]$Insecure = $false, [Alias("r")] [Parameter()] [System.Management.Automation.SwitchParameter]$RemoteAccess = $false, [Alias("t")] [Parameter()] [System.String]$Token, [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,65535)] [System.UInt16]$NewIndex, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.Byte][System.Boolean]$NewEnable ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:X_AVM-DE_USPController:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_uspcontroller" $AvmWebrequestBody.Action = "SetUSPControllerEnableByIndex" $AvmWebrequestBody.Token = $Token $AvmWebrequestBody.InnerBody = @" <s:NewIndex>{0}</s:NewIndex> <s:NewEnable>{1}</s:NewEnable> "@ -f $NewIndex, $NewEnable [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-AvmUspControllerByIndex { <# .SYNOPSIS Wiki: https://github.com/chikenborgir/avmtools/wiki/Get-AvmUspControllerByIndex .DESCRIPTION Wiki: https://github.com/chikenborgir/avmtools/wiki/Get-AvmUspControllerByIndex .NOTES Author: chikenborgir Website: https://github.com/chikenborgir/avmtools License: https://github.com/chikenborgir/avmtools/blob/main/LICENSE .LINK https://github.com/chikenborgir/avmtools https://github.com/chikenborgir/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,65535)] [System.UInt16]$NewIndex ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:X_AVM-DE_USPController:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_uspcontroller" $AvmWebrequestBody.Action = "GetUSPControllerByIndex" $AvmWebrequestBody.InnerBody = "<s:NewIndex>{0}</s:NewIndex>" -f $NewIndex [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-AvmUspControllerInfo { <# .SYNOPSIS Wiki: https://github.com/chikenborgir/avmtools/wiki/Get-AvmUspControllerInfo .DESCRIPTION Wiki: https://github.com/chikenborgir/avmtools/wiki/Get-AvmUspControllerInfo .NOTES Author: chikenborgir Website: https://github.com/chikenborgir/avmtools License: https://github.com/chikenborgir/avmtools/blob/main/LICENSE .LINK https://github.com/chikenborgir/avmtools https://github.com/chikenborgir/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_USPController:1#GetInfo" UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_uspcontroller" XmlResponse = "GetInfoResponse" } Connect-AvmDevice @SplatParameters } function Get-AvmUspControllerNumberOfEntry { <# .SYNOPSIS Wiki: https://github.com/chikenborgir/avmtools/wiki/Get-AvmUspControllerNumberOfEntry .DESCRIPTION Wiki: https://github.com/chikenborgir/avmtools/wiki/Get-AvmUspControllerNumberOfEntry .NOTES Author: chikenborgir Website: https://github.com/chikenborgir/avmtools License: https://github.com/chikenborgir/avmtools/blob/main/LICENSE .LINK https://github.com/chikenborgir/avmtools https://github.com/chikenborgir/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_USPController:1#GetUSPControllerNumberOfEntries" UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_uspcontroller" XmlResponse = "GetUSPControllerNumberOfEntriesResponse" } Connect-AvmDevice @SplatParameters } function Get-AvmUspMyFritzEnable { <# .SYNOPSIS Wiki: https://github.com/chikenborgir/avmtools/wiki/Get-AvmUspMyFritzEnable .DESCRIPTION Wiki: https://github.com/chikenborgir/avmtools/wiki/Get-AvmUspMyFritzEnable .NOTES Author: chikenborgir Website: https://github.com/chikenborgir/avmtools License: https://github.com/chikenborgir/avmtools/blob/main/LICENSE .LINK https://github.com/chikenborgir/avmtools https://github.com/chikenborgir/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_USPController:1#GetUSPMyFRITZEnable" UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_uspcontroller" XmlResponse = "GetUSPMyFRITZEnableResponse" } Connect-AvmDevice @SplatParameters } function Remove-AvmUspControllerByIndex { <# .SYNOPSIS Wiki: https://github.com/chikenborgir/avmtools/wiki/Remove-AvmUspControllerByIndex .DESCRIPTION Wiki: https://github.com/chikenborgir/avmtools/wiki/Remove-AvmUspControllerByIndex .NOTES Author: chikenborgir Website: https://github.com/chikenborgir/avmtools License: https://github.com/chikenborgir/avmtools/blob/main/LICENSE .LINK https://github.com/chikenborgir/avmtools https://github.com/chikenborgir/avmtools/blob/main/LICENSE #> Param ( [Alias("i")] [Parameter()] [System.Management.Automation.SwitchParameter]$Insecure = $false, [Alias("r")] [Parameter()] [System.Management.Automation.SwitchParameter]$RemoteAccess = $false, [Alias("t")] [Parameter()] [System.String]$Token, [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,65535)] [System.UInt16]$NewIndex ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:X_AVM-DE_USPController:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_uspcontroller" $AvmWebrequestBody.Action = "DeleteUSPControllerByIndex" $AvmWebrequestBody.Token = $Token $AvmWebrequestBody.InnerBody = "<s:NewIndex>{0}</s:NewIndex>" -f $NewIndex [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-AvmUspMyFritzEnable { <# .SYNOPSIS Wiki: https://github.com/chikenborgir/avmtools/wiki/Set-AvmUspMyFritzEnable .DESCRIPTION Wiki: https://github.com/chikenborgir/avmtools/wiki/Set-AvmUspMyFritzEnable .NOTES Author: chikenborgir Website: https://github.com/chikenborgir/avmtools License: https://github.com/chikenborgir/avmtools/blob/main/LICENSE .LINK https://github.com/chikenborgir/avmtools https://github.com/chikenborgir/avmtools/blob/main/LICENSE #> Param ( [Alias("i")] [Parameter()] [System.Management.Automation.SwitchParameter]$Insecure = $false, [Alias("r")] [Parameter()] [System.Management.Automation.SwitchParameter]$RemoteAccess = $false, [Alias("t")] [Parameter()] [System.String]$Token, [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.Byte][System.Boolean]$NewUSPMyFRITZEnabled ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:X_AVM-DE_USPController:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_uspcontroller" $AvmWebrequestBody.Action = "SetUSPMyFRITZEnable" $AvmWebrequestBody.Token = $Token $AvmWebrequestBody.InnerBody = "<s:NewUSPMyFRITZEnabled>{0}</s:NewUSPMyFRITZEnabled>" -f $NewUSPMyFRITZEnabled [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 } |