Skip to content

Instantly share code, notes, and snippets.

@Nillth
Created February 2, 2023 02:01
Show Gist options
  • Save Nillth/8625c3cc617b809c01476a7efa1b569e to your computer and use it in GitHub Desktop.
Save Nillth/8625c3cc617b809c01476a7efa1b569e to your computer and use it in GitHub Desktop.
function Copy-QSReloadTasks {
param
(
[Parameter(Mandatory = $true)]
$SourceAppID,
[Parameter(Mandatory = $true)]
$DestinationAppID
)
#Get the Condensed Verion of the Reload Task
$AppReloadTasks = Get-QSReloadtask -Filter "App.id eq $($SourceAppID)"
foreach ($ReloadTask in $AppReloadTasks) {
#Get the full version
$ReloadTaskFull = Get-QSReloadtask -Id $ReloadTask.Id
#Get the Schema Events for the Reload Task
$SchemaEvents = Get-QSSchemaevent -Full -Filter "ReloadTask.id eq $($ReloadTask.Id)"
#Get Destination App Condensed, Filter alway returns a Array so select first
$DestinationApp = $(Get-QSApp -Filter "id eq $($DestinationAppID)") | Select-Object -First 1
#Create a New Reload task, clearing the ID,Operational and relacing the App
## You can further manipulate the Name etc here if needed.
$NewRT = New-QSReloadTask -InputObject $ReloadTaskFull -Id ([guid]::Empty) -App $DestinationApp -Operational $Null
#Add the New reload task to QlikSense
$DestRTFull = Add-QSReloadtask -ReloadTaskObj $NewRT
#Get New ReloadTask Condensed, Filter alway returns a Array so select first
$DestRT = $(Get-QSReloadtask -Filter "id eq $($DestRTFull.id)") | Select-Object -First 1
foreach ($Event in $SchemaEvents) {
#Create a New Schema Event, clearing the ID,Operational and relacing the ReloadTask
## You can further manipulate the Name etc here if needed.
$NewQSSchemaEvent = New-QSSchemaEvent -InputObject $Event -Id ([guid]::Empty) -Operational $null -ReloadTask $DestRT
#Add the schema event to the reload task
$QSSchemaEvent = Add-QSSchemaevent -SchemaEventObj $NewQSSchemaEvent
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment