Version information
This version is compatible with:
- Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x
- Puppet >= 7.0.0 < 9.0.0
- , , , , , , ,
Start using this module
Add this module to your Puppetfile:
mod 'puppetlabs-pwshlib', '1.2.2'
Learn more about managing modules with a PuppetfileDocumentation
ruby-pwsh
The PowerShell gem.
This gem enables you to execute PowerShell from within ruby without having to instantiate and tear down a PowerShell process for each command called. It supports Windows PowerShell as well as PowerShell Core (and, soon, just PowerShell) - if you're running *PowerShell v3+, this gem supports you.
The Manager
class enables you to execute and interoperate with PowerShell from within ruby, leveraging the strengths of both languages as needed.
Installation
Add this line to your application's Gemfile:
gem 'ruby-pwsh'
And then execute:
bundle install
Or install it yourself as:
gem install ruby-pwsh
Usage
Instantiating the manager can be done using some defaults:
# Instantiate the manager for Windows PowerShell, using the default path and arguments
# Note that this takes a few seconds to instantiate.
posh = Pwsh::Manager.instance(Pwsh::Manager.powershell_path, Pwsh::Manager.powershell_args)
# If you try to create another manager with the same arguments it will reuse the existing one.
ps = Pwsh::Manager.instance(Pwsh::Manager.powershell_path, Pwsh::Manager.powershell_args)
# Note that this time the return is very fast.
# We can also use the defaults for PowerShell Core, though these only work if PowerShell is
# installed to the default paths - if it is installed anywhere else, you'll need to specify
# the full path to the pwsh executable.
pwsh = Pwsh::Manager.instance(Pwsh::Manager.pwsh_path, Pwsh::Manager.pwsh_args)
Execution can be done with relatively little additional work - pass the command string you want executed:
# Instantiate the Manager:
posh = Pwsh::Manager.instance(Pwsh::Manager.powershell_path, Pwsh::Manager.powershell_args)
# Pretty print the output of `$PSVersionTable` to validate the version of PowerShell running
# Note that the output is a hash with a few different keys, including stdout.
pp(posh.execute('$PSVersionTable'))
# Lets reduce the noise a little and retrieve just the version number:
# Note: We cast to a string because PSVersion is actually a Version object.
pp(posh.execute('[String]$PSVersionTable.PSVersion'))
# We could store this output to a ruby variable if we wanted, for further use:
ps_version = posh.execute('[String]$PSVersionTable.PSVersion')[:stdout].strip
pp("The PowerShell version of the currently running Manager is #{ps_version}")
Reference
You can find the full reference documentation online, here.
Supported Operating Systems
The following platforms are supported:
- Windows
- CentOS
- Debian
- Fedora
- OSX
- RedHat
- Ubuntu
- AlmaLinux
Limitations
- When PowerShell Script Block Logging is enabled, data marked as sensitive in your manifest may appear in these logs as plain text. It is highly recommended, by both Puppet and Microsoft, that you also enable Protected Event Logging alongside this to encrypt the logs to protect this information.
License
This codebase is licensed under Apache 2.0. However, the open source dependencies included in this codebase might be subject to other software licenses such as AGPL, GPL2.0, and MIT.
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
v1.2.2 - 2024-09-25
Fixed
- (CAT-2061) Fix empty string nullification #346 (david22swan)
v1.2.1 - 2024-09-20
Added
- AlmaLinux 8/9 added to metadata.json #338 (alex501212)
Fixed
- Revert "Fix empty string nullification" #342 (jordanbreen28)
- (maint) - Fix incorrect test for file_path #335 (jordanbreen28)
- (CAT-1991) - Skip missing dirs invalid_dir method #334 (jordanbreen28)
v1.2.0 - 2024-08-15
Added
- (CAT-1869) - Add configurable dsc_timeout #319 (jordanbreen28)
- Add support for unit testing via Unix OS #309 (chambersmp)
Fixed
- (bug) - Fix dsc timeout matcher #331 (jordanbreen28)
- Fix empty string nullification #292 (Clebam)
v1.1.1 - 2024-02-21
Fixed
- (CAT-1724) - Fix Provider returned data not matching Type Schema #295 (jordanbreen28)
- Fix enum idempotency #291 (Clebam)
v1.1.0 - 2024-01-31
Added
- (feat) - add retries on failed dsc invocation #282 (jordanbreen28)
Fixed
v1.0.1 - 2023-12-13
Fixed
- (CAT-1617) - Always load vendored module in PSModulePath #261 (jordanbreen28)
v1.0.0 - 2023-08-17
Changed
- (maint) - Drop Support for Debian 8/9 #227 (jordanbreen28)
- (maint) - Drop Support for Ubuntu 16.04 #226 (jordanbreen28)
- (maint) - Drop Support for Fedora 30&31 #225 (jordanbreen28)
- (maint) - Drop Support for OSX 10.14 #224 (jordanbreen28)
- (maint) - Drop Support for Windows 2008(R2)/7/8 #223 (jordanbreen28)
- (CAT-1172) - Add Puppet 8 Support/Drop Puppet 6 Support #221 (jordanbreen28)
Added
- (feat) - Add support for Ubuntu 22.04 #232 (jordanbreen28)
- (feat) - add Windows 11 & Server 2022 support #231 (jordanbreen28)
- (feat) - Add support for Fedora 36 #230 (jordanbreen28)
- (feat) - Add support for OSX 11&12 #229 (jordanbreen28)
- (feat) - Add support for Debian 11 #228 (jordanbreen28)
Fixed
- (bug) - Fixes missing mandatory ID #234 (jordanbreen28)
v0.11.0 - 2023-08-16
v0.11.0.rc.1 - 2023-04-17
Changed
v0.10.3 - 2022-12-19
Fixed
0.10.2 - 2022-06-24
Fixed
0.10.1 - 2021-08-23
Fixed
- (GH-180) Ensure instance_key respects full uniqueness of options #181 (michaeltlombardi)
- (GH-165) Ensure null-value nested cim instance arrays are appropriately munged #177 (michaeltlombardi)
0.10.0 - 2021-07-02
Added
- (GH-172) Enable use of class-based DSC Resources by munging PSModulePath #173 (michaeltlombardi)
0.9.0 - 2021-06-28
Added
- (GH-147) Refactor Invocation methods to use shared helper and write error logs when appropriate #152 (david22swan)
- (GH-145) Improve DSC secrets redaction #150 (michaeltlombardi)
- (GH-145) Add insync? and invoke_test_method to dsc provider #124 (michaeltlombardi)
Fixed
- (IAC-1657) Fix for invalid DateTime value error in
invoke_get_method
#169 (david22swan) - (GH-154) Ensure values returned from
invoke_get_method
are recursively sorted in the DSC Base Provider to reduce canonicalization warnings. #160 (michaeltlombardi) - (GH-154) Fix return data from
Invoke-DscResource
for empty strings and single item arrays in DSC Base Provider #159 (michaeltlombardi) - (GH-155) Fix CIM Instance munging in
invoke_get_method
for DSC Base Provider #158 (michaeltlombardi) - (GH-154) Fix canonicalization in
get
method for DSC Base Provider #157 (michaeltlombardi) - (GH-144) Enable order-insensitive comparisons for DSC #151 (michaeltlombardi)
- (GH-143) Handle order insensitive arrays in the
same?
method of the DSC Base Provider #148 (michaeltlombardi) - (GH-127) Canonicalize enums correctly #131 (michaeltlombardi)
- (GH-125) Fix dsc provider canonicalization for absent resources #129 (michaeltlombardi)
- (MODULES-11051) Ensure environment variables are not incorrectly munged in the PowerShell Host #128 (michaeltlombardi)
- (MODULES-11026) Ensure the PowerShell manager works with v7 #122 (n3snah)
- (Maint) Ensure canonicalize correctly compares sorted hashes #118 (Hvid)
0.8.0 - 2021-03-01
Added
- (MAINT) Clarify supported platforms #113 (michaeltlombardi)
0.7.4 - 2021-02-11
Fixed
- (GH-105) Ensure set runs on ambiguous ensure states #108 (michaeltlombardi)
- (GH-105) Ensure canonicalized_cache check validates against namevar #107 (michaeltlombardi)
0.7.3 - 2021-02-03
Fixed
0.7.2 - 2021-02-03
Fixed
- (GH-97) Memoize class variables in initialize #98 (michaeltlombardi)
- (MAINT) Ensure is_same check works for nil manifest values #96 (bwilcox)
0.7.1 - 2021-02-02
Fixed
- (MAINT) Correctly canonicalize enumerable values in dsc #92 (michaeltlombardi)
- (MAINT) Ensure vendored path check works with mix of module builds #91 (michaeltlombardi)
- (GH-84) Fix empty array parameter check #90 (michaeltlombardi)
- (MAINT) Minor fixes to CIM instance handling #89 (michaeltlombardi)
0.7.0 - 2021-01-20
Added
Fixed
- Make root module path use puppetized module name #86 (michaeltlombardi)
0.6.3 - 2021-01-12
Fixed
- (MAINT) Add handling for when dsc_ensure is stripped #78 (michaeltlombardi)
0.6.2 - 2020-12-09
Fixed
- (MAINT) Ensure parameters are canonicalized #75 (michaeltlombardi)
0.6.1 - 2020-11-25
Fixed
- (maint) - Removal of inappropriate terminology #70 (pmcmaw)
- (Maint) Fix ensurability in the dsc base provider #69 (michaeltlombardi)
0.6.0 - 2020-11-24
Added
- (GH-81) Handle parameters in the dsc base provider #62 (michaeltlombardi)
- (GH-74) Remove special handling for ensure in the dsc base provider #61 (michaeltlombardi)
- (GH-59) Refactor away from Simple Provider #60 (michaeltlombardi)
Fixed
- (GH-57) Handle datetimes in dsc #58 (michaeltlombardi)
- (GH-55) Handle intentionally empty arrays #56 (michaeltlombardi)
0.5.1 - 2020-09-25
Fixed
- (MAINT) Ensure dsc provider finds dsc resources during agent run #45 (michaeltlombardi)
0.5.0 - 2020-08-20
Added
- (IAC-1045) Add the DSC base Puppet provider to pwshlib #39 (michaeltlombardi)
0.4.1 - 2020-02-12
Fixed
0.4.0 - 2020-01-13
Added
- (MODULES-10389) Add puppet feature for dependent modules to leverage #20 (sanfrancrisko)
0.3.0 - 2019-12-04
Added
- (FEAT) Add method for symbolizing hash keys #16 (michaeltlombardi)
Fixed
- (FEAT) Ensure hash key casing methods work on arrays #15 (michaeltlombardi)
0.2.0 - 2019-11-25
Added
- (FEAT) Add quality of life utilities #11 (michaeltlombardi)
- (FM-8422) Make library releasable as a Puppet module #8 (michaeltlombardi)
0.1.0 - 2019-09-25
Quality checks
We run a couple of automated scans to help you assess a module’s quality. Each module is given a score based on how well the author has formatted their code and documentation and select modules are also checked for malware using VirusTotal.
Please note, the information below is for guidance only and neither of these methods should be considered an endorsement by Puppet.
Malware scan results
The malware detection service on Puppet Forge is an automated process that identifies known malware in module releases before they’re published. It is not intended to replace your own virus scanning solution.
Learn more about malware scans- Module name:
- puppetlabs-pwshlib
- Module version:
- 1.2.2
- Scan initiated:
- September 25th 2024, 7:33:37
- Detections:
- 0 / 63
- Scan stats:
- 63 undetected
- 0 harmless
- 0 failures
- 0 timeouts
- 0 malicious
- 0 suspicious
- 14 unsupported
- Scan report:
- View the detailed scan report