public/New-CloudCustomer.ps1

<#PSScriptInfo
 
.VERSION 1.0.0.0
 
.GUID b5b02624-ec6c-4b79-ad7a-815bca7facca
 
.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 New-CloudCustomer {
    param(
        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$Name

    )

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

    if(Test-CCCRMConnection){
        if($name){
            $cloudcustomer = [cloudcustomer]::new()

            if($cloudcustomer){
                $error.clear()

                try{
                    $cloudcustomer.newcustomer($name) # new cloud customer
                    $null = $cloudcustomer.RemoveCustomerResponsibleUser() # remove responsible user
                    $null = $cloudcustomer.RemoveCustomerBilling() # set rechnungslauf to false
                    write-host "created cloud customer with following name $($name)" -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