Script to use on Linux with Powershell installed and IBM Spectrum Protect TDP VE
[root@lnxtdpve] /root/scripts > cat Backup-VM.ps1 #!/usr/bin/pwsh <# .SYNOPSIS Backup VM .OUTPUTS @{ExitCode=;StdOut=,StdErr=} #> $VMvCenterName = 'vcenter01.local.lu' $VMvCenterUser = 'user.tdp@vsphere.local' $VMvCenterPass = 'Vcpasswd' $AsNode = 'DATACENTER_01' # $Exclude_VM = @("vm01","vm02") $Exclude_VM = @("vm01") ### ### Connect to vCenter ### Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -WarningAction SilentlyContinue -ParticipateInCeip $false -DisplayDeprecationWarnings $false -confirm:$false # Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false -DefaultVIServerMode Single #Get-PowerCLIConfiguration $VCSession = Connect-VIServer -Server $VMvCenterName -User $VMvCenterUser -Password $VMvCenterPass ### ### Retreive VM Information ### Write-Host "Retreive VM information..." $env:LD_LIBRARY_PATH = "/opt/tivoli/tsm/client/ba/bin:/opt/tivoli/tsm/tdpvmware/common/jre/jre/bin/classic" Foreach( $VM in $( Get-VM | Select-String -pattern $Exclude_VM -notMatch)) { Write-Host "#### Backup VM: $VM" /usr/bin/dsmc ba vm $VM -optfile="/opt/tivoli/tsm/client/ba/bin/dsm_ve.opt" -asnode="$AsNode" } #$VMinfo = Get-VM | Out-String Write-Host "##### Backup Finished" ### ### Disconnect from vCenter ### Disconnect-VIServer -Server $VMvCenterName -Confirm:$false exit $RC