public/Add-CloudCompany.ps1

<#PSScriptInfo
 
.VERSION 1.0.0.0
 
.GUID 273a4543-b536-4b27-a7b7-e9e41d49789f
 
.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 crm classes #>

<#
 
.DESCRIPTION
new cloud customer
 
#>


function Add-CloudCompany {
    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){
            $account = [account]::new($name)

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

                try{
                    $account = $account.assigncustomer($customername) # new cloud company
                    write-host "added cloud company $($name) to following cloud customer $($customername)" -foregroundcolor 'yellow'

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

                } # end of try catch block
            } # end of if primary server

            #$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