< Back

New-ADSWorkBook

Fri Jan 10, 2020 7:36 pm

NAME New-ADSWorkBook



SYNOPSIS

Creates a New Azure Data Studio WorkBook





SYNTAX

New-ADSWorkBook [-Path] <String> [-cells] <PSObject[]> [-Type] <String> [-WhatIf] [-Confirm] [<CommonParameters>]





DESCRIPTION

This will create a new Azure Data Studio Notebook





PARAMETERS

-Path <String>

The full path where you want the notebook saved - must end with .ipynb



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-cells <PSObject[]>

An array of New-AdsWorkBookCells to add to the WorkBook



Required? true

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Type <String>

The type of WorkBook to create - SQL or PowerShell



Required? true

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



-WhatIf [<SwitchParameter>]



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Confirm [<SwitchParameter>]



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Rob Sewell 10/10/2019 - Initial

Rob Sewell 14/11/2019 - Added PowerShell Notebooks type



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>$introCelltext = "# Welcome to my Auto Generated SQL Notebook



## Automation

Using this we can automate the creation of notebooks for our use

"

$SecondCelltext = "## Running code

The next cell will have some code in it for running



## Server Principals

Below is the code to run against your instance to find the server principals that are enabled"



$thirdcelltext = "SELECT Name

FROM sys.server_principals

WHERE is_disabled = 0"

$Intro = New-ADSWorkBookCell -Type Text -Text $introCelltext

$second = New-ADSWorkBookCell -Type Text -Text $SecondCelltext

$third = New-ADSWorkBookCell -Type Code -Text $thirdcelltext



$path = 'C:\\temp\\AutoGenerated.ipynb'

New-ADSWorkBook -Path $path -cells $Intro,$second,$third -Type SQL



Creates 3 cells with New-AdsWorkBookCells to add to the workbook,

two text ones and a code one, then creates a SQL Notebook with

those cells and saves it as C:\\temp\\AutoGenerated.ipynb









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>$introCelltext = "# Welcome to my Auto Generated PowerShell Notebook



## dbatools

![image](https://user-images.githubusercontent.c ... a68fc8.png)



dbatools is an open-source PowerShell Module for administering SQL Servers.

You can read more about dbatools and find the documentation at [dbatools.io](dbatools.io)

"

$SecondCelltext = "### Installation

You can install dbatools from the PowerShell Gallery using `Install-Module dbatools`

"



$thirdcelltext = "Install-Module dbatools"



$fourthCelltext = "### Getting Help

You should always use `Get-Help` to fins out how to use dbatools (and any PowerShell) commands"



$fifthcelltext = "Get-Help Get-DbaDatabase"

$sixthCelltext = "Try a command now. get the name, owner and collation of the user databases on the local instance"

$seventhCellText = "Get-DbaDatabase -SqlInstance localhost -ExcludeSystem | Select Name, Owner, Collation"



$Intro = New-ADSWorkBookCell -Type Text -Text $introCelltext

$second = New-ADSWorkBookCell -Type Text -Text $SecondCelltext

$third = New-ADSWorkBookCell -Type Code -Text $thirdcelltext

$fourth = New-ADSWorkBookCell -Type Text -Text $fourthCelltext

$fifth = New-ADSWorkBookCell -Type Code -Text $fifthcelltext

$sixth = New-ADSWorkBookCell -Type Text -Text $sixthCelltext

$seventh = New-ADSWorkBookCell -Type Code -Text $seventhCellText



$path = 'C:\\temp\\dbatools.ipynb'

New-ADSWorkBook -Path $path -cells $Intro,$second,$third,$fourth,$fifth,$sixth,$Seventh -Type PowerShell



Creates 7 cells with New-AdsWorkBookCells to add to the workbook,

four text ones and three code ones, then creates a PowerShell Notebook with

those cells and saves it as C:\\temp\\dbatools.ipynb











RELATED LINKS