Update
This commit is contained in:
2
Testing/hyperv_list
Normal file
2
Testing/hyperv_list
Normal file
@ -0,0 +1,2 @@
|
||||
host1
|
||||
host2 host3
|
@ -1 +1,72 @@
|
||||
## For example
|
||||
# Author: Oriol Filter
|
||||
# Date: 04/04/2022
|
||||
|
||||
|
||||
|
||||
$SCRIPT_PATH=$PSScriptRoot
|
||||
|
||||
## Objects
|
||||
|
||||
class VirtualizationServer {
|
||||
[string]$URL
|
||||
[bool]$Authenticated=$false
|
||||
}
|
||||
|
||||
class HypervServer: VirtualizationServer{}
|
||||
class VMWareServer: VirtualizationServer{}
|
||||
|
||||
|
||||
# Get hyperv's
|
||||
filter Get-Hyperv
|
||||
{
|
||||
|
||||
$HYPERV_FILE = "$SCRIPT_PATH/hyperv_list"
|
||||
|
||||
## In a future use a yaml as a .conf (with the hyperv and vmware listed)
|
||||
#$__HYPERV_FILE = Get-Content "$_SCRIPT_PATH"
|
||||
$HYPERV_FILE = "host1
|
||||
host2 host3"
|
||||
|
||||
|
||||
$HYPERV_LIST = $HYPERV_FILE.Split()
|
||||
|
||||
|
||||
$HYPERV_ARRAY=@()
|
||||
# $i=0
|
||||
foreach ($url in $HYPERV_LIST)
|
||||
{
|
||||
if ($url)
|
||||
{
|
||||
[HypervServer]$new_hyerv=[HypervServer]::new()
|
||||
$new_hyerv.URL=$url
|
||||
$HYPERV_ARRAY+=$new_hyerv
|
||||
# $i++
|
||||
}
|
||||
}
|
||||
return $HYPERV_ARRAY
|
||||
}
|
||||
|
||||
function Check-Hyperv-Servers($hv_arr) {
|
||||
foreach ($connection in $hv_arr)
|
||||
{
|
||||
$connection.cla
|
||||
}
|
||||
}
|
||||
|
||||
function Print-Connections-Status($vs_arr) {
|
||||
foreach ($connection in $vs_arr)
|
||||
{
|
||||
$connection
|
||||
}
|
||||
}
|
||||
|
||||
$hyperv_arr=Get-Hyperv
|
||||
#$hyperv_arr.GetType()
|
||||
|
||||
Print-Connections-Status($hyperv_arr)
|
||||
#echo "1"
|
||||
|
||||
|
||||
|
||||
# Advanced params?
|
||||
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-7.2
|
Reference in New Issue
Block a user