Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
briantist committed Jul 9, 2017
1 parent ae8303a commit b032c72
Showing 1 changed file with 54 additions and 12 deletions.
66 changes: 54 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,63 @@
[![Build status](https://ci.appveyor.com/api/projects/status/krw5r7k42j5v2wxq?svg=true)](https://ci.appveyor.com/project/briantist/idempotion)
# Idempotion

# Installation

Please install directly from [PowerShell Gallery](https://www.powershellgallery.com/packages/Idempotion/):

```PowerShell
Install-Module -Name Idempotion
```

# About Idempotion

Idempotion is a PowerShell module designed to allow use of DSC resources as imperative commands.

The idempotent nature of DSC resources is sometimes desirable in a scenario where generating static configurations tied to a specific node doesn't make sense.

Idempotion allows you to use existing, well-tested logic as part of scripts so you don't have to reinvent the wheel.

## Quick Example
Essentially it turns this:

```PowerShell
Invoke-DscResource -Name File -ModuleName PSDesiredStateConfiguration -Method Set -Property @{ DestinationPath = 'C:\Folder\File.txt' ; Contents = 'Hello' }
```

into this:

```PowerShell
Set-File -DestinationPath 'C:\Folder\File.txt -Contents 'Hello'
```

---

Or even better, it turns this:

```PowerShell
$params = @{
DestinationPath = 'C:\Folder\File.txt'
Contents = 'Hello'
}
if (-not (Invoke-DscResource -Name File -ModuleName PSDesiredStateConfiguration -Method Test -Property $params)) {
Invoke-DscResource -Name File -ModuleName PSDesiredStateConfiguration -Method Set -Property $params
}
```

Into this:

```PowerShell
Update-File -DestinationPath 'C:\Folder\File.txt -Contents 'Hello'
```

### More Features:

* Mock `-WhatIf` support (`Invoke-DscResource` cannot use `-WhatIf`)
* All commands returned in a module for ease of use and namespace issues (`-Prefix`)
* Overridable template for generated functions
* Control which verb(s) you want generated, and which properties of the resource become parameters
* Generate functions as a string for injection into remote sessions or saving to a file

## Quick Sample

Need to check whether a system has a pending reboot? [There's a DSC Module for that (xPendingReboot)](https://www.powershellgallery.com/packages/xPendingReboot/) that checks 5 different locations in the system where a pending reboot might be set. But what if you need that functionality in a script?

Expand All @@ -24,25 +74,17 @@ Get-xPendingReboot
# Testing
if (Test-xPendingReboot) {
if (-not (Test-xPendingReboot)) {
throw 'Your computer requires a reboot.'
}
# Here we don't care about a pending file rename
if (Test-xPendingReboot -SkipPendingFileRename $true) {
if (-not (Test-xPendingReboot -SkipPendingFileRename $true)) {
# etc.
}
```

The parameters come directly from the properties of the DSC resource. Try it with `-Verbose` to see the full DSC-style output; saving you from writing additional logging code.

_More documentation coming soon._

# Installation

Please install directly from [PowerShell Gallery](https://www.powershellgallery.com/packages/Idempotion/):

```PowerShell
Install-Module -Name Idempotion
```

0 comments on commit b032c72

Please sign in to comment.