public/Get-CloudAccountAmountWrapper.ps1

<#PSScriptInfo
 
.VERSION 1.0.0.0
 
.GUID 3f2f3721-e35f-4d9b-a84f-fc200f40d30e
 
.AUTHOR Mikail Aras - Meta10
 
.COMPANYNAME Meta10
 
.COPYRIGHT (C) 2024 by Meta10 - Alle Rechte vorbehalten
 
.TAGS Script PowerSHELL get-cloudaccountamountwrapper
 
.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.07.28 |mike |Script erstellt.
 
.PRIVATEDATA
 
#>


<# Requires -Module none #>

<#
 
.DESCRIPTION
get cloud accounts and choose how many users it will use for cpu and ram sizing
 
#>


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

    )

    . ""$($PSScriptRoot)\Automation\"init-session.ps1"

    $additionalmodules = [system.collections.generic.list[string]]::new()
    $additionalmodules.add("D:\CEC\script\Get-CloudCustomer.ps1")

    foreach($additionalmodule in $additionalmodules){
        #Unblock-File -Path $additionalmodule
        import-module -name $additionalmodule -force
        write-host "importing module $($additionalmodule)" -ForegroundColor Green

    }

    $cloudcustomer = get-cloudcustomer -name $customername

    if($cloudcustomer){
        $cloudaccounts = ($cloudcustomer.CloudAccounts()).where({$_.ende -eq $null -and ('named user', 'test user') -contains $_.type -and $_.statecode -eq 'active'}).where({$_.loginname -match $cloudcustomer.accountnumber})

        if($cloudaccounts){
            if($cloudaccounts.count -gt 10){ # max user amount per session host is 10
                [byte]$useramount = 10

            }else{
                [byte]$useramount = $cloudaccounts.count # if less than 10, set the actual size

            } # end of if cloudaccounts

            if($useramount.count -ne 0){
                $useramount

            }else{
                [byte]$useramount = 2
                $useramount

            } # end of if useramount count
        }else{
            write-warning -message "couldnt find cloud accounts for following customer $($customername)"

        } # end of if cloudaccounts
    }else{
        write-warning -message "cloudcustomer with name $($CustomerName) not found"

    } # end of if cloudcustomer
}