# (C) 2012 Michael Denzler, michael@denzman.com # http://sharepoint.denzman.com # # Use on your own risk! cls write-host "DocAve 6 - PowerShell API Demo" -ForegroundColor green write-host "http://sharepoint.denzman.com/2012/01/sei-der-wolf-unter-den-schafen.html" -ForegroundColor green write-host "`n`n`nLade SharePoint PowerShell CMDlets" -ForegroundColor green Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue write-host "`n`nLade DocAve 6 PowerShell API" -ForegroundColor green Import-Module DocAveModule write-host "`n`nSetzte Variablen" -ForegroundColor green $dummyDocName = "dummy_document.txt" $subSiteName = "DemoWeb1" $docLibName = "DocLib1" $planName = "Backup Plan " + $subSiteName $planDescription = "This backup plan for subsite " + $subSiteName + " has been created by DocAve PowerShell API" $planStoragePolicy = "NAS Storage" $planAgentGroupName = "AllAgents" $farmName = "Farm(DEMO\SHAREPOINT:DEMO_SHAREPOINT_CONFIG)" $siteCollectionURL = "http://demo:80/docave" $siteURL = "http://demo:80/docave/prototypen/automation/" + $subSiteName $siteURLrelativePath = "/docave/prototypen/automation/" + $subSiteName $spObject = $subSiteName $docaveUsername = "admin" $docavePassword = ConvertTo-SecureString -String "admin" -AsPlainText -force $docaveControlPort = 14000 $docaveControlHost = "demo" write-host "`n`nErzeuge Web" -ForegroundColor green New-SPWeb -Url $siteURL -AddToQuickLaunch -AddToTopNav -Name $subSiteName -Template "STS#2" write-host "`n`nErzeuge Dokumenten Library" -ForegroundColor green $web = Get-SPWeb $siteURL $listTemplate = [Microsoft.SharePoint.SPListTemplateType]::DocumentLibrary $web.Lists.Add($docLibName, "Demo Document LIbrary", $listTemplate) $library = $web.Lists[$docLibName] $library.OnQuickLaunch = $true $library.Update() write-host "`n`nErzeuge Test-Dokument in Demo Doukemten Library" -ForegroundColor green $spFileCollection = $lib.Files $spFolder = $web.GetFolder($docLibName) $spFileCollection = $spFolder.Files $file = Get-ChildItem $dummyDocName $spFileCollection.Add("dummy_document.txt", $file.OpenRead(),$false) write-host "`n`nCreate Backup Plan for our web " + $subSiteName -ForegroundColor green Login-DocAveManager -controlHost $docaveControlHost -controlPort $docaveControlPort -Username $docaveUsername -Password $docavePassword $backupPlan = Get-DocAveGranularBackupBlankPlan $backupPlan.Name = $planName $backupPlan.Description = $planDescription $backupPlan.StoragePolicyName = $planStoragePolicy $backupPlan.AgentGroupName = $planAgentGroupName $objectToBackup = New-Object AvePoint.DocAve.API.Objects.SPWeb $farmName, $siteCollectionURL, $siteURLrelativePath $backupPlan.Tree.IncludeSPObject($objectToBackup) write-host "`n`nSend Backup Plan to DocAve" -ForegroundColor green New-DocAveGranularBackupPlan -Plan $backupPlan write-host "`n`nStart Backup Job by Plan" -ForegroundColor green cls $backupJob = Run-DocAveGranularBackupJob -PlanName $backupPlan.Name -BackupJobType full -JobReport detailed -WaitForJobComplete write-host "`n`nGet Backup Job details" -ForegroundColor green Get-DocAveJobSummary -ID $backupJob.ID #write-host "`n`nDownload Report file" Download-DocAveJobReport -ID $backupJob.ID -Format XLS -Path c:\report.zip