public/cbb/Get-MBSLicense.ps1
function Get-MBSLicense { <# .SYNOPSIS Shows the license information. .DESCRIPTION This cmdlet provides the information about the license used by current MBS user. .PARAMETER MasterPassword Master password. Should be specified if configuration is protected by master password. Use -MasterPassword (ConvertTo-SecureString -string "Your_Password" -AsPlainText -Force) .EXAMPLE PS C:\> Get-MBSLicense Show the license ID and the user using that license. .INPUTS None. .OUTPUTS MBS.Agent.License .NOTES Author: Ivan Skorin .LINK https://kb.msp360.com/managed-backup-service/powershell-module/cmdlets/backup-agent/get-mbslicense/ #> [CmdletBinding()] param ( # Parameter - Master password [Parameter(Mandatory=$false, HelpMessage="Specify Master password. Use -MasterPassword (ConvertTo-SecureString -string ""Your_Password"" -AsPlainText -Force)")] [SecureString] $MasterPassword ) begin { if (-not($CBB = Get-MBSAgent)) { Break } try { if ((Get-MBSAgentSetting -ErrorAction SilentlyContinue).MasterPassword -ne "" -and $null -ne (Get-MBSAgentSetting -ErrorAction SilentlyContinue).MasterPassword -and -not $MasterPassword) { $MasterPassword = Read-Host Master Password -AsSecureString } } catch { } } process { $Arguments = " showLicense" $Result = Start-MBSProcess -CMDPath $CBB.CBBCLIPath -CMDArguments $Arguments -Output json -MasterPassword $MasterPassword if ($result.Result -eq "Success") { Return [MBS.Agent.License]@{ User = $Result.User ID = $Result.ID } } } end { } } |