PowerShell script exchange
Post Reply
EdgarRicharte
Enthusiast
Posts: 77
Liked: 12 times
Joined: Jul 17, 2019 10:06 pm
Contact:

Enable Insider Protection for all tenants

Post by EdgarRicharte »

Hello,

Anyone have a powershell script to enable insider protection for all tenants. I tried:
SetVBRCloudTenant -BackupProtectionEnabled: $True

But it would ask for a cloud tenant. I type in the tenant name. But would give me an error. Contacted veeam support but they advised it was out of their scope unfortunately. I could've sworn I saw a similar thread on these forums a while ago. But am unable to find it. Ty for any help!

Rather do it through powershell. Instead of going through each company and manually enabling.thanks again!
mzollmann
Veeam Software
Posts: 37
Liked: 19 times
Joined: Mar 01, 2017 2:10 pm
Full Name: Mike Zollmann
Contact:

Re: Enable Insider Protection for all tenants

Post by mzollmann »

Please post the Case ID so we can review.
Mike Zollmann
Manager, System Engineering - VCSP
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Enable Insider Protection for all tenants

Post by jhoughes »

It's because you are not giving it a CloudTenant object as required.

If you have the tenant name, you can do this:

Code: Select all

$tenant = Get-VBRCloudTenant -Name 'tenantname'
Set-VBRCloudTenant -CloudTenant $tenant -EnableBackupProtection: $True
This is similar to all of the examples listed at the bottom of the doc for the Set-VBRCloudTenant cmdlet.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
EdgarRicharte
Enthusiast
Posts: 77
Liked: 12 times
Joined: Jul 17, 2019 10:06 pm
Contact:

Re: Enable Insider Protection for all tenants

Post by EdgarRicharte »

Case #04478442

I know how to do it individually. I was hoping someone could paste a script that I could use to enable it for all tenants en masse. I've done it before. But it was over a year ago. And I can no longer find the script.
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Enable Insider Protection for all tenants

Post by jhoughes »

You just need to get all tenants and then wrap that same code in a foreach loop.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
Mildur
Product Manager
Posts: 9848
Liked: 2609 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Enable Insider Protection for all tenants

Post by Mildur » 3 people like this post

I have found somewhere this script last Juli.
It’s possible, that is from the veeam powershell github site:

Code: Select all

# Enables Insider Protection and configures a default value.
# Does not reduce the period manually set on any given tenant.

$DefaultNumberOfProtectedDays = 7

Add-PSSnapin VeeamPSSnapIn

# Finds all tenants where Insider Protection is disabled, and enables it, with the number of days defined above.
Get-VBRCloudTenant | Where-Object -Property BackupProtectionEnabled -EQ $false | Set-VBRCloudTenant -EnableBackupProtection: $true -BackupProtectionPeriod $DefaultNumberOfProtectedDays 

# Finds all tenants where Insider Protection's protection period is less than the default value, and raises it to the default.
Get-VBRCloudTenant | Where-Object -Property BackupProtectionPeriod -LT $DefaultNumberOfProtectedDays | Set-VBRCloudTenant -BackupProtectionPeriod $DefaultNumberOfProtectedDays
Product Management Analyst @ Veeam Software
EdgarRicharte
Enthusiast
Posts: 77
Liked: 12 times
Joined: Jul 17, 2019 10:06 pm
Contact:

Re: Enable Insider Protection for all tenants

Post by EdgarRicharte » 1 person likes this post

TYVM @mildur that worked perfectly.
EdgarRicharte
Enthusiast
Posts: 77
Liked: 12 times
Joined: Jul 17, 2019 10:06 pm
Contact:

Re: Enable Insider Protection for all tenants

Post by EdgarRicharte »

So since this is now a module instead of of a snapin. May I get some help again please :) ?
Updated Add-PSSnapin VeeamPSSnapIn to be "Import-Module Veeam.Backup.PowerShell" in the above script:

Code: Select all

# Enables Insider Protection and configures a default value.
# Does not reduce the period manually set on any given tenant.

$DefaultNumberOfProtectedDays = 7

Import-Module Veeam.Backup.PowerShell

# Finds all tenants where Insider Protection is disabled, and enables it, with the number of days defined above.
Get-VBRCloudTenant | Where-Object -Property BackupProtectionEnabled -EQ $false | Set-VBRCloudTenant -EnableBackupProtection: $true -BackupProtectionPeriod $DefaultNumberOfProtectedDays 
But I now get the following warning:

Code: Select all

WARNING: The names of some imported commands from the module 'Veeam.Backup.PowerShell' include unapproved verbs that might make them less discoverable. To find the commands with 
unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
Is there any way to suppress the warning? Thank you for any help in advanced!
Mildur
Product Manager
Posts: 9848
Liked: 2609 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Enable Insider Protection for all tenants

Post by Mildur »

Have a look here:
https://www.vblog.nl/veeam-v11-powershe ... -warnings/

I can‘t test it at the moment. But it looks like a solution to me for the problem:
This is because the Veeam Powershell module is not in the default paths so you can add some lines to you scripts to fix this issue:
$VeeamModulePath = “C:\Program Files\Veeam\Backup and Replication\Console”
$env:PSModulePath = $env:PSModulePath + “$([System.IO.Path]::PathSeparator)$VeeamModulePath”
Import-Module -DisableNameChecking Veeam.Backup.PowerShell
Product Management Analyst @ Veeam Software
oleg.feoktistov
Veeam Software
Posts: 2011
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Enable Insider Protection for all tenants

Post by oleg.feoktistov » 1 person likes this post

This warning has nothing to do with the module path not being in $env:PSModulePath variable. It appears whenever a module has verbs not presented in this list and thus considered unapproved. But that's just an indication, the complete module is still imported. To suppress this warning, import ps module with the parameter below:

Code: Select all

Import-Module Veeam.Backup.Powershell -DisableNameChecking
For more information see this MS article.

Thanks!
Mildur
Product Manager
Posts: 9848
Liked: 2609 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Enable Insider Protection for all tenants

Post by Mildur »

Thanks Oleg :)
Product Management Analyst @ Veeam Software
EdgarRicharte
Enthusiast
Posts: 77
Liked: 12 times
Joined: Jul 17, 2019 10:06 pm
Contact:

Re: Enable Insider Protection for all tenants

Post by EdgarRicharte »

That fixed it. Tyvm everyone!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 9 guests