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.
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 :
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
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"
}
]
}
# 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
The PSRemotely docs will include more information, including :
Thanks goes to :
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 :
Feel free to submit any ideas, bugs or pull requests.