I am looking for a sample powershell script to login to the snapcenter server and run Get-SmBackup
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 serverWrite-Host "Connecting to SnapCenter Server: $SnapCenterServer..."Open-SmConnection -SMSbaseurl $SnapCenterServer -Credential $Credential# Check if the connection was successfulif ($?) {Write-Host "Connected to SnapCenter Server successfully."# Get SnapCenter backups Write-Host "Fetching SnapCenter backups..."$Backups = Get-SmBackup# Output backup detailsif ($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