Giter Site home page Giter Site logo

puppetlabs-powershell's Introduction

Microsoft Windows PowerShell module for Puppet

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

Installation

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.

Installation from source

If you'd like to install this module from source, please simply clone a copy into your puppet master's modulepath. Here is an example of how to do so for Puppet Enterprise:

$ cd /etc/puppetlabs/puppet/modules $ git clone
git://github.com/joshcooper/puppetlabs-powershell.git powershell

Examples

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.

License

Apache License, Version 2.0

Contact

Known Issues

  • This module requires PowerShell to be installed and the powershell.exe to be available in the system PATH.
  • On 32-bit versions of Windows, puppet will always invoke the 32-bit version of powershell.exe due to file system redirection.
  • Be careful when using PowerShell variables, e.g. $_, as they must be escaped in puppet manifests either using backslashes or single quotes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.