Skip to content

oracle/oci-powershell-modules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oracle Cloud Infrastructure Modules for PowerShell

About

Oracle Cloud Infrastructure(OCI) Modules for PowerShell is a set of cmdlet modules that can be used with PowerShell Core to manage Oracle Cloud Infrastructure resources. You can invoke these cmdlets from the PowerShell command-line and with the associated PowerShell scripting language.

The project is open source and maintained by Oracle Corp.

Supported PowerShell Versions

  • PowerShell Core 6.0 and higher

Installation

From PowerShell Gallery:

The modules are published to PowerShell Gallery.

Install the modules from PowerShell Gallery using Install-Module as explained here.

#Install module for Audit Service
Install-Module OCI.PSModules.Audit

To install all OCI modules:

Install-Module OCI.PSModules

Note: Uninstalling OCI.PSModules will not uninstall other OCI modules. To uninstall a specific OCI module installed by this module, OCI.PSModules will have to be uninstalled first.

From Github:

PowerShell modules are published to GitHub.

  • Download oci-psmodules-artifacts-<version>.zip file attached to the latest release in the Assets section.
  • Extract oci-psmodules-artifacts-<version>.zip to a local directory.
  • Register the extracted directory as the local PowerShell repository using the following cmdlet:
    Register-PSRepository -Name "LocalRepo" -SourceLocation <extractedlocation>
  • Find the modules available in the local repository using the following cmdlet:
    Find-Module -Repository "LocalRepo"
  • Install the desired module:
    Install-Module -Name OCI.PSModules.Objectstorage -Verbose -Repository LocalRepo
    Install-Module -Name OCI.PSModules.Core -Verbose -Repository LocalRepo

Configuring

Before using the cmdlets, set up a config file with the required credentials. Refer setup for instructions.

Import-Module OCI.PSModules.Common

#To setup a new config file
Set-OCIClientConfig

Examples

Some examples can be found here.

Building and Testing

Build

Modules can be built at the solution level or at the individual project level under the solution folder. At the root level, to build all the modules, run the dotnet cli command:

dotnet build

Alternatively, individual projects(modules) can be built by using dotnet cli commands inside project directory.

Test

  1. The repository has some Pester unit test scripts unit tests. These test scripts can be run in PowerShell.
#Install Pester module
Install-Module -Name Pester

#Dot-source common utilities for tests
. ./Common.ps1

#Set the path to config file in an env variable
([Environment]::SetEnvironmentVariable("ConfigFile", "~/.oci/config"))

#Run individual test script
Invoke-Pester ./<<Test-Script>>.ps1

#Run all test scripts
Invoke-Pester
  1. To test code changes, publish and import the service module.

Individual services can be published by executing the dotnet publish command from inside the project directory.

#Navigate to the project directory
cd <<ServiceName>>

#Publish assemblies
dotnet publish -o assemblies/

If you haven't loaded the required common module dependecy in your PowerShell session previously, load the common module.

cd ./oci-powershell-modules/Common/

Import-Module ./OCI.PSModules.Common.psd1

Import the published module into current PowerShell session from inside the project directory.

Import-Module OCI.PSModules.<<ServiceName>>.psd1

Help

The Issues page of this GitHub repository. To raise questions on Stack Overflow, use the oracle-cloud-infrastructure and oci-powershell-modules tags in your post. Developer Tools section of the Oracle Cloud forums. My Oracle Support.

Contributing

This project welcomes contributions from the community. Before submitting a pull request, please review our contribution guide

Security

Please consult the security guide for our responsible security vulnerability disclosure process

License

Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0; third-party content is separately licensed as described in the code.

See LICENSE for more details.

Changes

See CHANGELOG

Known Issues

You can find information on any known issues with the OCI modules for PowerShell at Oracle Cloud Infrastructure Known Issues and under the Issues tab of this project's GitHub repository.

Related Links

Read more about OCI Modules for PowerShell at https://docs.cloud.oracle.com/en-us/iaas/Content/API/SDKDocs/powershell.htm