public/Set-CloudServer.ps1
|
<#PSScriptInfo
.VERSION 1.0.0.0 .GUID e12c125d-5cb5-4895-ad04-db6176dee88c .AUTHOR Mikail Aras - Meta10 .COMPANYNAME Meta10 .COPYRIGHT (C) 2023 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 |2023.12.31 |mike |Script erstellt. 1.1.0.0 |BUILD |2025.03.05 |mike |Script erstellt. .PRIVATEDATA #> <# Requires -Module get-hypervisor #> <# .DESCRIPTION set crm server properties with powershell class library #> function Set-CloudServer { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Name, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [ValidateSet("Active", "Inactive")] [string]$State, [Parameter(Mandatory=$false)] [ValidateNotNullOrEmpty()] [string]$PrimaryServer, [Parameter(Mandatory=$false)] [ValidateNotNullOrEmpty()] [string]$ReplicaServer, [Parameter(Mandatory=$false)] [ValidateNotNullOrEmpty()] [string]$ProcessorCount, [Parameter(Mandatory=$false)] [ValidateNotNullOrEmpty()] [double]$MemoryMinimum, [Parameter(Mandatory=$false)] [ValidateNotNullOrEmpty()] [double]$MemoryMaximum ) $logal = [system.collections.arraylist]::new() # log arraylist if(Test-CCCRMConnection){ if($name){ $cloudServer = [CloudServer]::New($name, $state) if($cloudServer.name){ if($primaryserver){ $error.clear() try{ $cloudServer.sethost($primaryserver) write-host "Set primary hypervisor to $($primaryserver) for following computer $($name)" -foregroundcolor 'yellow' }catch{ write-error -message "Couldnt set primary hypervisor to $($primaryserver) for computer $($name) due to following error $($error[-1].exception)" } # end of try catch block } # end of if primaryserver if($replicaserver){ $error.clear() try{ $cloudServer.setreplicationhost($replicaserver) write-host "Set replica hypervisor to $($replicaserver) for following computer $($name)" -foregroundcolor 'yellow' }catch{ write-error -message "Couldnt set replica hypervisor to $($replicaserver) for computer $($name) due to following error $($error[-1].exception)" } # end of try catch block } # end of if replicaserver if($MemoryMinimum){ $error.clear() try{ $cloudServer.SetRam($MemoryMinimum) write-host "Set memory minimum to $($MemoryMinimum) for following computer $($name)" -foregroundcolor 'yellow' }catch{ write-error -message "Couldnt set memory minimum to $($MemoryMinimum) for computer $($name) due to following error $($error[-1].exception)" } # end of try catch block } # end of if memoryminimum if($MemoryMaximum){ $error.clear() try{ $cloudServer.SetRamMax($MemoryMaximum) write-host "Set memory maximum to $($MemoryMaximum) for following computer $($name)" -foregroundcolor 'yellow' }catch{ write-error -message "Couldnt set memory maximum to $($MemoryMaximum) for computer $($name) due to following error $($error[-1].exception)" } # end of try catch block } # end of if memorymaximum if($ProcessorCount){ $error.clear() try{ $cloudServer.SetCpu($ProcessorCount) write-host "Set processor count to $($ProcessorCount) for following computer $($name)" -foregroundcolor 'yellow' }catch{ write-error -message "Couldnt set processor count to $($ProcessorCount) for computer $($name) due to following error $($error[-1].exception)" } # end of try catch block } # end of if memorymaximum }else{ write-warning -message "couldnt find crm server with following name $($name)" } # end of if crmserver name #$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 |