• Stars
    star
    129
  • Rank 270,491 (Top 6 %)
  • Language
    C#
  • License
    MIT License
  • Created over 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Interact with I2C, SPI & GPIO devices using PowerShell Core!

PowerShell-IoT

Build status Travis PowerShell Gallery

Note: PowerShell IoT is still in Preview

A PowerShell module for interacting with hardware sensors and devices using common protocols: GPIO, I2C & SPI.

An SSD1306 displaying "Hello World from PowerShell"

Information

Goals

The main goal of this project is to provide a friendly interface for interacting with hardware sensors and devices using PowerShell.

That said, it was built as close to the metal as possible to keep the library broad enough to cover a range of sensors and devices.

The hope is that this module will be the foundation for other modules that will expose specific cmdlets for interacting with specific sensors and devices.

For example, a cmdlet stack to turn on a light bulb might be:

> Set-Light On # Your user types this / you make this cmdlet
> Set-GpioPin -Id 4 -Value High # You use this to make that^ / we make this cmdlet
> # Our code that makes that^

To see some examples of modules built on top of PowerShell IoT, see the Examples folder.

Supported platforms

Supported devices

  • Raspberry Pi 3
  • Raspberry Pi 2

Supported operating systems

  • Raspbian Stretch

Documentation & Examples

Please see our docs folder here for an API reference, pin layout and other docs. For examples, checkout our examples folder.

Dependencies

This project relies on .NET Core IoT Libraries. It is a .NET library for interacting with Raspberry Pi's IO functionality.

Installation

PowerShell Gallery

You can grab the latest version of PowerShell IoT by running:

Install-Module Microsoft.PowerShell.IoT

Please note that since this module works with Hardware, higher privileges are required (run PowerShell with sudo, or as root user)

Then see the section on running.

If you want to write a module that uses PowerShell IoT, include it in the RequiredModules field of your module manifest.

GitHub releases

You can also manually download the zipped up module from the releases.

Then see the section on running.

AppVeyor

You can download the latest CI build from our AppVeyor build here. Go to the latest build, click on either of the images, then click on the artifacts tab. From there, you can download a zip of the latest CI build.

Then see the section on running.

From Source

Prerequisites

Building

NOTE: You can't build on ARM devices at this time so you will need to build on another machine and copy the build to the device.

  1. Clone/download the repo
  2. run ./build.ps1 -Bootstrap to see if you're missing any tooling
  3. run ./build.ps1 to build

At this point, you'll notice an out folder has been generated in the root of your repo. The project is ready to be deployed to your device.

Deploying

We have included a helper script, Move-PSIoTBuild.ps1, that will move the PowerShell IoT build over to your device. This copy uses PSRP over SSH so make sure you're able to connect to your pi this way. The Microsoft.PowerShell.IoT module will be copied to your $env:PSModulePath on your device. Here's an example:

Move-PSIoTBuild.ps1 -Ip 10.123.123.123 # IP address of device

You can also easily copy examples in the Examples folder over using the -WithExample flag. Just give a list of examples you want to copy over and it will move those to you $env:PSModulePath along with Microsoft.PowerShell.IoT:

Move-PSIoTBuild.ps1 -Ip 10.123.123.123 -WithExample Microsoft.PowerShell.IoT.Plant,Microsoft.PowerShell.IoT.SSD1306

Also, with the -Build parameter, it will build/test/package your project before moving it.

NOTE: If you'd rather not use the script, simply copy the out/Microsoft.PowerShell.IoT to your device to get started.

Running

Start PowerShell:

pwsh

If you have the Microsoft.PowerShell.IoT module in your PSModulePath:

Import-Module Microsoft.PowerShell.IoT

Alternatively, just import the .psd1:

Import-Module /path/to/Microsoft.PowerShell.IoT/Microsoft.PowerShell.IoT.psd1

At this point you can now mess with the module:

Get-Command -Module Microsoft.PowerShell.IoT
Get-GpioPin 2 # gets the data from GPIO pin 2

Testing

You can run tests, but they require a particular setup. Here is how you run them:

./build.ps1 -Test

The setup required:

We currently have a build agent that will deploy PR code onto a test Raspberry Pi and run the tests found in the test directory.

More Repositories

1

PowerShell

PowerShell for every system!
C#
43,534
star
2

Win32-OpenSSH

Win32 port of OpenSSH
7,143
star
3

PSReadLine

A bash inspired readline implementation for PowerShell
C#
3,494
star
4

PSScriptAnalyzer

Download ScriptAnalyzer from PowerShellGallery
C#
1,784
star
5

vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
TypeScript
1,647
star
6

DscResources

Central repository for PowerShell Desired State Configuration (DSC) resources.
772
star
7

ConsoleGuiTools

Modules that mix PowerShell and GUIs/CUIs!
C#
740
star
8

platyPS

Write PowerShell External Help in Markdown
C#
729
star
9

PowerShellEditorServices

A common platform for PowerShell development support in any editor or application!
C#
593
star
10

Polaris

A cross-platform, minimalist web framework for PowerShell
PowerShell
507
star
11

PSResourceGet

PSResourceGet is the package manager for PowerShell
C#
453
star
12

PowerShellGetv2

PowerShellGet is the Package Manager for PowerShell
PowerShell
426
star
13

PowerShell-RFC

RFC (Request for Comments) documents for community feedback on design changes and improvements to PowerShell ecosystem
PowerShell
417
star
14

Crescendo

a module for wrapping native applications in a PowerShell function and module
PowerShell
378
star
15

PowerShell-Docker

Repository for building PowerShell Docker images
Dockerfile
377
star
16

SecretManagement

PowerShell module to consistent usage of secrets through different extension vaults
C#
302
star
17

JEA

Just Enough Administration
PowerShell
253
star
18

Operation-Validation-Framework

PowerShell
223
star
19

PowerShellGallery

PowerShell
210
star
20

SHiPS

Simple Hierarchy in PowerShell - developing PowerShell provider got so much easier
C#
184
star
21

PSSwagger

The cmdlet generator from OpenAPI (f.k.a Swagger) specification
PowerShell
163
star
22

PowerShellStandard

C#
158
star
23

SecretStore

C#
147
star
24

PSPrivateGallery

DSC Resources and Configurations to deploy and manage Private PowerShell Gallery
PowerShell
147
star
25

WindowsCompatibility

Module that allows Windows PowerShell Modules to be used from PSCore6
PowerShell
135
star
26

PowerShell-Tests

Pester based tests for testing PowerShell
PowerShell
128
star
27

GPRegistryPolicyParser

PowerShell
128
star
28

PSDscResources

PowerShell
128
star
29

EditorSyntax

Syntax highlighting files for editors (VSCode, Atom, SublimeText, TextMate, etc) and GitHub!
PowerShell
122
star
30

CompletionPredictor

C#
118
star
31

DSC

This repo is for the DSC v3 project
Rust
113
star
32

Modules

C#
111
star
33

Phosphor

A library and PowerShell module for generating user interfaces from PowerShell modules
TypeScript
109
star
34

psl-omi-provider

PSRP Linux support library
C
100
star
35

GPRegistryPolicy

PowerShell
99
star
36

Microsoft.PowerShell.Archive

Archive PowerShell module contains cmdlets for working with ZIP archives
C#
92
star
37

Community-Blog

Submissions for posts to the PowerShell Community Blog -https://devblogs.microsoft.com/powershell-community
90
star
38

PSArm

PSArm is a PowerShell module that provides a PowerShell-embedded domain-specific language (DSL) for Azure Resource Manager (ARM) templates
C#
77
star
39

Remotely

Enable remote execution of scripts. Works with Pester.
PowerShell
75
star
40

TextUtility

Microsoft.PowerShell.TextUtility module
C#
60
star
41

Demo_CI

PowerShell
56
star
42

DscResource.Tests

Common meta tests for PowerShell DSC resources repositories.
PowerShell
51
star
43

PSDesiredStateConfiguration

Source for https://www.powershellgallery.com/packages/PSDesiredStateConfiguration module
PowerShell
49
star
44

Whitepapers

Staging area for new documents and whitepapers
46
star
45

PowerShell-Native

C++
44
star
46

AzurePSDrive

Navigate Azure Resources Just like A FileSystem
PowerShell
41
star
47

ContainerProvider

ContainerImageProvider
PowerShell
38
star
48

PackageManagementProviderResource

Modules with DSC resources for the PackageManagement(aka OneGet) providers.
PowerShell
37
star
49

PrivateCloud.DiagnosticInfo

PowerShell
37
star
50

Pager

Project for console pager, which is published as a NuGet package Microsoft.PowerShell.Pager
C#
34
star
51

PowerShellGet

This module provide functions used with PowerShellGet v3 to provide compatibility with scripts expecting PowerShellGet v2
PowerShell
33
star
52

PlasterBuild

Provides common build tasks for PowerShell module projects
PowerShell
29
star
53

CimPSDrive

SHiPS based provider to navigate CIM classes and namespaces
PowerShell
27
star
54

DscConfigurations

PowerShell
27
star
55

MarkdownRender

C#
27
star
56

SelfSignedCertificate

A module for generating self-signed certificates in PowerShell Core
PowerShell
25
star
57

GitHub-Actions

PowerShell
25
star
58

MMI

C#
25
star
59

tree-sitter-PowerShell

JavaScript
24
star
60

PowerShell-Snap

PowerShell
24
star
61

Microsoft.PowerShell.Kubectl

PowerShell module to manage Kubernetes
PowerShell
23
star
62

ODataUtils

PowerShell Module to generate cmdlets from an OData endpoint
PowerShell
22
star
63

DSC-Samples

Samples and tutorials for DSC v3
Go
21
star
64

WmiNamespaceSecurityDsc

This module contains DSC resources to manage WMI Namespace Security.
PowerShell
21
star
65

ThreadJob

PowerShell
21
star
66

FileUtility

C#
21
star
67

LibreSSL

C
19
star
68

UnixCompleters

C#
18
star
69

underhanded-powershell

Underhanded PowerShell Contest Repository
PowerShell
18
star
70

Hardware-Management-Module

PowerShell
17
star
71

Homebrew-Tap

Ruby
16
star
72

generator-powershell

Create PowerShell modules and scripts using Yeoman!
JavaScript
16
star
73

JsonAdapter

C#
13
star
74

Announcements

PowerShell Team Announcements
12
star
75

PowerShellModuleCoverage

Track issues related to using Windows PowerShell modules with PowerShell
12
star
76

PSRelease

PowerShell
11
star
77

whatsnew

PowerShell
11
star
78

AwsDscToolkit

AWS DSC Toolkit
PowerShell
10
star
79

DscResource.Template

PowerShell
10
star
80

TemplateConfig

Provides template for organizing DSC configuration scripts and supporting modules
PowerShell
10
star
81

SmartPackageProvider

A PackageManagement provider to find and install packages using search engines
C#
9
star
82

SystemLocaleDsc

DSC Resource for configuring Windows System Locale
PowerShell
8
star
83

ZLib

C
8
star
84

xDisk

PowerShell
8
star
85

psl-pester

Fork of Pester for compatibility with PowerShell on Linux.
PowerShell
8
star
86

PowerShell-Blog-Samples

Samples for the PowerShell blog
PowerShell
7
star
87

AWSBootStrapper

PowerShell
6
star
88

WSAProvider

A PackageManagement provider to find and install packages for Appx based packaging format
PowerShell
6
star
89

command-not-found

C#
6
star
90

PowerShellGetDsc

DSCResources for the PowerShellGet module
PowerShell
5
star
91

DscConfiguration.Tests

Test automation scripts for evaluating the quality of DSC Configurations using Azure virtual machines and Azure Automation DSC.
PowerShell
5
star
92

SILDeploymentHelper

PowerShell
4
star
93

vscode-powershellise-keybindings

A Visual Studio Code extension that configures PowerShell ISE keybindings.
TypeScript
4
star
94

PSPackageProject

PowerShell
4
star
95

Compliance

3
star
96

.github

3
star
97

ISEAddOnExamples

3
star
98

pscore-docs-dotnet

PowerShell
2
star
99

JsonAdapterFeedbackPredictor

1
star