Last active
March 11, 2020 16:46
-
-
Save TylerLeonhardt/ff9a20fb53313bf31e6c0107b0fec4e3 to your computer and use it in GitHub Desktop.
An example PowerShell Notebook
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
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# PowerShell Notebook\n", | |
"\n", | |
"## What's supported" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Running things!" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> </pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> </pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> Directory: /Users/tyleonha/Code/CSharp/try/dotnet-interactive</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> </pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> Mode LastWriteTime Length Name</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ---- ------------- ------ ----</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> d---- 1/8/2020 11:45 AM bin</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> d---- 1/15/2020 12:31 PM CommandLine</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> d---- 1/15/2020 12:31 PM ContentFiles</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> d---- 1/15/2020 12:35 PM obj</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> d---- 1/3/2020 6:57 PM Properties</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/15/2020 12:32 PM 731 build-and-install-dotnet-interactive.ps1</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 12/29/2019 10:23 AM 222 Directory.Build.Props</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/15/2020 12:31 PM 6122 dotnet-interactive.csproj</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/15/2020 12:31 PM 198 dotnet-interactive.v3.ncrunchproject</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/3/2020 6:50 PM 515 IJupyterKernelSpec.cs</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 12/29/2019 10:23 AM 2500 JupyterInstallCommand.cs</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/3/2020 6:50 PM 1869 JupyterKernelSpec.cs</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/15/2020 12:31 PM 756 KernelExtensions.cs</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/23/2020 11:51 AM 14894 PowerShellNotebook.ipynb</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 12/29/2019 10:23 AM 3514 Program.cs</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 12/29/2019 10:23 AM 1280 Startup.cs</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/23/2020 12:04 PM 8952 Untitled.ipynb</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/17/2020 11:21 AM 3746 Untitled1.ipynb</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/17/2020 11:24 AM 1222 Untitled2.ipynb</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> </pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"Get-ChildItem" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### All the PowerShell streams" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<pre>WARNING: I'm a warning message</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre>VERBOSE: I'm a verbose message</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre>DEBUG: I'm a debug message</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre>INFORMATION: I'm an information message</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre>\n", | |
"Write-Error: I'm an non-terminating error\n", | |
"</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"\n", | |
"Exception: I'm a terminating error\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"Write-Warning \"I'm a warning message\"\n", | |
"Write-Verbose \"I'm a verbose message\" -Verbose\n", | |
"Write-Debug \"I'm a debug message\" -Debug\n", | |
"Write-Host \"I'm an information message\"\n", | |
"Write-Error \"I'm an non-terminating error\"\n", | |
"throw \"I'm a terminating error\"" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Order matters\n", | |
"#### Stream order (including output) is maintained" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<pre>WARNING: This should be before gci</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> </pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> </pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> Directory: /Users/tyleonha/Code/CSharp/try/dotnet-interactive</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> </pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> Mode LastWriteTime Length Name</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ---- ------------- ------ ----</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> d---- 1/8/2020 11:45 AM bin</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> d---- 1/15/2020 12:31 PM CommandLine</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> d---- 1/15/2020 12:31 PM ContentFiles</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> d---- 1/15/2020 12:35 PM obj</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> d---- 1/3/2020 6:57 PM Properties</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/15/2020 12:32 PM 731 build-and-install-dotnet-interactive.ps1</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 12/29/2019 10:23 AM 222 Directory.Build.Props</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/15/2020 12:31 PM 6122 dotnet-interactive.csproj</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/15/2020 12:31 PM 198 dotnet-interactive.v3.ncrunchproject</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/3/2020 6:50 PM 515 IJupyterKernelSpec.cs</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 12/29/2019 10:23 AM 2500 JupyterInstallCommand.cs</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/3/2020 6:50 PM 1869 JupyterKernelSpec.cs</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/15/2020 12:31 PM 756 KernelExtensions.cs</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/23/2020 11:51 AM 14894 PowerShellNotebook.ipynb</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 12/29/2019 10:23 AM 3514 Program.cs</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 12/29/2019 10:23 AM 1280 Startup.cs</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/23/2020 12:04 PM 8952 Untitled.ipynb</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/17/2020 11:21 AM 3746 Untitled1.ipynb</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> ----- 1/17/2020 11:24 AM 1222 Untitled2.ipynb</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre>WARNING: This should be after gci</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> </pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"Write-Warning \"This should be before gci\"\n", | |
"Get-ChildItem\n", | |
"Write-Warning \"This should be after gci\"" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Things that need work" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Cancel needs to work" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [] | |
}, | |
"execution_count": 7, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"Start-Sleep -Seconds 60" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Open questions\n", | |
"\n", | |
"### What should `$env:PSModulePath` look like?" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> /Users/tyleonha/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/Users/tyleonha/.dotnet/tools/.store/dotnet-interactive/0.0.0/dotnet-interactive/0.0.0/tools/netcoreapp3.1/any/runtimes/unix/lib/netcoreapp3.1/Modules:/Users/tyleonha/.powershell-daily/Modules:/Users/tyleonha/.dotnet/tools/.store/dotnet-interactive/0.0.0/dotnet-interactive/0.0.0/tools/netcoreapp3.1/any/Modules</pre>\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"$env:PSModulePath" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": ".NET (PowerShell)", | |
"language": "PowerShell", | |
"name": ".net-powershell" | |
}, | |
"language_info": { | |
"file_extension": ".ps1", | |
"mimetype": "text/x-powershell", | |
"name": "PowerShell", | |
"pygments_lexer": "powershell", | |
"version": "7.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment