Skip to content
Remote operations validation framework, exposes a DSL to wrap existing Pester/PoshSpec based validation tests.
Branch: master
Clone or download
DexterPOSH Feature splathash & build refactor (#63)
* [WIP] Add function to sanitize splat hash passed to Pester on remote nodes

* [WIP] Adds unit tests for the Sanitize-PesterSplathash func

* [WIP] Adds parameter -PesterSplatHash

- work done for JSON parameterset
- TODO the bootstrap parameterset

* [WIP] Fixes typo in the tests, replace $reservedKey with $key

* Refactors the build steps

* Sets the project root in the Build task
Latest commit 8060742 Sep 2, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Build Feature splathash & build refactor (#63) Sep 2, 2018
PSRemotely Feature splathash & build refactor (#63) Sep 2, 2018
Tests Feature splathash & build refactor (#63) Sep 2, 2018
docs v1.0.3 release Jun 5, 2017
.gitignore Initial commit. May 8, 2015
Contributing.md Develop (#43) Jan 18, 2017
LICENSE Initial commit May 8, 2015
PITCHME.md v1.0.3 release Jun 5, 2017
PITCHME.yaml v1.0.3 release Jun 5, 2017
PSRemotely.png
README.md [skip ci] cosmetic changes to README.md Jun 5, 2017
_config.yml Set theme jekyll-theme-hacker Dec 20, 2016
appveyor.yml Feature splathash & build refactor (#63) Sep 2, 2018
mkdocs.yml [skip ci] Adds node based targeting doc May 4, 2017

README.md

Build status Documentation Status GitPitch

alt

PSRemotely, started as a fork of the Remotely project and over the time grew out of it. In a nutshell it let's you execute Pester tests against a remote machine. PSRemotely can use PoshSpec style infrastucture validation tests too.

Note - In the code & documentation the term 'Remotely' and 'PSRemotely' refer to the same.

It supports copying of the modules and artifacts to the remote node before the Pester tests are run.

Description

PSRemotely exposes a DSL which makes it easy to run Pester tests on the remote nodes. If you already have pester tests then you need to just wrap them inside the PSRemotely keyword and specify the node information using the Node keyword.

PSRemotely workflow is as under :

  1. Read PSRemotely.json file to determine the path & modules to be used on the remote nodes.
  2. Bootstrap the remote nodes, this involves
    • Testing the remote node path exists.
    • All the modules required are copied from the Lib/ folder to the remote node.
  3. Drop the Pester tests (Describe blocks) as individual tests file on the remote node. Also copy the items defined in the PSRemotely.json, which are placed under Artifacts/ folder inside local PSRemotely folder.
  4. Invoke the tests using background jobs on the remote nodes and wait for these jobs to complete, finally process and output a JSON object back.
  5. It also exports a global variable named $PSRemotely to which the Node bootstrap map and PSSession information is stored.

Remote Ops validation

Well this is a term coined by us for some of the infrastucture validation being done for Engineered solutions. So taking liberty to use this here.

Suppose, you already have below Pester test for some nodes in our environment:

Describe 'Bits Service test' {
    
    $BitsService = Get-Service -Name Bits
    
    It "Should have a service named bits" {
        $BitsService | Should Not BeNullOrEmpty
    }
    
    it 'Should be running' {
        $BitsService.Status | Should be 'Running'
    }
}

If you want to target the very same tests on the remote node named say AD,WDS & DHCP from your current workstation (part of the same domain), you can use PSRemotely.

Usage with PSRemotely:

PSRemotely {
	
    Node AD, WDS, DHCP {
		
        Describe 'Bits Service test' {
		
            $BitsService = Get-Service -Name Bits
            
            It "Should have a service named bits" {
                $BitsService | Should Not BeNullOrEmpty
            }
            
            It 'Should be running' {
                $BitsService.Status | Should be 'Running'
            }
        }		
	}
}

Once you have the tests file ready , save it with a .PSRemotely.ps1 extension, below is how you invoke the PSRemotely framework to start the remote ops validation :

Invoke-PSRemotely -Script <FileName>.PSRemotely.ps1

Output of the above is a JSON object, if the tests pass then an empty JSON object array of TestResult is returned otherwise the Error record thrown by Pester is returned :

{
    "Status":  true,
    "NodeName":  "WDS",
    "Tests":  [
                  {
                      "TestResult":  [

                                     ],
                      "Result":  true,
                      "Name":  "Bits Service test"
                  }
              ]
}
{
    "Status":  true,
    "NodeName":  "AD",
    "Tests":  [
                  {
                      "TestResult":  [

                                     ],
                      "Result":  true,
                      "Name":  "Bits Service test"
                  }
              ]
}
{
    "Status":  true,
    "NodeName":  "DHCP",
    "Tests":  [
                  {
                      "TestResult":  [

                                     ],
                      "Result":  true,
                      "Name":  "Bits Service test"
                  }
              ]
}

Initial PSRemotely setup

# One time setup
    # Download the repository
    # Unblock the zip
    # Extract the PSRemotely folder to a module path (e.g. $env:USERPROFILE\Documents\WindowsPowerShell\Modules\)

    #Simple alternative, if you have PowerShell 5, or the PowerShellGet module:
        Install-Module PSRemotely

# Import the module.
    Import-Module PSRemotely    # Alternatively, Import-Module \\Path\To\PSRemotely

# Get commands in the module
    Get-Command -Module PSRemotely

# Get help for the module and a command
    
    Get-Help Invoke-PSRemotely -full

More Information

The PSRemotely docs will include more information, including :

  • PSRemotely Basics
  • PSRemotely Examples
  • PSRemotely How Tos

Notes

Thanks goes to :

  • Remotely project
  • Ravikanth Chaganti - For all the help with the ideas and motivation behind the scenes.
  • Warren Frame's PSDeploy module - have been following Warren's module & documentation structure to organize.
  • [Pester module] (https://github.com/pester/pester), PSDesiredStateConfiguration module for borrowing some of the ideas.
  • PowerShell community & fellow MVPs, who are fantastic at helping each other.

TO DO

PSRemotely in its current form works for our needs to validate some of the Engineered solutions. But it has the potential to grow into something bigger, below are some of the items in the wishlist :

  • Use PowerShell classes, and add support for providers for nodes running either On-prem or on Cloud (AWS or Azure).
  • Integrate with JEA, since PSRemotely uses PSSession endpoints these can be locked down using JEA on the nodes.
  • More unit tests, lacking far behind in this aspect. More focus on it once we start working with the classes implementation.
  • Faster background processing of the remote node jobs, using runspaces.

Feel free to submit any ideas, bugs or pull requests.

You can’t perform that action at this time.