Forge Home

powershell

A PowerShell provider for puppet.

288,821 downloads

286,106 latest version

4.1 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
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.

Support the Puppet Community by contributing to this module

You are welcome to contribute to this module by suggesting new features, currency updates, or fixes. Every contribution is valuable to help ensure that the module remains compatible with the latest Puppet versions and continues to meet community needs. Complete the following steps:

  1. Review the module’s contribution guidelines and any licenses. Ensure that your planned contribution aligns with the author’s standards and any legal requirements.
  2. Fork the repository on GitHub, make changes on a branch of your fork, and submit a pull request. The pull request must clearly document your proposed change.

For questions about updating the module, contact the module’s author.

Version information

  • 0.0.6 (latest)
  • 0.0.5
  • 0.0.4
  • 0.0.2
  • 0.0.1
released Sep 17th 2013

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'joshcooper-powershell', '0.0.6'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add joshcooper-powershell
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install joshcooper-powershell --version 0.0.6

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

joshcooper/powershell — version 0.0.6 Sep 17th 2013

powershell

##Overview

This module adds an exec provider allowing Puppet to execute PowerShell commands.

##Module Description

Puppet provides a built-in exec type that is capable of executing commands. This module adds a powershell provider for the exec type, and as such, supports all of the exec parameters like creates, onlyif, unless, etc.

##Setup

###Beginning with powershell

The best way to install this module is with the puppet module subcommand or the puppet-module Gem. On your puppet master, execute the following command, optionally specifying your puppet master's modulepath in which to install the module:

$ puppet module install [--modulepath <path>] joshcooper/powershell

See the section Installing Modules for more information.

##Usage

To rename the Guest account:

exec { 'rename-guest':
  command   => '$(Get-WMIObject Win32_UserAccount -Filter "Name=\'guest\'").Rename("new-guest")',
  unless    => 'if (Get-WmiObject Win32_UserAccount -Filter "Name=\'guest\'") { exit 1 }',
  provider  => powershell,
}

Notice that the command parameter is single-quoted to prevent puppet from interpolating $(..). Also note that the example uses the unless parameter to make the resource idempotent. The command is only executed if the Guest account does not exist, as indicated by unless returning 0.

The powershell provider also supports the onlyif exec parameter. See the exec resource for more information about these parameters.

##Limitations

  • This module requires PowerShell to be installed and the powershell.exe to be available in the system PATH.
  • Be careful when using PowerShell variables, e.g. $_, as they must be escaped in puppet manifests either using backslashes or single quotes.

##License

Apache License, Version 2.0