From 8219d4e475e1055a373be77f02eb9f29c05cd70f Mon Sep 17 00:00:00 2001 From: OCram85 Date: Wed, 21 Mar 2018 13:56:17 +0100 Subject: [PATCH] Set Credential Parameter pipeable --- src/Item/New-CredentialStoreItem.ps1 | 4 ++-- src/Item/Set-CredentialStoreItem.ps1 | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Item/New-CredentialStoreItem.ps1 b/src/Item/New-CredentialStoreItem.ps1 index e431c01..9b57f41 100644 --- a/src/Item/New-CredentialStoreItem.ps1 +++ b/src/Item/New-CredentialStoreItem.ps1 @@ -55,9 +55,9 @@ function New-CredentialStoreItem { [ValidateNotNullOrEmpty()] [string]$Identifier, - [Parameter(Mandatory = $false)] + [Parameter(Mandatory = $false, ValueFromPipeline = $true)] [ValidateNotNullOrEmpty()] - [pscredential]$Credential, + [PSCredential]$Credential, [Parameter(Mandatory = $false, ParameterSetName = "Shared")] [switch]$Shared diff --git a/src/Item/Set-CredentialStoreItem.ps1 b/src/Item/Set-CredentialStoreItem.ps1 index 7cbcb28..df154fa 100644 --- a/src/Item/Set-CredentialStoreItem.ps1 +++ b/src/Item/Set-CredentialStoreItem.ps1 @@ -53,6 +53,10 @@ function Set-CredentialStoreItem { [Parameter(Mandatory = $false, ParameterSetName = "Shared")] [string]$Identifier, + [Parameter(Mandatory = $false, ValueFromPipeline = $true)] + [ValidateNotNullOrEmpty()] + [PSCredential]$Credential, + [Parameter(Mandatory = $false, ParameterSetName = "Shared")] [switch]$Shared ) @@ -83,7 +87,9 @@ function Set-CredentialStoreItem { $CredentialName = $RemoteHost } - $Creds = Get-Credential -Message $CredentialName + if (-not($Credential)) { + $Creds = Get-Credential -Message $CredentialName + } if ($Creds.UserName) { if ($CSContent.Type -eq "Shared") {