Public/ManagementClientProfiles/Copy-ManagementClientProfile.ps1
#Requires -Modules 'MilestonePSTools' function Copy-ManagementClientProfile { <# .SYNOPSIS Adds a new Management Client Profile based on the Default profile or a given Management Client Profile .DESCRIPTION Adds a new Management Client Profile based on the Default profile or a given Management Client Profile, effectively copying an existing profile. .EXAMPLE PS C:\> Add-ManagementClientProfile -Name 'Remote Guards' -Description 'Management Client Profile for Remote Guard users with limited access' Creates a new Management Client Profile named 'Remote Guards' .OUTPUTS The output of this function will be a [VideoOS.Management.VmoClient.ManagementClientProfile] object with the following properties: Name : Remote Guard Description : LastModified : 1/22/2021 7:59:12 PM SettingsXml : <Settings> <Setting key="SettingKeyName"> <Value>Example</Value> <Locked>False</Locked> </Setting> </Settings> IsDefaultProfile : False AttachedRoles : {} Id : e73e6ddf-8493-48e9-8e48-04b36023538d IsDirty : False IsCreated : True IsDeleted : False Exists : True CustomProperties : {} IsCustomPropertiesSupported : True ServerVersion : 20.3.1 #> [CmdletBinding()] param( # Specifies the description for the new Management Client Profile [Parameter(Mandatory, ValueFromPipeline)] [VideoOS.Management.VmoClient.ManagementClientProfile] $SourceProfile, # Specifies the display name the new Management Client Profile [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string] $Name, # Specifies the description for the new Management Client Profile [Parameter()] [ValidateNotNullOrEmpty()] [string] $Description ) begin { $vmo = Get-VmoClient } process { try { Write-Verbose "Creating a new Management Client Profile based on profile '$($SourceProfile.Name)'" $newProfile = [VideoOS.Management.VmoClient.ManagementClientProfile]::new($vmo.ManagementServer) $newProfile.Name = $Name $newProfile.Description = $Description $newProfile.SettingsXml = $SourceProfile.SettingsXml $newProfile.Create() if ($newProfile.IsCreated) { Write-Output $newProfile } } catch { $vmo.Dispose() throw } } end { $vmo.Dispose() } } |