public/Get-CloudAccount.ps1

<#PSScriptInfo
 
.VERSION 1.0.0.0
 
.GUID 560d2350-c47e-46c0-ac80-a959cd453b8a
 
.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.10.14 |mike |Script erstellt.
 
.PRIVATEDATA
 
#>


<# Requires -Module crm classes #>

<#
 
.DESCRIPTION
get cloud account
 
#>


function Get-CloudAccount {
    param(
        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$CustomerName,

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

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

    if(Test-CCCRMConnection){
        if($customername -and $username){
            $cloudcustomer = [cloudcustomer]::New($customername)

            if($cloudcustomer.name){
                $cloudaccount = $cloudcustomer.cloudaccounts().where({$_.loginname -eq $username -and $_.statecode -eq 'active'})

                if($cloudaccount.name){
                    $cloudaccount

                }else{
                    write-warning -message "Cloudaccount with following name $($username) not found"

                } # end of if cloudaccount name
            }else{
                write-warning -message "Cloudcustomer with following name $($customername) not found"

            }
        } # end of if computername

        $logal

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

        } # end of foreach
    }
} # end of function