public/Add-CloudServer.ps1

<#PSScriptInfo
 
.VERSION 1.0.0.0
 
.GUID 84c791fa-4e4a-43ce-9b9c-89bd6442f451
 
.AUTHOR Mikail Aras - Meta10
 
.COMPANYNAME Meta10
 
.COPYRIGHT (C) 2024 by Meta10 - Alle Rechte vorbehalten
 
.TAGS Script PowerSHELL function_connect_exchangeonline_unattended
 
.LICENSEURI
 
.PROJECTURI
 
.ICONURI
 
.EXTERNALMODULEDEPENDENCIES
 
.REQUIREDSCRIPTS
 
.EXTERNALSCRIPTDEPENDENCIES
 
.RELEASENOTES
Aenderungsverlauf des Scripts nach dem Schema Major.Minor.Build.Revision,jeweils Major Versionen sind produktiv zu verwenden
Version |Type |Datum |Benutzer |Bemerkungen
1.0.0.0 |BUILD |2024.01.29 |mike |Script erstellt.
 
.PRIVATEDATA
 
#>


<# Requires -Module powershell crm classes #>

<#
 
.DESCRIPTION
add new crm server to customer
 
#>


function Add-CloudServer {
    param(
        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$Name,

        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$CustomerName

    )

    $logal = [system.collections.arraylist]::new() # log arraylist

    if(Test-CCCRMConnection){
        if($name){
            $cloudserver = [CloudServer]::New($Name, 'active')

            if($cloudserver.name){
                $error.clear()

                try{
                    $cloudserver.AssignCustomer($customername)
                    write-host "added server $($name) to cloud customer $($customername)" -foregroundcolor 'yellow'

                }catch{
                    write-error -message "couldnt add server $($name) to cloud customer $($customername) due to following error $($error[-1].exception)"

                } # end of try catch block
            } # end of if crmserver

            #$null = $logal.add("configured dns client server address for interface alias $($ethif) with server addresses $($args[2]) and $($args[3])")
        } # end of if computername

        $logal

        foreach($log in $output){
            #write-customlog -path $pathtolog -message $log -level 'info'

        } # end of foreach
    }
} # end of function