PowerShell script exchange
Post Reply
matteu
Veeam Legend
Posts: 823
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

NAS configuration

Post by matteu »

Hello,

I would like to find these values for all my NAS :

Name
CacheRepositoryName
CacheRepositoryHost
CacheRepositoryPath
BackupIOControlLevel

Unfortunately the command Get-VBRNasServer return all the share.
Is it possible to have what I want for NAS1 , then NAS2, ... ?

Thanks
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: NAS configuration

Post by david.domask »

Hi matteu,

Maybe you could put an example of what you hope to see manually? I think I get the request, but it's not so clear. In general, if you need to return the results of deeper properties/methods, you need to make a calculated property: https://docs.microsoft.com/en-us/powers ... rshell-7.2

The general format in the Select-Object -Property statement should be:

Code: Select all

$SomeThing | Select-Object -Property @{Name="Some label/name";Expression={($_.SomeProperty.SomeSubProperty)}}
You can shorten Name and Expression to n/e for shorthand.

I think you want something like:

Code: Select all

PS C:\Users\Administrator> foreach($n in $Nases){
$n | select Name, @{name="CacheRepo Name";expression={($_.CacheRepository.Name)}}, @{name="IO Control Level"; expression={($_.BackupIoControlLevel)}}
}


Name                                CacheRepo Name                          IO Control Level
----                                --------------                          ----------------
[myveeamserver] Default Backup Repository (Don't use!!)           Medium
[some internal ip]                      Default Backup Repository (Don't use!!)           Medium
                                    Default Backup Repository (Don't use!!)           Medium
                                    Default Backup Repository (Don't use!!)           Medium
                                    Default Backup Repository (Don't use!!)           Medium
                                    ReFS2                                             Medium
                                    ReFS                                              Medium
                                    ReFS                                              Medium
                                    ReFS                                              Medium
                                    temprepo02                                        Medium
                                    ReFS                                              Medium
                                    ReFS                                              Medium
                                    temprepo02                                        Medium
                                    ReFS                                              Medium
                                    ReFS                                              Medium
                                    ReFS                                              Medium
                                    ReFS                                              Medium
                                    ReFS                                              Medium
                                    temprepo02                                        Medium
Note that depending on if it's added as a host/SMB or NFS share/Filer, the results of Get-VBRNasServer are a little different so you'll need some logic to parse what type you're dealing with. The empty names in my output are all SMB/NFS shares.
David Domask | Product Management: Principal Analyst
matteu
Veeam Legend
Posts: 823
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: NAS configuration

Post by matteu »

Hello,

Thank you for your answer.

I have filer and I have same restult than you, lot of lines I don't want with empty firt column because it's only for my filer shares... The only one I would like is the first one with my filer name.
It's easy for me when type is FileServer because there is only one line
However when type is SANSMB (filer) there are as much object than share. What I would like is only filer host name.

This is a sample of my result :

Code: Select all

Name	    CacheRepositoryName  CacheRepositoryHost	CacheRepositoryPath	   BackupIOControlLevel
srv-veeam 	Backup Repository	 srv-veeam	        	D:\Veeam_Backup	       Medium
            Repo_NAS	         SRP-SRV2  				C:\NASCache	           Medium
            Repo_NAS	         SRP-SRV2  				C:\NASCache	           Medium
            Repo_NAS         	 SRP-SRV2  				C:\NASCache	           Medium
I would like to obtain the Name for all my line and not only for the first one.
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: NAS configuration

Post by david.domask » 1 person likes this post

For NAS Filers (e.g., Netapp or Dell boxes), use the Get-VBRFiler command. They have slightly different properties, but should be familiar and what you want is under the Server property. So you can likely add both the Get-VBRNasServer + Get-VBRFiler output to the same array and as you process the objects, you can do some parsing on Type and if it's not FileServer, then you can decide how to handle it (I suppose maybe for NFS/SMB you'd want to set Path to Name value, but I suppose you can imagine what you want better ;) ) Probably making a Custom Object is a bit easier then and add the NAS Objects to some new list and just print that

Edit:

To clarify, as I see you want to have a name for the SMB/NFS ones, do something in your loop like:

Code: Select all

If($n.Type -ne "FileServer"){
$nName = $n.Path
}
This way you can keep the name column as is for the FileServers, and just set $nName to be $nName = $n.Name for FileServers, and the code then looks like:

Code: Select all

$NasData = @()
Foreach($n in $Nases){
If($n.Type -ne "FileServer"){
$nName = $n.Path
} else {$nName = $n.Name}
$SomeCustomObject = @{
Name = $nName
CacheRepoName = $n.CacheRepository.Name
...
}
$NasData += $SomeCustomObject
}
Example of Get-Filer:

Code: Select all

PS C:\Users\Administrator> $filers= Get-VBRFiler
PS C:\Users\Administrator> $filers[0].Server


Info               : [some netapp filer] (Storage)
ParentId           : 00000000-0000-0000-0000-000000000000
Id                 : aa0ce12f-5b01-4e06-bd95-0d5e9feaf93a
Uid                : aa0ce12f5b014e06bd950d5e9feaf93a
Name               : [some netapp filer]
Reference          :
Description        : Created by DDOM-VEEAM-RB2\Administrator at 5/6/2021 16:29.
IsUnavailable      : False
Type               : SanHost
ApiVersion         : Unknown
PhysHostId         : 00000000-0000-0000-0000-000000000000
ProxyServicesCreds : Veeam.Backup.Common.CCredentials
David Domask | Product Management: Principal Analyst
matteu
Veeam Legend
Posts: 823
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: NAS configuration

Post by matteu »

Hello,

Thank you for your help.
I appreciate it :)

You give me lot of details here and help me to do what I want :)

This is my final result

I know I don't manage all nas type but it's because I can't try all unfortunatly. I will update it when I will face an error :)

Code: Select all

function Get-VeeamNAS
{
    $result=@()
    Write-host "NAS Servers SMB/NFS"
    #NAS SMB/NFS
    $NASServer = Get-VBRNASServer
    foreach ($element in $NASServer)
    {
        if ($element.type -eq "FileServer")
        {
            $name = $element.name
        }
        elseif ($element.type -eq "SANSMB")
        {
            $name = (Get-VBRServer | Where-Object {$_.id -eq $element.id}).info.name
        }
        else
        {
            $name = "Unknown type $($element.type) . Script need to be updated"
        }
        $result+=[pscustomobject]@{
            Name = $name
            Type = $element.type
            CacheRepositoryName = $element.CacheRepository.Name
            CacheRepositoryHost = $element.CacheRepository.Host.Name
            CacheRepositoryPath = $element.CacheRepository.FriendlyPath
            BackupIOControlLevel = $element.BackupIOControlLevel
        }
    }
    #Filers
    Write-host "Filers Servers"
    $FilerServer = Get-VBRFiler
    foreach ($element in $FilerServer)
    {
        $result+=[pscustomobject]@{
            Name = $element.name
            Type = $element.Server.type
            CacheRepositoryName = $element.CacheRepository.Name
            CacheRepositoryHost = $element.CacheRepository.Host.Name
            CacheRepositoryPath = $element.CacheRepository.FriendlyPath
            BackupIOControlLevel = $element.BackupIOControlLevel
        }
    }
    $result
    Write-host "-------------------"
}
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: NAS configuration

Post by david.domask »

Always welcome! And glad I could help.

Your script looks really clean, so hope it helps others :)
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests