Hi Lion liao,
Please find the sample script to connect to SnapCenter and run Get-SmBackup command:
# Define SnapCenter server and credentials
$SnapCenterServer = "https://snapcenter:8146" # Replace with your SnapCenter server address
$Username = "demo\administrator" # Replace with your username
$Password = ConvertTo-SecureString "password@123" -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential($Username, $Password)
# Connect to the SnapCenter server
Write-Host "Connecting to SnapCenter Server: $SnapCenterServer..."
Open-SmConnection -SMSbaseurl $SnapCenterServer -Credential $Credential
# Check if the connection was successful
if ($?) {
Write-Host "Connected to SnapCenter Server successfully."
# Get SnapCenter backups Write-Host "Fetching SnapCenter backups..."
$Backups = Get-SmBackup
# Output backup details
if ($Backups) {
$Backups
} else {
Write-Host "No backups found."
}
} else {
Write-Host "Failed to connect to SnapCenter Server."
}
Output from my lab:
Connecting to SnapCenter Server: https://snapcenter:8146...
Connected to SnapCenter Server successfully.
Fetching SnapCenter backups...
BackupId BackupName BackupTime BackupType
-------- ---------- ---------- ----------
1 RG1_SQL1_11-18-2024_02.38.40.9407 11/18/2024 2:39:01 AM Full Backup
Regards,
Pravin Kumar