All Projects → fvanroie → PS_OPNsense

fvanroie / PS_OPNsense

Licence: MIT license
PowerShell Module for OPNsense REST api

Programming Languages

powershell
5483 projects
C#
18002 projects

Projects that are alternatives of or similar to PS OPNsense

Vrtk
*Beta* - An example of how to use the Tilia packages to create great content with VRTK v4.
Stars: ✭ 3,422 (+12574.07%)
Mutual labels:  beta, work-in-progress
vscode-xslt-tokenizer
VSCode extension for highlighting XSLT and XPath (upto 3.0/3.1)
Stars: ✭ 37 (+37.04%)
Mutual labels:  work-in-progress
cpptoswift
Hack that'll hopefully one day auto-generate a Swift wrapper around C++ source code.
Stars: ✭ 13 (-51.85%)
Mutual labels:  work-in-progress
ansible-opnsense
Ansible role to configure OPNsense firewalls
Stars: ✭ 78 (+188.89%)
Mutual labels:  opnsense
pf-azure-sentinel
Parse pfSense/OPNSense logs using Logstash, GeoIP tag entities, add additional context to logs, then send to Azure Sentinel for analysis.
Stars: ✭ 24 (-11.11%)
Mutual labels:  opnsense
smalldragon
[Work in Progress] Toy Compiler <3
Stars: ✭ 23 (-14.81%)
Mutual labels:  work-in-progress
Cookie-Clicker-Source-Code
Cookie Clicker source code for... educational purposes...
Stars: ✭ 74 (+174.07%)
Mutual labels:  beta
vektor
Opinionated production-grade HTTP server framework for Go
Stars: ✭ 86 (+218.52%)
Mutual labels:  beta
docker-introduction
Reproducible Computational Environments using Containers
Stars: ✭ 34 (+25.93%)
Mutual labels:  beta
deep-learning-intro
Learn Deep Learning with Python
Stars: ✭ 23 (-14.81%)
Mutual labels:  beta
pluralsight-downloader-chrome-extension
[WIP] A chrome extension to download and track Pluralsight courses. 😈
Stars: ✭ 227 (+740.74%)
Mutual labels:  beta
altstore
AltStore source with more stuff
Stars: ✭ 44 (+62.96%)
Mutual labels:  beta
UnboundBL
🛑 DNSBL (adblock) on OPNsense with UnboundBL & Unbound DNS
Stars: ✭ 63 (+133.33%)
Mutual labels:  opnsense
powervrni
PowervRNI: A PowerShell module to talk to the vRealize Network Insight API
Stars: ✭ 19 (-29.63%)
Mutual labels:  cmdlet
reggie
Stata-like Regression Functionality for R
Stars: ✭ 24 (-11.11%)
Mutual labels:  work-in-progress
PowerShell
A collection of useful PowerShell modules and scripts.
Stars: ✭ 37 (+37.04%)
Mutual labels:  cmdlet
PowerShell-Watch
A PowerShell Watch-Command cmdlet for repeatedly running a command or block of code until a change in the output occurs.
Stars: ✭ 49 (+81.48%)
Mutual labels:  cmdlet
infy-scroll
A web extension for Chrome, Edge, and Firefox. Add customized infinite scrolling to websites and auto load the next page. Supports the AutoPagerize Database. (Beta)
Stars: ✭ 70 (+159.26%)
Mutual labels:  beta
python-aos-lesson
Python for Atmosphere and Ocean Scientists
Stars: ✭ 78 (+188.89%)
Mutual labels:  beta
linguistic-datasets-portuguese
Linguistic Datasets for Portuguese: Lista de conjuntos de dados linguísticos para língua portuguesa com licença flexíveis: banco de dados, lista de palavras, sinônimos, antônimos, dicionário temático, tesauro, linked data, semântica, ontologia e representação de conhecimento
Stars: ✭ 46 (+70.37%)
Mutual labels:  work-in-progress

PS_OPNsense

About

This is a PowerShell module that uses the OPNsense REST api to manage OPNsense firewall appliances. The development of the OPNsense REST api and this PowerShell module is still ongoing, so additional functionality will be added in the future.

Supported Modules

Currently there are basic api hooks for these OPNsense modules:

  • Firmware
  • CaptivePortal
  • Cron
  • Diagnostics
  • IDS
  • Packages
  • Proxy
  • Services

Not all functionality is implemented yet and this is an early development alpha release. All testing and feedback is appreciated.

Supported Objects

Items

All CRUD items are supported using Get-OPNsenseItem, Remove-OPNsenseItem and Switch-OPNsenseItem. Creating and updating CRUD items is being worked on and not yet fully supported.

Packages

Full support to install, re-install, remove, lock and unlock OPNsense Packages and Plugins.

Settings

You can get the Settings for all API modules. Changing the Settings is not supported yet.

Services

Currently only Start, Stop, Update and Restart services are implemented for the other plugins. More work is needed to support all available REST api commands.

Firmware

Updating firmware via PowerShell is implemented.

Legacy Commands

There is legacy WebUI support for these commands:

  • Backup Config
  • Restore Config
  • Reset Factory Defaults

A minimal set of legacy commands are also available in this PowerShell module. Only crucial functionality that is not yet available via the REST api yet will be exposed using the WebUI. These cmdlets will be ported over to use the REST api functions when they are ported to the REST api when they are made available in future OPNsense firmware versions.

Getting Started

Install PS_OPNsense Module

To find out the location of the Modules directory, check the PSModulePath environment variable:

$Env:PSModulePath -split ";"    # On Windows
$Env:PSModulePath -split ":"    # On Linux

Change into the PowerShell Module directory located in your profile folder.

You can download and unzip the module into the PowerShell Modules folder or clone the repository directly:

git clone https://github.com/fvanroie/PS_OPNsense.git

Depending on your ExecutionPolicy, you might need to unblock the downloaded module files:

Get-ChildItem PS_OPNsense -Recurse | Unblock-File -Verbose

On newer system you also might open PS with administrative access and run:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

To load this module in PowerShell type:

Import-Module -Name PS_OPNsense -PassThru

Get all the commands in the PS_OPNsense module type:

Get-Command -Module PS_OPNsense

Create an API key in OPNsense

From the OPNsense GUI, create an API key for a user that will run PowerShell scripts:

  • Open System > Access > Users.
  • Click on a user that will be used for accessing the REST api.
  • Under the section API keys, click on the Add [+] button to generate a key/secret pair.
  • Download the txt file.
  • Use the key and secret values to connect to OPNsense REST api using Connect-OPNsense cmdlet below.

Examples

Connecting to an OPNsense server:

Connect-OPNsense -Uri 'http://opnsense.local:8080' -Key <api_key> -Secret <api_secret>
Connect-OPNsense -Uri 'https://opnsense.local' -Key <api_key> -Secret <api_secret> -Verbose -Debug
Connect-OPNsense 'https://opnsense.local' <api_key> <api_secret> -SkipCertificateCheck

Run some commands:

Get-OPNsenseItem -Cron Job
Get-OPNsensePackage -Plugin

Disconnect from the server:

Disconnect-OPNsense

Use the -Verbose and/or -Debug switches to see what is going on behind the scenes. You can use the output to learn more about the OPNsense REST api.

The project contains an Examples directory with more example scripts. For the full documentation of all the cmdlets and parameters, please visit the PS_OPNsense wiki.

Compatibility

This module is tested on:

Platform Edition Version
Windows 10 PowerShell Desktop 5.1
Windows 10 PowerShell Core 6.0
Ubuntu 18.04 PowerShell Core 6.0

PS_OPNsense aims to be cross-platform on PowerShell Core 6.0 and up, however it has not been extensively tested on MacOS yet. Let me know what works and what doesn't. Feel free to use it on these platforms and report back any issues you encouter. The goal is to make PS_OPNsense crossplatform with PowerShell Core.

Buy me a coffee

Buy me a coffee

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].