Skip to content

Lets you automate PowerShell Notebooks with PowerShell at the command line, exports to Excel and more.

License

Notifications You must be signed in to change notification settings

ili101/PowerShellNotebook

 
 

Repository files navigation

PowerShell Notebook

This PowerShell module lets you automate the PowerShell notebooks you can create in the Azure Data Studio. Check out the SQL DBA with A Beard PowerShell Notebooks in Azure Data Studio.

This module includes the function Invoke-PowerShellNotebook which enables you to run the cells inside the PowerShell notebook.

Environment Master
Windows Build Status
Windows (Core) Build Status
Ubuntu Build Status
macOS Build Status

A PowerShell Notebook with Cells

Below is a PowerShell Notebook with three cells, each containing a PowerShell "script".

Notice the second cell has the results of running get-process | select company, name, handles -first 10

Automate the PowerShell Notebook

Bonus Points: Using the -AsExcel switch

Invoke-PowerShellNotebook sports an AsExcel switch. This lets you execute each cell in the PowerShell notebook and the function exports the results to a separate sheet in an Excel file.

You need to have the PowerShell ImportExcel module installed. The module is on the PowerShell Gallery, use Install-Module ImportExcel to install it on you machine.

Todo

  • Add Get-Notebook section
  • Add Get-NotebookContent section
  • Add create PS Notebook DSL section both AsText and saving to a file
New-PSNotebook -AsText {
            Add-NotebookCode "8+12"
            Add-NotebookCode "8+3"
            Add-NotebookMarkdown @'
## Math

- show addition
- show other
'@
}
{
	"metadata": {
		"kernelspec": {
			"name": "powershell",
			"display_name": "PowerShell"
		},
		"language_info": {
			"name": "powershell",
			"codemirror_mode": "shell",
			"mimetype": "text/x-sh",
			"file_extension": ".ps1"
		}
	},
	"nbformat_minor": 2,
	"nbformat": 4,
	"cells": [{
		"cell_type": "code",
		"source": "8+12"
	}, {
		"cell_type": "code",
		"source": "8+3"
	}, {
		"cell_type": "markdown",
		"source": "## Math\n\n- show addition\n- show other"
	}]
}

About

Lets you automate PowerShell Notebooks with PowerShell at the command line, exports to Excel and more.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PowerShell 88.2%
  • Jupyter Notebook 11.2%
  • Dockerfile 0.6%