Giter Site home page Giter Site logo

odatautils's Introduction

Microsoft.PowerShell.ODataUtils Module

Microsoft.PowerShell.ODataUtils module generates CDXML modules that contain cmdlets to manage OData and Redfish endpoints.

Master
Build status

Building

  1. Ensure that .NET Command Line Interface tools are installed.
  2. Run build.ps1
  3. Successfull build will generate Microsoft.PowerShell.ODataUtils module folder that can be copied to a target PowerShell deployment.

Examples

Using Redfish server from PowerShell Core

Import-Module Microsoft.PowerShell.ODataUtils -Force
# generate CDXML module based on metadata of Redfish server
Export-ODataEndpointProxy -Uri 'https://<redfishserver>/redfish/v1/' -OutputModule '/home/test/RedfishModule' -Force -CmdletAdapter ODataV4Adapter -AllowUnsecureConnection -SkipCertificateCheck
Import-Module '/home/test/RedfishModule' -Force
$c = Get-Credential # credentials for server
# manage server using Redfish - retrieve ComputerSystems on the server
Get-ServiceRoot -SkipCertificateCheck | Get-ComputerSystemCollection -Credential $c -SkipCertificateCheck | Get-ComputerSystem -Credential $c -SkipCertificateCheck

Using Redfish server from Windows PowerShell

Import-Module Microsoft.PowerShell.ODataUtils -Force
# some preparation work for connection to a Redfish endpoint
# enable TLS v1.1 as required by Redfish spec
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [System.Net.SecurityProtocolType]::Tls11
# allow self-signed server certificates
if ([System.Net.ServicePointManager]::CertificatePolicy.GetType().Name -ne 'TrustAllCertsPolicy')
{
    Add-Type 'using System.Net;using System.Security.Cryptography.X509Certificates;public class TrustAllCertsPolicy:ICertificatePolicy {public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate,WebRequest request, int certificateProblem) {return true;}}'
    [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
}
# Generate CDXML module based on endpoint metadata
Export-ODataEndpointProxy -Uri https://<redfishserver>/redfish/v1/ -OutputModule C:\Temp\RedfishTest -Force -CmdletAdapter ODataV4Adapter -AllowUnsecureConnection
$c = Get-Credential # credentials for server
Import-Module C:\Temp\RedfishTest –Force
# manage server using Redfish
# example 1 - retrieve ComputerSystems on the server
$r = Get-ServiceRoot
$cc = Get-ComputerSystemCollection -ServiceRoot $r -Credential $c
$cs = Get-ComputerSystem -ComputerSystemCollection $cc -Credential $c
$cs
# example 2 - retrieve Chassis on the server
Get-ServiceRoot | Get-ChassisCollection -Credential $c | Get-Chassis -Credential $c

odatautils's People

Contributors

anmenaga avatar stevel-msft avatar stevel-powershell avatar

Watchers

Siddharth Joshi avatar

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.