Use Registered Servers or Central Management Server to run Invoke-SqlNotebook against multiple servers.
$datetime = Get-Date -Format yyyyMMddhhmm
dir 'SQLSERVER:\SQLRegistration\Database Engine Server Group' |
WHERE { $_.Mode -ne 'd'} |
foreach {
Get-SqlInstance -ServerInstance $_.Name |
foreach {
Invoke-SqlNotebook -ServerInstance $_.Name -Database master -InputFile '$home\Documents\SQL Server Management Studio\BPCheck.ipynb' `
-OutputFile "BPCheck_output_$($_.NetName)_$($datetime).ipynb"
}
}
Install the PowerShell extension from the Azure Data Studio marketplace. Use the PowerShell Integrated Console in Azure Data Studio to run Invoke-SqlNotebook
and use Open-EditorFile
to open the results of the SQL Notebook directly in Azure Data Studio.
Invoke-SqlNotebook -ServerInstance ServerA -Database master -InputFile "$home\Documents\SQL Server Management Studio\BPCheck.ipynb" |
Open-EditorFile
Any idea why am I getting this error:
[TAIOB] C:\Users\taiob
--> Invoke-SqlNotebook -ServerInstance DESKTOP-50O69FS -Database master -InputFile "C:\Presentation\NotebookJobs\DatabaseConfiguration.ipynb" -OutputFile "C:\Presentation\NotebookJobs\outtest.ipynb" | Open-EditorFile
MethodInvocationException: C:\Users\taiob.azuredatastudio\extensions\microsoft.powershell-2021.12.0\modules\PowerShellEditorServices\Commands\Public\CmdletInterface.ps1:199:13
Line |
199 | $psEditor.Workspace.OpenFile($_.FullName, $preview)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "OpenFile" with "2" argument(s): "One or more errors occurred. (Internal error. )"