Functions/Generic/Storage.ps1
function Get-AvmStorageInfo { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmStorageInfo .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmStorageInfo .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_Storage:1#GetInfo" UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_storage" XmlResponse = "GetInfoResponse" } Connect-AvmDevice @SplatParameters } function Get-AvmStorageUserInfo { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmStorageUserInfo .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Get-AvmStorageUserInfo .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_Storage:1#GetUserInfo" UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_storage" XmlResponse = "GetUserInfoResponse" } Connect-AvmDevice @SplatParameters } function Request-AvmStorageFtpServerWan { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Request-AvmStorageFtpServerWan .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Request-AvmStorageFtpServerWan .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_Storage:1#RequestFTPServerWAN" UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_storage" XmlResponse = "RequestFTPServerWANResponse" } Connect-AvmDevice @SplatParameters } function Set-AvmStorageFtpServer { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmStorageFtpServer .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmStorageFtpServer .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.Byte][System.Boolean]$NewFTPEnable = 0 ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:X_AVM-DE_Storage:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_storage" $AvmWebrequestBody.Action = "SetFTPServer" $AvmWebrequestBody.InnerBody = "<s:NewFTPEnable>{0}</s:NewFTPEnable>" -f $NewFTPEnable [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-AvmStorageFtpServerWan { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmStorageFtpServerWan .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmStorageFtpServerWan .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.Byte][System.Boolean]$NewFTPWANEnable = 0, [Parameter()] [System.Byte][System.Boolean]$NewFTPWANSSLOnly = 0 ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:X_AVM-DE_Storage:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_storage" $AvmWebrequestBody.Action = "SetFTPServerWAN" $AvmWebrequestBody.InnerBody = @" <s:NewFTPWANEnable>{0}</s:NewFTPWANEnable> <s:NewFTPWANSSLOnly>{1}</s:NewFTPWANSSLOnly> "@ -f $NewFTPWANEnable, $NewFTPWANSSLOnly [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-AvmStorageSmbServer { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmStorageSmbServer .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmStorageSmbServer .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.Byte][System.Boolean]$NewSMBEnable = 0 ) $AvmWebrequestBody = [AvmBody]::new() $AvmWebrequestBody.SoapAction = "urn:dslforum-org:service:X_AVM-DE_Storage:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_storage" $AvmWebrequestBody.Action = "SetSMBServer" $AvmWebrequestBody.InnerBody = "<s:NewSMBEnable>{0}</s:NewSMBEnable>" -f $NewSMBEnable [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-AvmStorageUserConfig { <# .SYNOPSIS Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmStorageUserConfig .DESCRIPTION Wiki: https://github.com/Gincules/avmtools/wiki/Set-AvmStorageUserConfig .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.Byte][System.Boolean]$NewEnable = 0, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.Security.SecureString]$NewPassword, [Parameter()] [System.Byte][System.Boolean]$NewNetworkAccessReadOnly = 1 ) if ($NewEnable -eq 0) { $NewNetworkAccessReadOnly = 1 } $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_Storage:1" $AvmWebrequestBody.UrlPath = "$(if ($RemoteAccess) { "/tr064" })/upnp/control/x_storage" $AvmWebrequestBody.Action = "SetUserConfig" $AvmWebrequestBody.InnerBody = @" <s:NewEnable>{0}</s:NewEnable> <s:NewPassword>{1}</s:NewPassword> <s:NewX_AVM-DE_NetworkAccessReadOnly>{2}</s:NewX_AVM-DE_NetworkAccessReadOnly> "@ -f $NewEnable, $PlainNewPassword, $NewNetworkAccessReadOnly [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 } |