MyVeeamReport exclude Folders

PowerShell script exchange

MyVeeamReport exclude Folders

Veeam Logoby sebastien22 » Thu Aug 07, 2014 9:20 am

Hello
Excuse me for my english

I use the script smasterson MyVeeamReport.ps1
(https://gist.github.com/smasterson/9136 ... report-ps1)


But excluding folders does not work or simply for a folder,
you have an idea for multiples folders ?

# To Exclude Missing VMs from VM Backups report add names to be excluded as follows
# $ @ = Excludevms ("vm1", "vm2", "* _replica")
$ @ excludeVMs = ("")
# Exclude Missing VMs from backups report in the following (vCenter) folder
folderExclude $ = ""


folderExclude $ = "No_backup" = OK
folderExclude $ = "No_backup,No_backup_citrix" = KO
folderExclude $ = "No_backup","No_backup_citrix" = KO
folderExclude $ = "No_backup" "No_backup_citrix" = KO

Thank you in advance
sebastien22
Novice
 
Posts: 5
Liked: never
Joined: Thu Aug 07, 2014 9:06 am
Full Name: Sebastien

Re: MyVeeamReport exclude Folders

Veeam Logoby v.Eremin » Thu Aug 07, 2014 9:24 am

But excluding folders does not work or simply for a folder, you have an idea for multiples folders ?

Can you elaborate on that? You mean the script can only exclude VMs coming from one folder, not multiple ones? Thanks.
v.Eremin
Veeam Software
 
Posts: 13290
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: MyVeeamReport exclude Folders

Veeam Logoby sebastien22 » Thu Aug 07, 2014 10:08 am

hello

No, it is the exclusion of a complete folder in datacenter , with one folder it works, but not with more

Exemple :

# Exclude Missing VMs from backups report in the following (vCenter) folder
folderExclude $ = ""

folderExclude $ = "No_backup" = OK ( all VM in folder is exclude )

But with multiples folders in variables , dont work

folderExclude $ = "No_backup,No_backup_citrix" = KO
folderExclude $ = "No_backup","No_backup_citrix" = KO
folderExclude $ = "No_backup" "No_backup_citrix" = KO


thanks
sebastien22
Novice
 
Posts: 5
Liked: never
Joined: Thu Aug 07, 2014 9:06 am
Full Name: Sebastien

Re: MyVeeamReport exclude Folders

Veeam Logoby nefes » Thu Aug 07, 2014 10:10 am

Could you try
Code: Select all
$folderExclude = @("No_backup", "No_backup_citrix")
?
It will create an array with two elements rather than one big string
nefes
Veeam Software
 
Posts: 534
Liked: 125 times
Joined: Mon Dec 10, 2012 8:44 am
Full Name: Nikita Efes

Re: MyVeeamReport exclude Folders

Veeam Logoby sebastien22 » Thu Aug 07, 2014 11:33 am

hello

I also tested the same result.

$folderExclude = @("No_backup", "No_backup_citrix")



If I place a folder OK, as soon as there are at least two, it does not work.

The folder name is good, one by one is OK

Thanks
sebastien22
Novice
 
Posts: 5
Liked: never
Joined: Thu Aug 07, 2014 9:06 am
Full Name: Sebastien

Re: MyVeeamReport exclude Folders

Veeam Logoby v.Eremin » Thu Aug 07, 2014 11:48 am

Then, some sort of cycle seems to be required within the script provided. Based on your description, currently script can only exclude only one folder. So, you will have to add cycle to the script. Within the cycle specified folders will be taken and excluded one by one. Thanks.
v.Eremin
Veeam Software
 
Posts: 13290
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: MyVeeamReport exclude Folders

Veeam Logoby nefes » Thu Aug 07, 2014 2:22 pm

After some reading of the script you linked, seems that I find the reason. The string 443
Code: Select all
$vmobjs = Find-VBRObject -Server $vcenterobj | Where-Object {$_.Type -eq "VirtualMachine" -and $_.VMFolderName -notlike $script:folderExclude}

should be changed to
Code: Select all
$vmobjs = Find-VBRObject -Server $vcenterobj | Where-Object {$_.Type -eq "VirtualMachine" -and $_.VMFolderName -notin $script:folderExclude}


After that $folderExclude = @("No_backup", "No_backup_citrix") should work. Please be aware, this search is case-specific ("no_backup" folder will not be excluded)
nefes
Veeam Software
 
Posts: 534
Liked: 125 times
Joined: Mon Dec 10, 2012 8:44 am
Full Name: Nikita Efes

Re: MyVeeamReport exclude Folders

Veeam Logoby sebastien22 » Fri Aug 08, 2014 7:12 am

Hello ,

Thank you for your help.

I'm testing, but following the change

Code: Select all
PS C:\Users\root> U:\prc\veeam\Rapport_Veeam_Quotidien.ps1
Vous devez fournir une expression de valeur à droite de l'opérateur « - ».   ( You must provide a value expression on the right of the "-" operator. )
Au niveau de U:\prc\veeam\Rapport_Veeam_Quotidien.ps1 : 362 Caractère : 114
+     $vmobjs = Find-VBRObject -Server $vcenterobj | Where-Object {$_.Type -eq "VirtualMachine" -and $_.VMFolderName - <<<< notin $script:folderExclude}
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : ExpectedValueExpression



Thanks
sebastien22
Novice
 
Posts: 5
Liked: never
Joined: Thu Aug 07, 2014 9:06 am
Full Name: Sebastien

Re: MyVeeamReport exclude Folders

Veeam Logoby nefes » Fri Aug 08, 2014 3:39 pm

Seems that "-notin" comparator is presented only in PowerShell 3.0
If you want to use Powershell 2.0, you could try "-notcontains", but you should switch places of parameters:
Code: Select all
$vmobjs = Find-VBRObject -Server $vcenterobj | Where-Object {$_.Type -eq "VirtualMachine" -and $script:folderExclude -notcontains $_.VMFolderName}
nefes
Veeam Software
 
Posts: 534
Liked: 125 times
Joined: Mon Dec 10, 2012 8:44 am
Full Name: Nikita Efes

Re: MyVeeamReport exclude Folders

Veeam Logoby sebastien22 » Wed Aug 13, 2014 8:13 am

Hello

Thank you very much for your quick response, it works fine, I tested with ten records and perfect.


And Shawn Masterson offered me this solution also works great


On line 21
Code: Select all
$folderExclude = ""


Separate multiple folders with a | like so
Code: Select all
$folderExclude = "folder1|folder2|folder3"



On line 443
Code: Select all
$vmobjs = Find-VBRObject -Server $vcenterobj | Where-Object {$_.Type -eq "VirtualMachine" -and $_.VMFolderName -notlike $script:folderExclude}


Lets change this from -notlike to -notmatch
Code: Select all
$vmobjs = Find-VBRObject -Server $vcenterobj | Where-Object {$_.Type -eq "VirtualMachine" -and $_.VMFolderName -notmatch $script:folderExclude}





Thank you again
sebastien22
Novice
 
Posts: 5
Liked: never
Joined: Thu Aug 07, 2014 9:06 am
Full Name: Sebastien


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 9 guests