-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate notebook demo.ps1
48 lines (33 loc) · 1.57 KB
/
create notebook demo.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Import-Module Git:\ADSNotebook\ADSNotebook.psd1
Get-Command -Module ADSNotebook
$introCelltext = "# Welcome to my Auto Generated 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"
$fourthcelltext = "## SA renamed?
You should check if the sa account is in that list"
$fifthCellText = "We should try another Code cell"
$sixthcelltext = "## Are these sysadmin role members correct?
You should check the accounts in this list"
$seventhcelltext = "EXEC sp_helpsrvrolemember 'sysadmin'"
$eighthcelltext = 'Thats all folks!!
<img src="https://media.giphy.com/media/8P7y2ARUPFpNaaWEZ3/giphy.gif" height="264" title="Windmill">
'
$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 Text -Text $fifthCellText
$sixth = New-ADSWorkBookCell -Type Text -Text $sixthcelltext
$seventh = New-ADSWorkBookCell -Type Code -Text $seventhcelltext
$eighth = New-ADSWorkBookCell -Type Text -Text $eighthcelltext
$path = 'C:\temp\AutoGenerated.ipynb'
New-ADSWorkBook -Path $path -cells $Intro,$second,$third,$fourth,$fifth,$sixth,$seventh,$eighth
Invoke-Item $path