Skip to content

Instantly share code, notes, and snippets.

@SQLvariant
Created May 13, 2020 15:38
Show Gist options
  • Save SQLvariant/8d5c95ab4bd858a5fccd8523eede3151 to your computer and use it in GitHub Desktop.
Save SQLvariant/8d5c95ab4bd858a5fccd8523eede3151 to your computer and use it in GitHub Desktop.

Revisions

  1. SQLvariant created this gist May 13, 2020.
    60 changes: 60 additions & 0 deletions PBIRS_ArgumentCompleter.PS1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@
    <# SSRS / PBIRS #>
    Register-ArgumentCompleter -ParameterName ReportServerUri -ScriptBlock {
    "http://localhost:8016/Reports_SQL2016", 'http://localhost:8081/PBIRServer' | ForEach-Object {
    $CompletionText = $_
    New-Object System.Management.Automation.CompletionResult (
    $CompletionText,
    $_,
    'ParameterValue',
    "$_ (SSRSInstance)"
    )
    }
    };
    <# When the Parameter is called -Destination we do this #>
    Register-ArgumentCompleter -ParameterName Destination -ScriptBlock {
    param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)

    if ($fakeBoundParameter.ContainsKey('ReportServerUri')) {
    (Get-RsFolderContent -ReportServerUri $($fakeBoundParameter.ReportServerUri) -Path /).Name | ForEach-Object {
    $CompletionText = $_
    New-Object System.Management.Automation.CompletionResult (
    $CompletionText,
    $_,
    'ParameterValue',
    "$_ (SSRS Item)"
    )
    }
    }
    };
    <# When the Parameter is called -Path we do this #>
    Register-ArgumentCompleter -ParameterName RsFolder -ScriptBlock {
    param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)

    if ($fakeBoundParameter.ContainsKey('ReportServerUri')) {
    (Get-RsFolderContent -ReportServerUri $($fakeBoundParameter.ReportServerUri) -Path /).Name | ForEach-Object {
    $CompletionText = $_
    New-Object System.Management.Automation.CompletionResult (
    $CompletionText,
    $_,
    'ParameterValue',
    "$_ (SSRS Item)"
    )
    }
    }
    };
    <# When the Parameter is called -DestinationFolder we do this #>
    Register-ArgumentCompleter -ParameterName DestinationFolder -ScriptBlock {
    param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)

    if ($fakeBoundParameter.ContainsKey('ReportServerUri')) {
    (Get-RsFolderContent -ReportServerUri $($fakeBoundParameter.ReportServerUri) -Path /).Name | ForEach-Object {
    $CompletionText = $_
    New-Object System.Management.Automation.CompletionResult (
    $CompletionText,
    $_,
    'ParameterValue',
    "$_ (SSRS Item)"
    )
    }
    }
    };