• Stars
    star
    152
  • Rank 244,685 (Top 5 %)
  • Language
    PowerShell
  • License
    MIT License
  • Created about 9 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A wrapper for Get-Credential offering options that it should have offered

The Better Credentials Module

The goal of BetterCredentials is to provide a completely backwards-compatible Get-Credential command that enhances the in-the-box Get-Credential by adding additional features which are missing from the built-in command. Specifically, storing credentials for automation, and providing more complete prompts with an explanation of what the credentials are for.

TO INSTALL:

Use the PowerShellGet module included in WMF (PowerShell) 5, or the PackageManagement Preview for PowerShell 3 and 4.

Just run:

    Install-Module BetterCredentials -AllowClobber

The -AllowClobber switch is to allow the BetterCredentials module to do what it's designed to do: provide you a better, backwards compatible Get-Credential command, clobbering the built-in version.

Features

Prompting

The original motivation for writing BetterCredentials was to take advantage of some of the features of PowerShell's underlying credential API which are inexplicably ignored in the built-in Get-Credential, particularly to allow one-off prompting for passwords inline (that is, in the console, instead of via the credentials dialog), without having to resort to a configuration change.

You can use the -Inline switch to force prompting in the host instead of with a popup dialog, or even pass in a -Password value (secure string or not, I won't judge) which allows you to easily create credential objects without a prompt at all.

Additionally, you can set the -Title parameter to control the text that's show at the top of the prompt window, and even set the -Description parameter to add text in the prompt.

Storage

Despite the fact that this feature arrived late in the life of BetterCredentials, clearly the best feature is the fact that it can store your passwords in the Windows Credential Manager (sometimes called the Vault), and retrive them on demand so you don't have to enter them over and over. The Windows Credential Manager is what's used by Internet Explorer and Remote Desktop to store passwords, and it keeps them safely encrypted to your account and machine, and provides a user interface where they can be securely reviewed, deleted or even modified.

On our BetterCredentials\Get-Credential command, the -Store switch causes the returned credentials to be stored in the vault, and the -Delete switch makes sure they are not. As of version 4.5, you can also use the Set-Credential and Remove-Credental commands to explicitly store or remove credentials.

Once you've stored credentials in the vault, future requests for the same credential -- where you pass in a username (and optionally, a domain) will simply return the credentials without prompting. Because of this, there is also a -Force switch (alias: -New) which prevents loading and forces the prompt to be displayed. When you need to change a stored password, use both together:

BetterCredentials\Get-Credential -Force -Store

Additionally, in 4.5 there are two commands for searching and/or testing for credentials in the vault: Find-Credential and Test-Credential...

Unattended Usage

When Get-Credential is called from a script running unattended, e.g. in a scheduled task, script execution will hang prompting for credentials if there is no credential in the vault corresponding to the given username. Normally one might execute Get-Credential username -Store to populate the credential vault prior to putting the scheduled task into production, but might also forget to do so. In version 4.5 the new Test-Credential command solves the script hanging problem by returning a true or false value depending on whether a credential corresponding to a user name is currently stored in the vault.

NOTES

In my scripts and sample code, I nearly always use BetterCredentials\Get-Credential as a way to make sure that I'm invoking this overload of Get-Credential, but the idea is that you can simply import the BetterCredentials module in your profile and automatically get this overload whenever you're calling Get-Credential. Of course, I haven't (yet) overloaded the [Credential] transform attribute, so the automatic prompting when you pass a user name to a -Credential attribute doesn't use my module -- you have to explicitly call Get-Credential.

Licensed under MIT license, see License.

More Repositories

1

PowerLine

A more PowerShell prompt
PowerShell
567
star
2

Jupyter-PowerShell

Jupyter Kernel for PowerShell
Jupyter Notebook
109
star
3

PoshConsole

PoshConsole is a WPF control that self-hosts PowerShell, a framework for building PowerShell-based managment apps!
C#
77
star
4

Tunable-SSL-Validator

A .Net class and PowerShell module to enable best practices for SSL validation even with self-signed certificates.
PowerShell
58
star
5

NancyPS

NancyPS was Nancy self-hosted in PowerShell, with script method handlers
PowerShell
42
star
6

Profile

Because people always wish they could see your profile...
PowerShell
32
star
7

Environment

A module for working with Environment Variables and especially Path variables in a cross-platform way
PowerShell
26
star
8

HtmlReport

Making HTML reports with charts and tables, from templates, in PowerShell
PowerShell
26
star
9

BoxStarter-Boxes

BoxStarter and Chocolatey Scripts for setting up my computers
PowerShell
25
star
10

Xml

My PowerShell XML module: generate, select, transform and work with XML
PowerShell
25
star
11

TreeSize

An exercise in live coding.
PowerShell
22
star
12

RequiredModules

A simpler tool for installing dependencies
PowerShell
21
star
13

PowerSite

A static page generator in .Net that is PowerShell friendly
C#
20
star
14

Reflection

A PowerShell module for introspection and code generation in .Net and PowerShell
PowerShell
19
star
15

PTUI

A PowerShell module for cross-platform TUI experiments
PowerShell
16
star
16

Spinner

A function to make console spinners from PowerShell...
PowerShell
16
star
17

ParameterTester

Wrappers for testing command parameters
PowerShell
14
star
18

WindowsConsoleFonts

A module for working with Console fonts in Windows
C#
13
star
19

EzTheme

An extensible module for PowerShell color themes
PowerShell
12
star
20

Authenticode

Code-signing wrapper functions for PowerShell to make it easier to work.
PowerShell
12
star
21

WASP

A Windows Automation Script module for Powershell
PowerShell
12
star
22

TerminalBlocks

PowerShell
10
star
23

DevOps2019

Presentation for PowerShell + DevOps Global Summit, 2019
HTML
10
star
24

Path

The [Path()] attribute for command parameters
PowerShell
9
star
25

PowerShellExtension

Helper classes for using PowerShell from C#
C#
9
star
26

Information

A module for crazy useful information logs
PowerShell
9
star
27

KeePassProvider

First of several PSProviders for credential managers
8
star
28

DefaultParameter

Functions for setting and saving PowerShell default parameter values
PowerShell
8
star
29

Figlet.ps1

A Figlet module for PowerShell based on auriou/FIGlet
PowerShell
8
star
30

snmp-demo1

An excercise in SNMP data with Splunk
7
star
31

NerdFonts

Chocolatey Windows Install scripts for NerdFonts
Roff
6
star
32

Bing

My PowerShell Bing modules for searching, translating and ... Bing wallpapers.
PowerShell
6
star
33

DevOps2023-Practices

Patterns and Practices for Sharable Scripts and Functions
PowerShell
6
star
34

PowerBot

An IRC bot in PowerShell (using SmartIrc4net)
PowerShell
6
star
35

dotfiles

Using chezmoi to manage dotfiles (including my PowerShell profile)
PowerShell
6
star
36

docker-containers

My small collection of Dockerfiles
Dockerfile
5
star
37

PSAudio

A Tiny PowerShell Module based on NAudio
PowerShell
5
star
38

Autoload

Autoload function like the Korn shell, and can inject functions into Modules
PowerShell
5
star
39

PowerBotMQ

A multi-protocol bridging chat bot based on ZeroMQ pub-sub
PowerShell
4
star
40

ConnectorCards

A module to send connector card messages to the Office 365 API (because I can't find this command built-in).
PowerShell
4
star
41

NetCoreModuleProof

A simple cross-platform .NETStandard PowerShell module
C#
4
star
42

SublimeConEmu

Add some helper commands for using Sublime with ConEmu (and PowerShell).
Python
3
star
43

BFPowerBot

BotFramework PowerBot Exploration
C#
3
star
44

DevOps2023-Building

Invoke-Build - PowerShell in CI/CD
C#
3
star
45

xColors

A PowerShell module for loading xColors themes. Because I was tired.
PowerShell
3
star
46

PortableNativeBinariesTest

Trying Microsoft's prescription for portable libraries
C#
2
star
47

SxSTest

An example of side-by-side PowerShell modules, for test purposes
PowerShell
2
star
48

PSAINT

PowerShell Arrange-Act-Assert in Test
PowerShell
2
star
49

Extensibility

A presentation I gave on writing extensible modules
1
star
50

KernelFun

C#
1
star
51

Kluster

Yet another way to set up Azure Kubernetes Service
PowerShell
1
star
52

dynamic-powershell-example

Shows how to use ClrPlus's Dynamic Powershell classes
C#
1
star
53

SimpleVmProvisioning

Provisioning a secure VM or two...
PowerShell
1
star
54

DSC

PowerShell
1
star
55

Stella

Hosting Kestrel in PowerShell
PowerShell
1
star
56

ChoVersion

A module for switching between multiple versions of command-line tools
PowerShell
1
star
57

jaykul.github.io

My personal blog site via jekyll
HTML
1
star