GithubHelp home page GithubHelp logo

jaykul / jupyter-powershell Goto Github PK

View Code? Open in Web Editor NEW
109.0 8.0 17.0 255 KB

Jupyter Kernel for PowerShell

License: Other

C# 20.20% Jupyter Notebook 77.05% PowerShell 2.15% Dockerfile 0.60%
powershell jupyter kernel

jupyter-powershell's Introduction

This project is archived. Try Microsoft's reimplementation in dotnet/interactive.

A Jupyter Kernel for PowerShell

Create PowerShell notebooks in a web browser, with commands and captured output. Add markdown blocks for documentation!

You can use Jupyter with PowerShell to produce documentation of your troubleshooting, researching, and even your regular processes. You can also use HTML and Javascript with your PowerShell data to create visual reports, do numerical analysis, etc.

Get it for yourself

The easiest way to try the kernel is using Binder. You can just click here: Binder

The next easiest way is using docker (if you have docker installed). You can start a copy like this:

docker run -it --rm -p 8888:8888 jaykul/powershell-notebook-base

You can also install the kernel locally (assuming you have Jupyter or a clone installed) using chocolatey:

choco install jupyter-powershell

Current Status

The PowerShell kernel is based on PowerShell Core, in order to be cross-platform and standalone.

At this point, I'm only handling two messages:

  • KernelInfo request
  • Execute request

Features

Since Jupyter is all about interaction and documentation, if you want details about the features, you can read the Features notebook here on github, or by running the binder link above.

PowerShell Core

In order to get cross-platform support, this kernel is based on PowerShell Core.

To build it yourself --or to run the "PowerShell (Core)" kernel-- you need dotnet core 2. You can build it by running dotnet restore; dotnet build from the root. If you want to build it in Visual Studio, you need VS 2017 version 15.3 or higher.

A Note on the Jupyter library

This kernel is being written in C#, and in the process, I've taken some messaging code from the iCSharp kernel and made a generic library for .Net with a re-usable core for anyone who needs to create Jupyter kernels in .Net languages -- so feel free to borrow that if you like (it's under the Apache license).

jupyter-powershell's People

Contributors

it-praktyk avatar jaykul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jupyter-powershell's Issues

Job related exception

I'm trying run the following code blocks

@(
    Start-Job {Start-sleep -Seconds 2; Get-Date}
    Start-Job {Start-sleep -Seconds 3; Get-Date}
) | Wait-Job | Receive-Job
$Jobs = @(
    Start-Job {Start-sleep -Seconds 2; Get-Date}
    Start-Job {Start-sleep -Seconds 3; Get-Date}
) 
$Jobs | Wait-Job | Receive-Job
$Job1 = Start-Job {Start-sleep -Seconds 2; Get-Date}
$Job2 = Start-Job {Start-sleep -Seconds 3; Get-Date}
Start-sleep -Seconds 5
Get-Job | Receive-Job

Or any kind of combination to start a job and receive it. I get the following exception for all of them:

PowerShell-Kernel : Object reference not set to an instance of an object.

   at Jupyter.PowerShell.PowerShellEngine.LogErrors(ExecutionResult result, PipelineReader`1 errorStream) in C:\Users\Joel\Projects\Jupyter\Jupyter-PowerShell\Source\PowerShell-Kernel\PowerShellEngine.cs:line 179
   at Jupyter.PowerShell.PowerShellEngine.Execute(String script) in C:\Users\Joel\Projects\Jupyter\Jupyter-PowerShell\Source\PowerShell-Kernel\PowerShellEngine.cs:line 75

Note: My purpose for using jobs in the jupyter notebook was to demonstrate different methods of parallel and concurrent programming in PowerShell with pretty markdown all around it. Not trying to do anything real fancy.

Need to be able to customize the output

Projects like nteract demonstrate the beauty of writing output with custom mime-types as a way of triggering visualization, and are showing off tricks like having multiple code-blocks write to the same output block, etc.

In order to enable this we need a Write-Jupyter cmdlet that gives the shell access to the jupyter ZeroMQ streams, and the ability to specify mime types for IOPub output.

difficulty loading assembly from NuGet

# List available modules, specifically, we're looking for Npgsql driver loaded.
Get-Module -ListAvailable
Directory: /usr/src/jupyter-powershell/Modules


ModuleType Version    Name                                ExportedCommands                                              
---------- -------    ----                                ----------------                                              
Manifest   1.1.0.0    Microsoft.PowerShell.Archive        {Compress-Archive, Expand-Archive}                            
Manifest   3.0.0.0    Microsoft.PowerShell.Host           {Start-Transcript, Stop-Transcript}                           
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path...}
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {Get-Credential, Get-ExecutionPolicy, Set-ExecutionPolicy, ...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Format-List, Format-Custom, Format-Table, Format-Wide...}    
Script     1.1.7.0    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packag...
Script     1.6.0      PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}  
Script     0.0        PSDesiredStateConfiguration         {ThrowError, Get-PSMetaConfigDocumentInstVersionInfo, New-D...
Script     1.2        PSReadLine                          {Get-PSReadlineKeyHandler, Set-PSReadlineKeyHandler, Remove...
# List available repos, specifically, we're looking for Nuget where Npgsql is available
Get-PackageSource
Name                             ProviderName     IsTrusted  Location                                                   
----                             ------------     ---------  --------                                                   
MyNuGet                          NuGet            False      https://www.nuget.org/api/v2                               
PSGallery                        PowerShellGet    False      https://www.powershellgallery.com/api/v2
# If unavailable, register Nuget repo
Register-PackageSource -Name MyNuGet -Location https://www.nuget.org/api/v2 -ProviderName NuGet
Register-PackageSource : Package Source 'MyNuGet' exists.



At line:2 char:1
+ Register-PackageSource -Name MyNuGet -Location https://www.nuget.org/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

CategoryInfo          : ResourceExists: (Microsoft.Power...erPackageSource:RegisterPackageSource) [Register-PackageSource], Exception

FullyQualifiedErrorId : PackageSourceExists,Microsoft.PowerShell.PackageManagement.Cmdlets.RegisterPackageSource
# Search for the package after repo is added.
Find-Package Npgsql
Name                           Version          Source           Summary                                                
----                           -------          ------           -------                                                
Npgsql                         4.1.3.1          MyNuGet          Npgsql is the open source .NET data provider for Pos...
# Install Npgsql from the newly added repo
Install-Package Npgsql -Force -SkipDependencies -Scope CurrentUser 
Name                           Version          Source           Summary                                                
----                           -------          ------           -------                                                
Npgsql                         4.1.3.1          MyNuGet          Npgsql is the open source .NET data provider for Pos...
# Verify Npgsql is installed
Get-Package -Name Npgsql 
Name                           Version          Source                           ProviderName                           
----                           -------          ------                           ------------                           
Npgsql                         4.1.3.1          /usr/local/share/PackageManag... NuGet
# Get the strong Name of the assembly for reference
[System.Reflection.AssemblyName]::GetAssemblyName('/usr/local/share/PackageManagement/NuGet/Packages/Npgsql.4.1.3.1/lib/netstandard2.1/Npgsql.dll').FullName
Npgsql, Version=4.1.3.1, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7
# Import the Npgsql library for use (Doesn't work in Jupyter)
Import-Module '/usr/local/share/PackageManagement/NuGet/Packages/Npgsql.4.1.3.1/lib/netstandard2.1/Npgsql.dll' 
Import-Module : Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.




At line:2 char:1
+ Import-Module '/usr/local/share/PackageManagement/NuGet/Packages/Npgs ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

CategoryInfo          : NotSpecified: (:) [Import-Module], FileNotFoundException

FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand
# Doesn't work in Jupyter
Add-Type -Path '/usr/local/share/PackageManagement/NuGet/Packages/Npgsql.4.1.3.1/lib/netstandard2.1/Npgsql.dll' 
# https://books.google.com/books?id=yxiUDwAAQBAJ&pg=PA138&lpg=PA138&dq=powershell+npgsql&source=bl&ots=MCjIQZIpC6&sig=ACfU3U0YPc74WsKicn02hW5VelSTEFPVKQ&hl=en&sa=X&ved=2ahUKEwi8p9GV0I3oAhXFc98KHZrQCPwQ6AEwB3oECAsQAQ#v=onepage&q=powershell%20npgsql&f=false
Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/Npgsql/4.1.3.1 -OutFile .\postgres.zip
Expand-Archive .\postgres.zip
ls $bin
postgres
postgres.zip
share
Add-Type -Path /home/jovyan/.local/postgres/lib/netstandard2.1/Npgsql.dll -ReferencedAssemblies "/usr/src/jupyter-powershell/System.*.dll"
# List current assemblies
[System.AppDomain]::CurrentDomain.GetAssemblies() #| Select-String "Npgsql"
GAC    Version        Location                                                                                          
---    -------        --------                                                                                          
False  v4.0.30319     /usr/src/jupyter-powershell/System.Private.CoreLib.dll                                            
False  v4.0.30319     /usr/src/jupyter-powershell/PowerShell-Kernel.dll                                                 
False  v4.0.30319     /usr/src/jupyter-powershell/System.Runtime.dll                                                    
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.Extensions.Logging.dll                                      
False  v4.0.30319     /usr/src/jupyter-powershell/netstandard.dll                                                       
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.Extensions.Logging.Abstractions.dll                         
False  v4.0.30319     /usr/src/jupyter-powershell/Jupyter.dll                                                           
False  v4.0.30319     /usr/src/jupyter-powershell/System.Runtime.Extensions.dll                                         
False  v4.0.30319     /usr/src/jupyter-powershell/System.IO.FileSystem.dll                                              
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.Extensions.Configuration.dll                                
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.Extensions.Configuration.Abstractions.dll                   
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.Extensions.Configuration.Json.dll                           
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.Extensions.Configuration.Binder.dll                         
False  v4.0.30319     /usr/src/jupyter-powershell/System.Threading.Thread.dll                                           
False  v4.0.30319     /usr/src/jupyter-powershell/System.Console.dll                                                    
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.Extensions.Logging.Debug.dll                                
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.Extensions.Logging.Console.dll                              
False  v4.0.30319     /usr/src/jupyter-powershell/System.Diagnostics.Debug.dll                                          
False  v4.0.30319     /usr/src/jupyter-powershell/System.Linq.dll                                                       
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.Extensions.FileProviders.Abstractions.dll                   
False  v4.0.30319     /usr/src/jupyter-powershell/System.Management.Automation.dll                                      
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.Extensions.Options.dll                                      
False  v4.0.30319     /usr/src/jupyter-powershell/System.Collections.dll                                                
False  v4.0.30319     /usr/src/jupyter-powershell/System.Threading.dll                                                  
False  v4.0.30319     /usr/src/jupyter-powershell/System.Runtime.InteropServices.dll                                    
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.Extensions.Configuration.FileExtensions.dll                 
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.Extensions.FileProviders.Physical.dll                       
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.Extensions.Primitives.dll                                   
False  v4.0.30319     /usr/src/jupyter-powershell/System.IO.FileSystem.Watcher.dll                                      
False  v4.0.30319     /usr/src/jupyter-powershell/System.ComponentModel.Primitives.dll                                  
False  v4.0.30319     /usr/src/jupyter-powershell/System.Collections.Concurrent.dll                                     
False  v4.0.30319     /usr/src/jupyter-powershell/System.Threading.Tasks.dll                                            
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.Extensions.FileSystemGlobbing.dll                           
False  v4.0.30319     /usr/src/jupyter-powershell/Newtonsoft.Json.dll                                                   
False  v4.0.30319     /usr/src/jupyter-powershell/System.Dynamic.Runtime.dll                                            
False  v4.0.30319     /usr/src/jupyter-powershell/System.Linq.Expressions.dll                                           
False  v4.0.30319     /usr/src/jupyter-powershell/System.ObjectModel.dll                                                
False  v4.0.30319     /usr/src/jupyter-powershell/System.IO.dll                                                         
False  v4.0.30319     /usr/src/jupyter-powershell/System.Globalization.dll                                              
False  v4.0.30319     /usr/src/jupyter-powershell/System.Runtime.Numerics.dll                                           
False  v4.0.30319     /usr/src/jupyter-powershell/System.Private.Uri.dll                                                
False  v4.0.30319     /usr/src/jupyter-powershell/System.ComponentModel.TypeConverter.dll                               
False  v4.0.30319     /usr/src/jupyter-powershell/System.ComponentModel.dll                                             
False  v4.0.30319     /usr/src/jupyter-powershell/System.Collections.Specialized.dll                                    
False  v4.0.30319     /usr/src/jupyter-powershell/System.Drawing.Primitives.dll                                         
False  v4.0.30319     /usr/src/jupyter-powershell/System.Runtime.InteropServices.RuntimeInformation.dll                 
False  v4.0.30319     /usr/src/jupyter-powershell/System.Runtime.Serialization.Primitives.dll                           
False  v4.0.30319     /usr/src/jupyter-powershell/System.Runtime.Serialization.Formatters.dll                           
False  v4.0.30319     /usr/src/jupyter-powershell/System.Reflection.dll                                                 
False  v4.0.30319     /usr/src/jupyter-powershell/System.Reflection.Extensions.dll                                      
False  v4.0.30319     /usr/src/jupyter-powershell/System.Reflection.Emit.ILGeneration.dll                               
False  v4.0.30319     /usr/src/jupyter-powershell/System.Reflection.Primitives.dll                                      
False  v4.0.30319     /usr/src/jupyter-powershell/System.Reflection.Emit.Lightweight.dll                                
False  v4.0.30319                                                                                                       
False  v4.0.30319     /usr/src/jupyter-powershell/System.Text.Encoding.Extensions.dll                                   
False  v4.0.30319     /usr/src/jupyter-powershell/System.Resources.ResourceManager.dll                                  
False  v4.0.30319     /usr/src/jupyter-powershell/System.Diagnostics.TraceSource.dll                                    
False  v4.0.30319     /usr/src/jupyter-powershell/System.Xml.ReaderWriter.dll                                           
False  v4.0.30319     /usr/src/jupyter-powershell/System.Private.Xml.dll                                                
False  v4.0.30319     /usr/src/jupyter-powershell/System.Diagnostics.FileVersionInfo.dll                                
False  v4.0.30319     /usr/src/jupyter-powershell/System.Reflection.Metadata.dll                                        
False  v4.0.30319     /usr/src/jupyter-powershell/System.Collections.Immutable.dll                                      
False  v4.0.30319     /usr/src/jupyter-powershell/System.IO.MemoryMappedFiles.dll                                       
False  v4.0.30319     /usr/src/jupyter-powershell/System.Text.RegularExpressions.dll                                    
False  v4.0.30319     /usr/src/jupyter-powershell/System.Security.AccessControl.dll                                     
False  v4.0.30319     /usr/src/jupyter-powershell/System.Diagnostics.Tracing.dll                                        
False  v4.0.30319     /usr/src/jupyter-powershell/System.Reflection.Emit.dll                                            
False  v4.0.30319     /usr/src/jupyter-powershell/System.Threading.Timer.dll                                            
False  v4.0.30319     /usr/src/jupyter-powershell/System.Threading.Tasks.Parallel.dll                                   
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.PowerShell.Security.dll                                     
False  v4.0.30319     /usr/src/jupyter-powershell/System.Security.Principal.dll                                         
False  v4.0.30319     /usr/src/jupyter-powershell/System.IO.FileSystem.DriveInfo.dll                                    
False  v4.0.30319     /usr/src/jupyter-powershell/System.Runtime.Loader.dll                                             
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.Management.Infrastructure.dll                               
False  v4.0.30319     /usr/src/jupyter-powershell/System.Net.Primitives.dll                                             
False  v4.0.30319     /usr/src/jupyter-powershell/System.Net.NetworkInformation.dll                                     
False  v4.0.30319     /usr/src/jupyter-powershell/System.Security.Cryptography.X509Certificates.dll                     
False  v4.0.30319     /usr/src/jupyter-powershell/System.Security.Cryptography.Encoding.dll                             
False  v4.0.30319     /usr/src/jupyter-powershell/System.Net.Mail.dll                                                   
False  v4.0.30319     /usr/src/jupyter-powershell/System.Collections.NonGeneric.dll                                     
False  v4.0.30319     /usr/src/jupyter-powershell/System.IO.FileSystem.AccessControl.dll                                
False  v4.0.30319     /usr/src/jupyter-powershell/System.Security.Principal.Windows.dll                                 
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.Win32.Registry.dll                                          
False  v4.0.30319     /usr/src/jupyter-powershell/System.Diagnostics.Process.dll                                        
False  v4.0.30319     /usr/src/jupyter-powershell/System.Data.Common.dll                                                
False  v4.0.30319     /usr/src/jupyter-powershell/System.Security.Cryptography.Primitives.dll                           
False  v4.0.30319     /usr/src/jupyter-powershell/System.Security.Cryptography.Algorithms.dll                           
False  v4.0.30319     /usr/src/jupyter-powershell/NetMQ.dll                                                             
False  v4.0.30319     /usr/src/jupyter-powershell/System.Net.Sockets.dll                                                
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.Win32.Primitives.dll                                        
False  v4.0.30319     /usr/src/jupyter-powershell/AsyncIO.dll                                                           
False  v4.0.30319     /usr/src/jupyter-powershell/System.Text.Encoding.dll                                              
False  v4.0.30319     /usr/src/jupyter-powershell/System.Net.NameResolution.dll                                         
False  v4.0.30319     /usr/src/jupyter-powershell/System.Threading.ThreadPool.dll                                       
False  v4.0.30319     /usr/src/jupyter-powershell/System.Text.Encoding.CodePages.dll                                    
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.PowerShell.Commands.Management.dll                          
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.PowerShell.Commands.Utility.dll                             
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.PowerShell.ConsoleHost.dll                                  
False  v4.0.30319     /usr/src/jupyter-powershell/System.Security.Claims.dll                                            
False  v4.0.30319     /usr/src/jupyter-powershell/System.Net.Http.dll                                                   
False  v4.0.30319     /usr/src/jupyter-powershell/System.Threading.AccessControl.dll                                    
False  v4.0.30319     /usr/src/jupyter-powershell/Modules/PackageManagement/1.1.7.0/coreclr/netcoreapp2.0/Microsoft.P...
False  v4.0.30319     /usr/src/jupyter-powershell/Modules/PackageManagement/1.1.7.0/coreclr/netcoreapp2.0/Microsoft.P...
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.CodeAnalysis.CSharp.dll                                     
False  v4.0.30319     /usr/src/jupyter-powershell/Microsoft.CodeAnalysis.dll                                            
False  v4.0.30319     /usr/src/jupyter-powershell/System.ValueTuple.dll                                                 
False  v4.0.30319     /usr/src/jupyter-powershell/System.Xml.XDocument.dll                                              
False  v4.0.30319     /usr/src/jupyter-powershell/System.Private.Xml.Linq.dll                                           
False  v4.0.30319                                                                                                       
False  v4.0.30319     /usr/src/jupyter-powershell/Modules/PackageManagement/1.1.7.0/coreclr/netcoreapp2.0/Microsoft.P...
False  v4.0.30319     /usr/src/jupyter-powershell/Modules/PackageManagement/1.1.7.0/coreclr/netcoreapp2.0/Microsoft.P...
False  v4.0.30319     /usr/src/jupyter-powershell/Modules/PackageManagement/1.1.7.0/coreclr/netcoreapp2.0/Microsoft.P...
False  v4.0.30319     /usr/src/jupyter-powershell/Modules/PackageManagement/1.1.7.0/coreclr/netcoreapp2.0/Microsoft.P...
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319                                                                                                       
False  v4.0.30319     /usr/src/jupyter-powershell/System.IO.Compression.dll                                             
False  v4.0.30319     /usr/src/jupyter-powershell/System.Buffers.dll                                                    
False  v4.0.30319     /usr/src/jupyter-powershell/System.Diagnostics.StackTrace.dll                                     
False  v4.0.30319     /usr/local/share/PackageManagement/NuGet/Packages/Npgsql.4.1.3.1/lib/netstandard2.1/Npgsql.dll    
False  v4.0.30319     /usr/src/jupyter-powershell/System.Linq.Parallel.dll                                              
False  v4.0.30319     /usr/src/jupyter-powershell/System.Diagnostics.DiagnosticSource.dll                               
False  v4.0.30319     /usr/src/jupyter-powershell/System.IO.Compression.ZipFile.dll                                     
False  v4.0.30319
# doesn't work yet, this is helpful https://stackoverflow.com/questions/34674761/how-to-import-the-npgsql-module

$connection = [Npgsql.NpgsqlConnection]::new('Host=crdb-1;Port=26257;Username=maxroach;Password="";Database=movr')
$connection.Open()
$command = [Npgsql.NpgsqlCommand]::new('SELECT * from rides limit 10', $connection)
 : Unable to find type [Npgsql.NpgsqlConnection].



At line:3 char:15
+ $connection = [Npgsql.NpgsqlConnection]::new('Host=crdb-1;Port=26257; ...
+               ~~~~~~~~~~~~~~~~~~~~~~~~~

CategoryInfo          : InvalidOperation: (Npgsql.NpgsqlConnection:TypeName) [], ParentContainsErrorRecordException

FullyQualifiedErrorId : TypeNotFound

Crash on output of `pwd`?

Unhandled Exception: Newtonsoft.Json.JsonSerializationException: Self referencing loop detected with type 'System.Management.Automation.PSDriveInfo'. Path 'data.application/json.output[0].Drive.Provider.Drives'.

Manual setup documentation when using nteract

Given that the chocolatey package isn't working I tried to manually do what the package does and I now have a directory "C:\ProgramData\chocolatey\lib\jupyter-powershell\PowerShell-Core" that contains all the files that are in the Windows folder of the zip attached to the release.

I have the following in kernel.json:

{
  "argv": [
    "dotnet",
    "C:\\ProgramData\\chocolatey\\lib\\jupyter-powershell\\PowerShell-Core\\PowerShell-Kernel.dll",
    "{connection_file}"
  ],
  "display_name": "PowerShell (Core)",
  "language": "PowerShell"
}

I am using nteract and it shows PowerShell-Core as a kernel but it stays in the launching state and doesn't complete.

I would love to use the chocolatey package instead but that is blocked on #19 and I tried this with the last prelease version on chocolatey and it gives errors about not having live debugging enabled (probably a dead end anyway).

Any documentation on how to get this going manually while we wait for the package would be great.

Powershell X68 / X64

HI ,
If I try to load a powershell module then I run into the below issue

import-module : The current processor architecture is: X86.  
The module 'C:\Users\josverl\OneDrive -     Microsoft\WindowsPowerShell\Modules\AzureAD\2.0.0.131\AzureAD.psd1' 
requires the following architecture: Amd64.

What would it take to run an x64 Powershell kernel ?

PowerShell-Core tries to load Registry on Linux

When launching PowerShell-Core notebook on Linux throws an exception about not supporting Registry on linux:

PS /home/corbob/jupyter> jupyter notebook                                                                                                                                
[I 22:02:51.651 NotebookApp] Serving notebooks from local directory: /home/corbob/jupyter
[I 22:02:51.651 NotebookApp] 0 active kernels 
[I 22:02:51.651 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=cb0aee7035533fe2a5982ed0d2ced625b2eefc825fc107e3
[I 22:02:51.651 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 22:02:51.652 NotebookApp] 
    
    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8888/?token=cb0aee7035533fe2a5982ed0d2ced625b2eefc825fc107e3
Created new window in existing browser session.
[9707:9733:0703/220252.035095:ERROR:browser_gpu_channel_host_factory.cc(103)] Failed to launch GPU process.
[I 22:02:52.048 NotebookApp] Accepting one-time-token-authenticated connection from ::1
[I 22:02:57.337 NotebookApp] Creating new notebook in 
[W 22:02:58.076 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20170703220251 (::1) 10.93ms referer=http://localhost:8888/notebooks/Untitled.ipynb?kernel_name=powershell-core
[I 22:02:58.149 NotebookApp] Kernel started: e696de97-1220-46b1-86cf-16d220113188

Unhandled Exception: System.TypeInitializationException: The type initializer for 'System.Management.Automation.PSVersionInfo' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Microsoft.Win32.Registry' threw an exception. ---> System.PlatformNotSupportedException: Registry is not supported on this platform.
   at Microsoft.Win32.RegistryKey.OpenBaseKeyCore(RegistryHive hKey, RegistryView view)
   at Microsoft.Win32.Registry..cctor()
   --- End of inner exception stack trace ---
   at System.Management.Automation.PSVersionInfo.GetWSManStackVersion()
   at System.Management.Automation.PSVersionInfo..cctor()
   --- End of inner exception stack trace ---
   at System.Management.Automation.PSVersionInfo.get_PSVersion()
   at System.Management.Automation.PSSnapInReader.ReadRegistryInfo(Version& assemblyVersion, String& publicKeyToken, String& culture, String& architecture, String& applicationBase, Version& psVersion)
   at System.Management.Automation.PSSnapInReader.ReadEnginePSSnapIns()
   at System.Management.Automation.Runspaces.InitialSessionState.CreateDefault()
   at Jupyter.PowerShell.PowerShellEngine..ctor(ILogger logger)
   at Jupyter.PowerShell.Kernel.Main(String[] args)

working in Notebook / CLI but not in jupyterlab?

While using the C# core for another project I came across the problem of
the kernel working great in Notebook but not Jupyterlab. After much digging I found the issue is the same as the following link:
jupyterlab/jupyterlab#470
Basically you need to modify the KernelInfoHandler to send PublishStatus(message, ioPub, KernelState.Busy) before the message and PublishStatus(message, ioPub, KernelState.Idle) after it is done in HandleMessage just like you do for an ExecuteRequestHandler. You have to do this for all messages you choose to handle. The new system going forward does not consider the kernel to be active until it gets the KernelState.Idle on the ioPub channel for every message it sends forward and gets handled.

Just thought someone might like to know.

Linux Installation warning that dotnet version is wrong

Install script failing in multiple ways on Linux.

Having the latest dotnet isntalled, gives an error that you're not on the expected version.

PS /home/corbob/Jupyter-PowerShell> ./Install.ps1 -KernelFolder ~/.jupyter/kernel                                                                                        
WARNING: 
            The currently installed 'dotnet' (.NET Command Line Tools) is not the expected version.

            Installed version: 2.0.0-preview2-006127
            Expected version: 2.0.0-preview1-005977

            If your version is older, you PROBABLY cannot run the 'PowerShell (Core)' kernel.

            Get the latest version from https://www.microsoft.com/net/core/preview
            

            
/usr/bin/mkdir: invalid option -- 'P'
Try '/usr/bin/mkdir --help' for more information.

This doesn't seem to stop the installation, but it is a warning that comes up.

Issues running in Jupyterhub

I cannot seem to get the is to work in the jupyterhub setup. I have installed everything correct but receive a consisted traceback error. this is the error I receive anytime I try to run any type of code in the Notebook.

Traceback (most recent call last):
File "/opt/tljh/user/lib/python3.6/site-packages/powershell_kernel/kernel.py", line 62, in do_execute
self.__createProxy()
File "/opt/tljh/user/lib/python3.6/site-packages/powershell_kernel/kernel.py", line 51, in __createProxy
repl = subprocess_repl.SubprocessRepl([powershell_command, '-noninteractive', '-noprofile', '-File', '-'])
File "/opt/tljh/user/lib/python3.6/site-packages/powershell_kernel/subprocess_repl.py", line 29, in init
stderr=subprocess.STDOUT, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File "/opt/tljh/user/lib/python3.6/subprocess.py", line 709, in init
restore_signals, start_new_session)
File "/opt/tljh/user/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'pwsh': 'pwsh'

Any help is greatly appreciated.

Not all errors are displayed...

For example:

Invoke-WebRequest natas2.natas.labs.overthewire.org

Calling Pipeline.Invoke throws an exception, rather than returning output and an Exception.

Trouble installing via Chocolatey

Following the installation instructions for installing via chocolatey, I ran into a problem:

Chocolatey v0.10.10
Installing the following packages:
jupyter-powershell
By installing you accept licenses for the packages.
jupyter-powershell not installed. The package was not found with the source(s) listed.
 Source(s): 'https://chocolatey.org/api/v2/'
 NOTE: When you specify explicit sources, it overrides default sources.
If the package version is a prerelease and you didn't specify `--pre`,
 the package may not be found.
Please see https://chocolatey.org/docs/troubleshooting for more
 assistance.

Chocolatey installed 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

If I add the --pre, then it installs.

choco install jupyter-powershell --pre
Chocolatey v0.10.10
Installing the following packages:
jupyter-powershell
By installing you accept licenses for the packages.
Progress: Downloading jupyter-powershell 1.0.0-beta-7... 100%

jupyter-powershell v1.0.0-beta-7

Installation on Linux fails trying to make kernel directory

Line 143 references mkdir. mkdir is an application in linux, and a function on Windows.

PS /home/corbob/Jupyter-PowerShell> ./Install.ps1 -KernelFolder ~/.jupyter/kernel                                                                                        
         
/usr/bin/mkdir: invalid option -- 'P'
Try '/usr/bin/mkdir --help' for more information.

Should use New-Item instead of mkdir.

No Error output

Not sure how the errors are supposed to go back in order to be displayed as errors.

Get-Credential does not work

Neither, for that matter does anything else which needs to prompt for input.

To get this working I need to write a proper "Host" so it's not the highest priority.

The workaround (for me, at least) is to use the BetterCredentials and -Store the credentials from a regular PowerShell session so I can use them here.

Show-Command

When I run Show-Command to get all the syntax for a command in the CLI it pops up a window and when I'm done filling it in and click "Run" it returns but does not execute the line. Example:

PS C:> Show-Command Get-Process
PS C:> Get-Process^M

When I do that inside a Jupyter Notebook it doesn't pause but executes the line without showing the command.

JSON Validation errors

I'm getting a validation error when the output from the PowerShell kernel includes the json representation.
Looks like this needs to return a single object, not an array.

PowerShell (Full) crashes on fully patched Windows 10 1703

Have tried on two systems running Windows 10 1703, and PowerShell (Full) crashes immediately upon opening the notebook. Issue does not occur on Windows 10 Insider build system.

[I 21:07:07.375 NotebookApp] Accepting one-time-token-authenticated connection from ::1
[I 21:07:18.486 NotebookApp] Creating new notebook in
[I 21:07:20.970 NotebookApp] Kernel started: 00d310c9-98c4-4194-9746-de1826ea36d2

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Console, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
   at Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider..ctor(Func`3 filter, Boolean includeScopes)
   at Microsoft.Extensions.Logging.ConsoleLoggerExtensions.AddConsole(ILoggerFactory factory, Boolean includeScopes)
   at Jupyter.PowerShell.Kernel.Main(String[] args)
[I 21:07:26.927 NotebookApp] KernelRestarter: restarting kernel (1/5)

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Console, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
   at Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider..ctor(Func`3 filter, Boolean includeScopes)
   at Microsoft.Extensions.Logging.ConsoleLoggerExtensions.AddConsole(ILoggerFactory factory, Boolean includeScopes)
   at Jupyter.PowerShell.Kernel.Main(String[] args)
[I 21:07:29.947 NotebookApp] Interrupted...
[I 21:07:29.950 NotebookApp] Shutting down kernels
[I 21:07:29.953 NotebookApp] Kernel shutdown: 00d310c9-98c4-4194-9746-de1826ea36d2

Can the docker approach access the host file system?

Just a quick question. If I run this via docker, I wouldn't be able to access the host file system, right? At least not without mounting volumes?

I think I know the answer, but since I imagine most of the time that people want to use powershell they're working against the file system, it might be a good idea to explicitly address and maybe even given an example of how to mount volumes in the README

Installation

Hii,
This is very nice!
I have some Problems with the installing, I get a dead kernel...
Did you know the dependencies

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.