-
-
Save LSTANCZYK/3258e865311b8593205e43070c9ecd01 to your computer and use it in GitHub Desktop.
PowerShell Argument Completer for SSRS & Power BI Report Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# 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)" | |
) | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment