Public/func_Add-SSHServer.ps1
function Add-SSHServer { [CmdletBinding()] param ( [Parameter(Position = 0, Mandatory = $true)][string]$Name, [Parameter(Position = 1, Mandatory = $true)][string]$IP, [Parameter(Position = 2, Mandatory = $false)][string[]]$Tags ) [Collections.Generic.List[SSHServer]]$sshServers = Get-SSHServersFile if($null -eq $sshServers) { $sshServers = New-Object Collections.Generic.List[SSHServer] } if($sshServers | Where-Object Name -eq $Name) { Throw New-Object System.ArgumentException("Name already exist") } [SSHServer]$sshServer = New-Object SSHServer $sshServer.Name = $Name $sshServer.IP = $IP $sshServer.Tags = $Tags $sshServers.Add($sshServer) Set-SSHServersFile -SSHServers $sshServers } |