PowerShell script exchange
jcolonfzenpr
Enthusiast
Posts: 53 Liked: 33 times
Joined: Dec 30, 2021 1:16 am
Full Name: Jonathan Colon
Location: Puerto Rico
Contact:
Post
by jcolonfzenpr » Jul 22, 2022 12:24 am
this post
Hello again,
I am working on a diagramming tool for veeam backup and replication using powershell, psgraph and graphviz. So now I am in the process of building the backup proxy infrastructure diagram and I want to know if there is any way to get the vsphere infrastructure hierarchy information through the veeam powershell module. I know I can use Powercli but I want to simplify the code and dependencies.
Currently I can get the information about vcenter, esxi host etc. but I need to know if it is possible to get the full hierarchy (Datacenter, Cluster, Resources Pool etc..).
Any help would be greatly appreciated.
Veeam VBR Backup Proxies *WIP*
Other Examples:
Veeam VBR SOBR:
Veeam VBR Backup Repository:
Veeam VBR Wan Accel:
Jonathan Colon
https://techmyth.blog/
HannesK
Product Manager
Posts: 15146 Liked: 3242 times
Joined: Sep 01, 2014 11:46 am
Full Name: Hannes Kasparick
Location: Austria
Contact:
Post
by HannesK » Jul 22, 2022 5:44 am
this post
Hello,
first of all: fancy output
I know I can use Powercli
looking at the Veeam
PowerShell reference , PowerCLI is the way to go.
Best regards,
Hannes
Eamonn Deering
Service Provider
Posts: 33 Liked: 4 times
Joined: Feb 29, 2012 1:42 pm
Full Name: EamonnD
Location: Dublin, Ireland
Contact:
Post
by Eamonn Deering » Aug 01, 2022 7:24 pm
2 people like this post
Hi jcolonfzenpr
Perhaps something in this basic script might help or point you in some direction.
Might need some testing/validation/optimization/dev/corrections etc..
Code: Select all
#####################################################
# Eamonn Deering
# A quick attempt to gather vCenter info through Veeam
# 01082022
#
#####################################################
# Eamonn Deering
# A quick attempt to garther vCenter info through Veeam
# 01082022
#
#Create an array
$vCenterServers = @()
# Collect all the vCenter servers mapped to this VBR
$vCenterServers= Get-VBRServer -Type vc
# Display all the vCenter names
Write-Host ""
Write-Host "vCenter Names "
Write-Host "----------------------------"
$vCenterServers.name
# Display systems connected to each vcenter
Foreach ($vCenter in $vCenterServers){
$VMs = Find-VBRViEntity -server $vCenter | where {($_.type -eq "vm")}
$ESXis = Find-VBRViEntity -server $vCenter | where {($_.type -eq "esx")}
$Clusters = Find-VBRViEntity -server $vCenter | where {($_.type -eq "cluster")}
Write-Host ""
Write-Host "vCenter Name "
Write-Host "----------------------------"
$vCenter.name |sort
Write-Host ""
Write-Host "Cluster's in this vCenter "
Write-Host "---------"
$Clusters.Name |sort
$Datastores = Find-VBRViEntity -Server $vCenter -DatastoresAndVMs | where {($_.type -eq "Datastore")}
Write-Host ""
Write-Host "Datastor Names in the vCenter "
Write-Host "--------------"
$Datastores.Name |sort
Write-Host ""
Write-Host "ResourcePools in the vCenter "
Write-Host "--------------"
$ResourcePools = Find-VBRViEntity -Server $vCenter -ResourcePools | where {($_.type -eq "ResourcePool")}|sort path
$ResourcePools | Select Name, Path |Ft
<#
Write-Host ""
Write-Host "ESXi Hosts"
$ESXis.Name |sort
Write-Host ""
#Write-Host "VM Names"
#$Vms.Name
#Write-Host ""
#>
}
foreach ($cluster in $Clusters){
Write-Host " "
Write-Host " "
Write-Host "Cluster Name "
Write-Host "------------ "
$cluster.name
Write-Host ""
Write-Host "ResourcePools in the Cluster "
Write-Host "----------------------------"
$ResourcePools.path -match $cluster.Name |Sort
# Datastore path does not list the Cluster
#Write-Host ""
#Write-Host "Datastor Names in the Cluster "
#Write-Host "--------------"
#$Datastores.path -match $cluster.Name |sort
$ClusterESXis =$ESxis.path -match $cluster.name |sort
$x=1
Foreach ($ESXi in $ClusterESXis |sort){ #$ESXi.split("\")[-1]
Write-Host ""
Write-Host "ESXi Servers in this cluster "$x " Of " $ClusterESXis.count
Write-Host "----------------------------"
$x++
Write-Host ""
Write-Host $ESXi.split("\")[-1]
#$PowerOnVMs = Find-VBRViEntity -server $vCenter | where {($_.VmHostName -match $ESXi.split("\")[-1])} | where {($_.PowerState -eq "PoweredON")}
#$PowerOffVMs = Find-VBRViEntity -server $vCenter | where {($_.VmHostName -match $ESXi.split("\")[-1])} | where {($_.PowerState -eq "PoweredOff")}
$PowerOnVMs = $VMs | where {($_.VmHostName -match $ESXi.split("\")[-1])} | where {($_.PowerState -eq "PoweredON")}
$PowerOffVMs = $VMs | where {($_.VmHostName -match $ESXi.split("\")[-1])} | where {($_.PowerState -eq "PoweredOff")}
Write-host ""
Write-host "Powered on VM's"
Write-Host "----------------"
$PowerOnVMs.name |sort
Write-host ""
Write-host "Powered Off VM's"
Write-Host "----------------"
$PowerOffVMs.name |sort
}
}
##############################################
#Edited by MOD: added /code Tags for visability
jcolonfzenpr
Enthusiast
Posts: 53 Liked: 33 times
Joined: Dec 30, 2021 1:16 am
Full Name: Jonathan Colon
Location: Puerto Rico
Contact:
Post
by jcolonfzenpr » Aug 08, 2022 9:27 pm
this post
Thanks.
This is a good example of the difference between software development and software engineering.
Engineering is the ability to provide solutions to complex problems.
Nice catch!
Jonathan Colon
https://techmyth.blog/
Users browsing this forum: No registered users and 7 guests