PowerShell script exchange
Post Reply
Andreas Neufert
VP, Product Management
Posts: 6956
Liked: 1472 times
Joined: May 04, 2011 8:36 am
Full Name: Andreas Neufert
Location: Germany
Contact:

Andys scripting corner - Add VMs to job (v6)

Post by Andreas Neufert »

Example script for adding VMs to a job

Start script:
VBRaddVMstoJobYourPowershellscriptexampleStartYourPowershellscript.bat

Code: Select all

@ECHO OFF
REM Veeam                                                                              
REM                                                                                                            
REM Author: Andreas Neufert - Systems Engineer Centrael EMEA (Germany)
REM                                                                                                                                                                                                
REM March 2012                                                                                                 
REM
REM 
REM This script starts a Powershellscript and document what it does in a joblog                                                                                                                                                                            
REM                                                                                                          
REM #################################################################

REM  PowerShell.exe
set powershell=c:\windows\system32\windowspowershell\v1.0\powershell.exe

REM  Set Folder with the VBRaddVMstoJobYourPowershellscriptexample.ps1 in it
set PS1=E:\scripts\


REM Output LOG incl. Folder
set joblog=E:\scripts\VBRaddVMstoJobYourPowershellscriptexample.log


REM ###################################################################
"%powershell%" "%PS1%VBRaddVMstoJobYourPowershellscriptexample.ps1" >> "%joblog%"

Your code example:
VBRaddVMstoJobYourPowershellscriptexample.ps1

Code: Select all

 
$JobName = "ad"
$vcenter = "vcenter.demolab.an.veeam.de"
$VMs = "Exchange3","fileserver2"
./VBRaddVMstoJob.ps1 $JobName $vcenter $VMs
Program code:
VBRaddVMstoJob.ps1

Code: Select all

#############################################################################################################
#                                                                                                           
# Veeam                                                                              
#                                                                                                           
# Author: Andreas Neufert - Systems Engineer Central EMEA (Germany)                                                                                   
#                                                                                                           
# March 2012
#
# Version 1.01                                                                                                
#                                                                                                           
# ./VBRaddVMstoJob.ps1 <object:vbrjobname> <object:vcenter> <objects:VMs>
#
# This script adds VMs to Backup & Replication Jobs                                                                                                                                                                          
#                                                                          
#                                                                                                           
#############################################################################################################
#Manual Input (delete # in front of the next 3 lines)
#$vbrjobname = "ad"
#$vcenter= "vcenter.demolab.an.veeam.de"
#$VMs = "Exchange3","fileserver2"
#############################################################################################################
# External Input
$vbrjobname = $args[0]
$vcenter = $args[1]
$servers = $args[2]
#############################################################################################################
# Empty lines to see every code in the powershellwindow (jup under Powershellprozessing bar)
Write-host ". "
Write-host ". "
Write-host ". "
Write-host ". "
Write-host ". "
Write-host ". "
Write-host ". "
Write-host ". "
Write-host ". "
Write-host ". "
Write-host ". "

#Loads Veeam Powershell Snapin
Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue

#Reset Error Counter
$Resultcounter = 0

#Write informations with timestamps
$5Time = get-date
$5TimeFormated = $5Time.ToUniversalTime()
Write-host $5TimeFormated "Information: VBRaddVMstoJob.ps1"
$AStartTime = get-date
$AStartTimeFormated = $AStartTime.ToUniversalTime()
write-host $AStartTimeFormated "Information: Start time:" $AStartTimeFormated
$6Time = get-date
$6TimeFormated = $6Time.ToUniversalTime()
write-host $6TimeFormated "Information: Adding VMs" $servers " from VCenter/ESX" $vcenter " to Job: " $vbrjobname


#Load Job object and check if it exists
$vbrjob = Get-VBRJob | Where {$_.Name -eq $vbrjobname}
if  ($vbrjob -eq $Null)  {
$resultcounter++
$1Time = get-date
$1TimeFormated = $1Time.ToUniversalTime()
Write-host $1TimeFormated "Error: Jobname not correct. Jobname: " $vbrjobname
} Else {
$2Time = get-date
$2TimeFormated = $2Time.ToUniversalTime()
Write-host $2TimeFormated "Information: Jobname name accepted. Jobname: " $vbrjobname


#Load vcenter/esx object and check if it exists
$vbrserverVC = Get-VBRServer | where {$_.Name -eq $vcenter}
if  ($vbrserverVC -eq $Null)  {
$resultcounter++
$3Time = get-date
$3TimeFormated = $3Time.ToUniversalTime()
Write-host $3TimeFormated "Error: vcenter/ESX name not correct. vcenter/ESX: " $vcenter
} Else {
$4Time = get-date
$4TimeFormated = $4Time.ToUniversalTime()
Write-host $4TimeFormated "Information: vcenter/ESX name accepted. vcenter/ESX: " $vcenter


    #Loop for every VM
    foreach ($vm1 in $servers){
    $BStartTime = get-date
    $BStartTimeFormated = $BStartTime.ToUniversalTime()
    write-host $BStartTimeFormated "Information: Processing: " $vm1
    
    #Load VM object and check if it exists
    $vbrobjects = Find-VBRObject $vbrserverVC | ?{$_.name -eq $vm1}
    if  ($vbrobjects -eq $Null)  {
    $resultcounter++
    $7Time = get-date
    $7TimeFormated = $7Time.ToUniversalTime()
    Write-host $7TimeFormated "Error: VM does not exist. VM Name: " $vm1
    } Else {
        $8Time = get-date
        $8TimeFormated = $8Time.ToUniversalTime()
        Write-host $8TimeFormated "Information: VM exists. VM Name: " $vm1
        
        #Add VM to Job
        Add-VBRJobObject -Job $vbrjob -Server $vbrserverVC -Object $vbrobjects
        
        #Load Job obects and check if VM was successfully added
        $tt = Get-VBRJob -Name $vbrjobname | Get-VBRJobObject | where {$_.name -eq $vm1}
        $erg = $vm1 -match $tt.Name
        $9Time = get-date
        $9TimeFormated = $9Time.ToUniversalTime()        
        write-host $9TimeFormated "Information: Proofcheck result:" $erg
        $BEndTime = get-date
        $BEndTimeFormated = $BEndTime.ToUniversalTime()
        write-host $BEndTimeFormated "Information: Finished Processing: " $vm1
        IF ($erg -eq "True")
        {
        $10Time = get-date
        $10TimeFormated = $10Time.ToUniversalTime()
        write-host $10TimeFormated "Information: Successfully added: " $vm1
        }
        ELSE
        {
        $11Time = get-date
        $11TimeFormated = $11Time.ToUniversalTime()
        write-host $11TimeFormated "Error: " $vm1 "not added to job " $vbrjobname
        $resultcounter++
        write-host $11TimeFormated "Error: Errors since now: "$resultcounter
        }
        write-host "----------------------------------------------------------"
        } 
    }
#End if  ($vbrserverVC -eq $Null) 
}
#End ($vbrjob.TotalItemSize -eq $Null) 
}

#Results
IF ($Resultcounter -lt 1)
{
write-host "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
write-host "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
write-host "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
write-host "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" 
write-host "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" 
write-host "Information: Job Finished"    
write-host $servers "where added successfully to job: " $vbrjobname
$AEndTime = get-date
$AEndTimeFormated = $AEndTime.ToUniversalTime()
Write-host "Job started at " $AStartTimeFormated
Write-host "Job finished at " $AEndTimeFormated
write-host "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
write-host "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
}
ELSE
{
write-host "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
write-host "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
write-host "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
write-host "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" 
write-host "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
$AEndTime = get-date
$AEndTimeFormated = $AEndTime.ToUniversalTime()
Write-host $AEndTimeFormated "Information: ERROR ERROR ERROR ERROR ERROR ERROR ERROR"
Write-host $AEndTimeFormated "Information: Job Finished with Errors"
Write-host $AEndTimeFormated "Error: There are " $Resultcounter "Errors"
Write-host $AEndTimeFormated "Information: Job started at " $AStartTimeFormated
Write-host $AEndTimeFormated "Information: Job finished at " $AEndTimeFormated
Write-host "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"    
}
Log:

Code: Select all

. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
27.03.2012 09:42:09 Information: VBRaddVMstoJob.ps1
27.03.2012 09:42:09 Information: Start time: 27.03.2012 09:42:09
27.03.2012 09:42:09 Information: Adding VMs Exchange3 fileserver2  from VCenter/ESX vcenter.demolab.an.veeam.de  to Job:  ad
27.03.2012 09:42:13 Information: Jobname name accepted. Jobname:  ad
27.03.2012 09:42:17 Information: vcenter/ESX name accepted. vcenter/ESX:  vcenter.demolab.an.veeam.de
27.03.2012 09:42:17 Information: Processing:  Exchange3
27.03.2012 09:42:27 Information: VM exists. VM Name:  Exchange3


Id                  : d0793b52-c524-4a84-b094-4aaaa6b76e35
Object              : Name: ad
Filter              : 
Name                : ad
Type                : Include
Location            : vcenter.demolab.an.veeam.de\ad
ApproxSizeString    : 3,1 GB
Info                : Veeam.Backup.Model.CDbObjectInJobInfo
JobId               : 43d287be-0f12-48a2-849b-883006208857
IsFolder            : False
IsIncluded          : True
IsVssChild          : False
IsExcludeDisksChild : False
IsExcluded          : False
IsExtended          : False
PolicyType          : None
VssOptions          : <CVssOptions><Enabled>True</Enabled><IgnoreErrors>False</
                      IgnoreErrors><GuestFSIndexingType>ExceptSpecifiedFolders<
                      /GuestFSIndexingType><TransactionLogsTruncation>OnlyOnSuc
                      cessJob</TransactionLogsTruncation><IsFirstUsage>False</I
                      sFirstUsage><IncludedIndexingFolders /><ExcludedIndexingF
                      olders><string>%windir%</string><string>%ProgramFiles%</s
                      tring><string>%TEMP%</string></ExcludedIndexingFolders></
                      CVssOptions>
ExtendedOptions     : Veeam.Backup.Model.COijExtendedOptions
DiskFilter          : 2000;2001;2002;2003;2004;2005;2006;2008;2009;2010;2011;20
                      12;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2024
                      ;2025;2026;2027;2028;2029;2030;2031;2032;2033;2034;2035;2
                      036;2037;2038;2040;2041;2042;2043;2044;2045;2046;2047;204
                      8;2049;2050;2051;2052;2053;2054;2056;2057;2058;2059;2060;
                      2061;2062;2063
UpdateConfig        : False

Id                  : 6f131826-997c-4ff9-a82c-7cbf2c2a014c
Object              : Name: fileserver2
Filter              : 
Name                : fileserver2
Type                : Include
Location            : vcenter.demolab.an.veeam.de\fileserver2
ApproxSizeString    : 0,0 KB
Info                : Veeam.Backup.Model.CDbObjectInJobInfo
JobId               : 43d287be-0f12-48a2-849b-883006208857
IsFolder            : False
IsIncluded          : True
IsVssChild          : False
IsExcludeDisksChild : False
IsExcluded          : False
IsExtended          : False
PolicyType          : None
VssOptions          : <CVssOptions><Enabled>True</Enabled><IgnoreErrors>False</
                      IgnoreErrors><GuestFSIndexingType>ExceptSpecifiedFolders<
                      /GuestFSIndexingType><TransactionLogsTruncation>OnlyOnSuc
                      cessJob</TransactionLogsTruncation><IsFirstUsage>True</Is
                      FirstUsage><IncludedIndexingFolders /><ExcludedIndexingFo
                      lders><string>%windir%</string><string>%ProgramFiles%</st
                      ring><string>%TEMP%</string></ExcludedIndexingFolders></C
                      VssOptions>
ExtendedOptions     : Veeam.Backup.Model.COijExtendedOptions
DiskFilter          : 2000;2001;2002;2003;2004;2005;2006;2008;2009;2010;2011;20
                      12;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2024
                      ;2025;2026;2027;2028;2029;2030;2031;2032;2033;2034;2035;2
                      036;2037;2038;2040;2041;2042;2043;2044;2045;2046;2047;204
                      8;2049;2050;2051;2052;2053;2054;2056;2057;2058;2059;2060;
                      2061;2062;2063
UpdateConfig        : True

Id                  : a9c7eaae-8d69-4691-84c6-c1ad547ed4b7
Object              : Name: Exchange3
Filter              : 
Name                : Exchange3
Type                : Include
Location            : vcenter.demolab.an.veeam.de\Exchange3
ApproxSizeString    : 0,0 KB
Info                : Veeam.Backup.Model.CDbObjectInJobInfo
JobId               : 43d287be-0f12-48a2-849b-883006208857
IsFolder            : False
IsIncluded          : True
IsVssChild          : False
IsExcludeDisksChild : False
IsExcluded          : False
IsExtended          : False
PolicyType          : None
VssOptions          : <CVssOptions><Enabled>True</Enabled><IgnoreErrors>False</
                      IgnoreErrors><GuestFSIndexingType>ExceptSpecifiedFolders<
                      /GuestFSIndexingType><Credentials><UserName>Domain\Admini
                      strator</UserName><Password>AQAAANCMnd8BFdERjHoAwE/Cl+sBA
                      AAAHm8lXvyCt0C3raNuvC1l2QAAAAACAAAAAAADZgAAqAAAABAAAABHXt
                      RN9cmNgW0U31E7gcnDAAAAAASAAACgAAAAEAAAAOJmRA+ejOZhCe2EELh
                      /IjkQAAAAESuJJ0MMYNiKdCLWzZpBLRQAAAA/ycmZkqjsSHrCejK6d+/O
                      x0/Wzw==</Password><IsLocalProtect>False</IsLocalProtect>
                      <CurrentUser>False</CurrentUser></Credentials><Transactio
                      nLogsTruncation>OnlyOnSuccessJob</TransactionLogsTruncati
                      on><IsFirstUsage>True</IsFirstUsage><IncludedIndexingFold
                      ers /><ExcludedIndexingFolders><string>%windir%</string><
                      string>%ProgramFiles%</string><string>%TEMP%</string></Ex
                      cludedIndexingFolders></CVssOptions>
ExtendedOptions     : Veeam.Backup.Model.COijExtendedOptions
DiskFilter          : 2000;2001;2002;2003;2004;2005;2006;2008;2009;2010;2011;20
                      12;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2024
                      ;2025;2026;2027;2028;2029;2030;2031;2032;2033;2034;2035;2
                      036;2037;2038;2040;2041;2042;2043;2044;2045;2046;2047;204
                      8;2049;2050;2051;2052;2053;2054;2056;2057;2058;2059;2060;
                      2061;2062;2063
UpdateConfig        : True

Id                  : a1f03cc0-be90-48d6-93fd-8a0bb5a57531
Object              : Name: ad3
Filter              : 
Name                : ad3
Type                : Include
Location            : vcenter.demolab.an.veeam.de\ad3
ApproxSizeString    : 153,8 KB
Info                : Veeam.Backup.Model.CDbObjectInJobInfo
JobId               : 43d287be-0f12-48a2-849b-883006208857
IsFolder            : False
IsIncluded          : True
IsVssChild          : False
IsExcludeDisksChild : False
IsExcluded          : False
IsExtended          : False
PolicyType          : None
VssOptions          : <CVssOptions><Enabled>True</Enabled><IgnoreErrors>False</
                      IgnoreErrors><GuestFSIndexingType>ExceptSpecifiedFolders<
                      /GuestFSIndexingType><TransactionLogsTruncation>OnlyOnSuc
                      cessJob</TransactionLogsTruncation><IsFirstUsage>False</I
                      sFirstUsage><IncludedIndexingFolders /><ExcludedIndexingF
                      olders><string>%windir%</string><string>%ProgramFiles%</s
                      tring><string>%TEMP%</string></ExcludedIndexingFolders></
                      CVssOptions>
ExtendedOptions     : Veeam.Backup.Model.COijExtendedOptions
DiskFilter          : 2000;2001;2002;2003;2004;2005;2006;2008;2009;2010;2011;20
                      12;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2024
                      ;2025;2026;2027;2028;2029;2030;2031;2032;2033;2034;2035;2
                      036;2037;2038;2040;2041;2042;2043;2044;2045;2046;2047;204
                      8;2049;2050;2051;2052;2053;2054;2056;2057;2058;2059;2060;
                      2061;2062;2063
UpdateConfig        : False

27.03.2012 09:42:40 Information: Proofcheck result: True
27.03.2012 09:42:41 Information: Finished Processing:  Exchange3
27.03.2012 09:42:41 Information: Successfully added:  Exchange3
----------------------------------------------------------
27.03.2012 09:42:41 Information: Processing:  fileserver2
27.03.2012 09:42:45 Information: VM exists. VM Name:  fileserver2
Id                  : d0793b52-c524-4a84-b094-4aaaa6b76e35
Object              : Name: ad
Filter              : 
Name                : ad
Type                : Include
Location            : vcenter.demolab.an.veeam.de\ad
ApproxSizeString    : 3,1 GB
Info                : Veeam.Backup.Model.CDbObjectInJobInfo
JobId               : 43d287be-0f12-48a2-849b-883006208857
IsFolder            : False
IsIncluded          : True
IsVssChild          : False
IsExcludeDisksChild : False
IsExcluded          : False
IsExtended          : False
PolicyType          : None
VssOptions          : <CVssOptions><Enabled>True</Enabled><IgnoreErrors>False</
                      IgnoreErrors><GuestFSIndexingType>ExceptSpecifiedFolders<
                      /GuestFSIndexingType><TransactionLogsTruncation>OnlyOnSuc
                      cessJob</TransactionLogsTruncation><IsFirstUsage>False</I
                      sFirstUsage><IncludedIndexingFolders /><ExcludedIndexingF
                      olders><string>%windir%</string><string>%ProgramFiles%</s
                      tring><string>%TEMP%</string></ExcludedIndexingFolders></
                      CVssOptions>
ExtendedOptions     : Veeam.Backup.Model.COijExtendedOptions
DiskFilter          : 2000;2001;2002;2003;2004;2005;2006;2008;2009;2010;2011;20
                      12;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2024
                      ;2025;2026;2027;2028;2029;2030;2031;2032;2033;2034;2035;2
                      036;2037;2038;2040;2041;2042;2043;2044;2045;2046;2047;204
                      8;2049;2050;2051;2052;2053;2054;2056;2057;2058;2059;2060;
                      2061;2062;2063
UpdateConfig        : False

Id                  : 6f131826-997c-4ff9-a82c-7cbf2c2a014c
Object              : Name: fileserver2
Filter              : 
Name                : fileserver2
Type                : Include
Location            : vcenter.demolab.an.veeam.de\fileserver2
ApproxSizeString    : 0,0 KB
Info                : Veeam.Backup.Model.CDbObjectInJobInfo
JobId               : 43d287be-0f12-48a2-849b-883006208857
IsFolder            : False
IsIncluded          : True
IsVssChild          : False
IsExcludeDisksChild : False
IsExcluded          : False
IsExtended          : False
PolicyType          : None
VssOptions          : <CVssOptions><Enabled>True</Enabled><IgnoreErrors>False</
                      IgnoreErrors><GuestFSIndexingType>ExceptSpecifiedFolders<
                      /GuestFSIndexingType><TransactionLogsTruncation>OnlyOnSuc
                      cessJob</TransactionLogsTruncation><IsFirstUsage>True</Is
                      FirstUsage><IncludedIndexingFolders /><ExcludedIndexingFo
                      lders><string>%windir%</string><string>%ProgramFiles%</st
                      ring><string>%TEMP%</string></ExcludedIndexingFolders></C
                      VssOptions>
ExtendedOptions     : Veeam.Backup.Model.COijExtendedOptions
DiskFilter          : 2000;2001;2002;2003;2004;2005;2006;2008;2009;2010;2011;20
                      12;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2024
                      ;2025;2026;2027;2028;2029;2030;2031;2032;2033;2034;2035;2
                      036;2037;2038;2040;2041;2042;2043;2044;2045;2046;2047;204
                      8;2049;2050;2051;2052;2053;2054;2056;2057;2058;2059;2060;
                      2061;2062;2063
UpdateConfig        : True

Id                  : a9c7eaae-8d69-4691-84c6-c1ad547ed4b7
Object              : Name: Exchange3
Filter              : 
Name                : Exchange3
Type                : Include
Location            : vcenter.demolab.an.veeam.de\Exchange3
ApproxSizeString    : 0,0 KB
Info                : Veeam.Backup.Model.CDbObjectInJobInfo
JobId               : 43d287be-0f12-48a2-849b-883006208857
IsFolder            : False
IsIncluded          : True
IsVssChild          : False
IsExcludeDisksChild : False
IsExcluded          : False
IsExtended          : False
PolicyType          : None
VssOptions          : <CVssOptions><Enabled>True</Enabled><IgnoreErrors>False</
                      IgnoreErrors><GuestFSIndexingType>ExceptSpecifiedFolders<
                      /GuestFSIndexingType><Credentials><UserName>Domain\Admini
                      strator</UserName><Password>AQAAANCMnd8BFdERjHoAwE/Cl+sBA
                      AAAHm8lXvyCt0C3raNuvC1l2QAAAAACAAAAAAADZgAAqAAAABAAAABHXt
                      RN9cmNgW0U31E7gcnDAAAAAASAAACgAAAAEAAAAOJmRA+ejOZhCe2EELh
                      /IjkQAAAAESuJJ0MMYNiKdCLWzZpBLRQAAAA/ycmZkqjsSHrCejK6d+/O
                      x0/Wzw==</Password><IsLocalProtect>False</IsLocalProtect>
                      <CurrentUser>False</CurrentUser></Credentials><Transactio
                      nLogsTruncation>OnlyOnSuccessJob</TransactionLogsTruncati
                      on><IsFirstUsage>True</IsFirstUsage><IncludedIndexingFold
                      ers /><ExcludedIndexingFolders><string>%windir%</string><
                      string>%ProgramFiles%</string><string>%TEMP%</string></Ex
                      cludedIndexingFolders></CVssOptions>
ExtendedOptions     : Veeam.Backup.Model.COijExtendedOptions
DiskFilter          : 2000;2001;2002;2003;2004;2005;2006;2008;2009;2010;2011;20
                      12;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2024
                      ;2025;2026;2027;2028;2029;2030;2031;2032;2033;2034;2035;2
                      036;2037;2038;2040;2041;2042;2043;2044;2045;2046;2047;204
                      8;2049;2050;2051;2052;2053;2054;2056;2057;2058;2059;2060;
                      2061;2062;2063
UpdateConfig        : True

Id                  : a1f03cc0-be90-48d6-93fd-8a0bb5a57531
Object              : Name: ad3
Filter              : 
Name                : ad3
Type                : Include
Location            : vcenter.demolab.an.veeam.de\ad3
ApproxSizeString    : 153,8 KB
Info                : Veeam.Backup.Model.CDbObjectInJobInfo
JobId               : 43d287be-0f12-48a2-849b-883006208857
IsFolder            : False
IsIncluded          : True
IsVssChild          : False
IsExcludeDisksChild : False
IsExcluded          : False
IsExtended          : False
PolicyType          : None
VssOptions          : <CVssOptions><Enabled>True</Enabled><IgnoreErrors>False</
                      IgnoreErrors><GuestFSIndexingType>ExceptSpecifiedFolders<
                      /GuestFSIndexingType><TransactionLogsTruncation>OnlyOnSuc
                      cessJob</TransactionLogsTruncation><IsFirstUsage>False</I
                      sFirstUsage><IncludedIndexingFolders /><ExcludedIndexingF
                      olders><string>%windir%</string><string>%ProgramFiles%</s
                      tring><string>%TEMP%</string></ExcludedIndexingFolders></
                      CVssOptions>
ExtendedOptions     : Veeam.Backup.Model.COijExtendedOptions
DiskFilter          : 2000;2001;2002;2003;2004;2005;2006;2008;2009;2010;2011;20
                      12;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2024
                      ;2025;2026;2027;2028;2029;2030;2031;2032;2033;2034;2035;2
                      036;2037;2038;2040;2041;2042;2043;2044;2045;2046;2047;204
                      8;2049;2050;2051;2052;2053;2054;2056;2057;2058;2059;2060;
                      2061;2062;2063
UpdateConfig        : False

27.03.2012 09:42:59 Information: Proofcheck result: True
27.03.2012 09:42:59 Information: Finished Processing:  fileserver2
27.03.2012 09:42:59 Information: Successfully added:  fileserver2
----------------------------------------------------------
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Information: Job Finished
Exchange3 fileserver2 where added successfully to job:  ad
Job started at  27.03.2012 09:42:09
Job finished at  27.03.2012 09:42:59
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



Feel free to post feedback and ideas.

CU Andy
Attachments
VBRaddVMstoJob.rar
(3.85 KiB) Downloaded 287 times
BGilbert
Influencer
Posts: 14
Liked: 3 times
Joined: Jun 20, 2012 10:01 pm
Full Name: Brian Gilbert
Contact:

Re: Andys scripting corner - Add VMs to job (v6)

Post by BGilbert »

Andy - Does this only work for VMware and not for Hyper-V vms? Do you know a way to add a Hyper-V vm to an existing job? Thanks, Brian
BGilbert
Influencer
Posts: 14
Liked: 3 times
Joined: Jun 20, 2012 10:01 pm
Full Name: Brian Gilbert
Contact:

Re: Andys scripting corner - Add VMs to job (v6)

Post by BGilbert »

Andy,

Here is what I tried:
$vmm2012 = get-vbrserver | where {$_.Name -eq "My VMM2012 server name" -and $_.Type -eq "Scvmm"}
Add-VBRJobObject -Job (get-vbrjob -name BGTest2) -Server $vmm2012 -Objects (find-vbrhventity -name hvm2test8)


I don't get any errors but it doesn't add the Hyper-V VM to the job either. The output returned looks like this:
Name Type ApproxSize Location
---- ---- ---------- --------
HVM2Test1 Include 0.0 KB My VMM2012 server name

HVM2Test1 is the existing VM in the job.
Brian
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 6 guests