10-14-2013 01:41 PM
Hello All,
I am creating a script to backup all of my UCS domains in one pass. I have created the proper credential file so that is not the issue. The issue happens when trying to create the output filename to include the domain name as part of the file name. For whatever reason, I can't get it to replace the variable with the domain name. Here is the snippet of code, where I am just using echo to verify the file names to be created:
Import-Module CiscoUcsPS
$a = Set-UcsPowerToolConfiguration -SupportMultipleDefaultUcs $true
$CredFileKey = ConvertTo-SecureString 'timetolockit' -AsPlainText -Force
$hanele1 = connect-ucs -LiteralPath C:\scripts\creds\all.xml -key $credfilekey
$date = Get-Date -format "MM-dd-yyyy"
$fname = "C:\backup\" + ${ucs} + "-" + $date + "-full-state.xml"
echo $fname
Thank you,
Jim
Solved! Go to Solution.
10-15-2013 05:55 AM
Jim:
You are very close. What you don't need to do is do the variable's for date / time / etc like you are doing. The backup-ucs cmdlet will do that for you using the -PathPattern flag like this:
Import-Module CiscoUcsPS
$a = Set-UcsPowerToolConfiguration -SupportMultipleDefaultUcs $true
$CredFileKey = ConvertTo-SecureString 'timetolockit' -AsPlainText -Force
$handle1 = connect-ucs -LiteralPath C:\scripts\creds\all.xml -key $credfilekey
$configallbackup = Backup-Ucs -Type config-all -PathPattern 'c:\ucs\backups\${ucs}-${MM}-${dd}-${yyyy}-config-all.xml'
$fullstatebackup = Backup-Ucs -Type full-state -PathPattern 'c:\ucs\backups\${ucs}-${MM}-${dd}-${yyyy}-full-state.bin'
Let me know if that helps.
Eric
10-15-2013 05:55 AM
Jim:
You are very close. What you don't need to do is do the variable's for date / time / etc like you are doing. The backup-ucs cmdlet will do that for you using the -PathPattern flag like this:
Import-Module CiscoUcsPS
$a = Set-UcsPowerToolConfiguration -SupportMultipleDefaultUcs $true
$CredFileKey = ConvertTo-SecureString 'timetolockit' -AsPlainText -Force
$handle1 = connect-ucs -LiteralPath C:\scripts\creds\all.xml -key $credfilekey
$configallbackup = Backup-Ucs -Type config-all -PathPattern 'c:\ucs\backups\${ucs}-${MM}-${dd}-${yyyy}-config-all.xml'
$fullstatebackup = Backup-Ucs -Type full-state -PathPattern 'c:\ucs\backups\${ucs}-${MM}-${dd}-${yyyy}-full-state.bin'
Let me know if that helps.
Eric
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide