pspete / PoShPACLI

Powershell Module for CyberArk PACLI
MIT License
72 stars 20 forks source link

Pipeline #42

Closed juler69 closed 7 years ago

juler69 commented 7 years ago

Hi Pete,

I am attempting to use the pipeline method you outline in your readme file and connecting to a vault using a logon file thus and have tried various combinations of parameters and can't seem to get it to work.

$token = Start-PVPACLI | Import-PVVaultDefinition -vault $vault -parmFile $parmfile | Connect-PVVault -vault $vault -user $user -logonFile $logonFile

Are you able to successfully connect to a vault using the pipeline with the above combo of functions?

Blessings, Jonathan

pspete commented 7 years ago

Hi Jonathan,

I do not usually use the parmFile nor logonFile for the logon process - but have run a test using your command as per the below:

PS D:\> Initialize-PoShPACLI "D:\PACLI\"
$vault = "Demo Vault"
$parmfile = "D:\PACLI\Vault.ini"
$user = "administrator"
$logonfile = "D:\PACLI\pacli.cred"
$VerbosePreference = "Continue"
$DebugPreference = "Continue"
$token = Start-PVPACLI |
Import-PVVaultDefinition -vault $vault -parmFile $parmfile |
Connect-PVVault -vault $vault -user $user -logonFile $logonFile
VERBOSE: Starting Pacli
DEBUG: Processing Bound Parameters
DEBUG: PACLI Command: INIT
DEBUG: Exit Code: 0
VERBOSE: Pacli Started
VERBOSE: Defining Vault
DEBUG: Processing Bound Parameters
DEBUG: vault="Demo Vault" parmFile="D:\PACLI\Vault.ini" sessionID=0
DEBUG: PACLI Command: DEFINEFROMFILE vault="Demo Vault" parmFile="D:\PACLI\Vault.ini" sessionID=0
DEBUG: Exit Code: 0
VERBOSE: Vault Config Read
VERBOSE: Logging onto Vault
DEBUG: Processing Bound Parameters
DEBUG: vault="Demo Vault" user="administrator" logonFile="D:\PACLI\pacli.cred" sessionID=0
DEBUG: PACLI Command: LOGON vault="Demo Vault" user="administrator" logonFile="D:\PACLI\pacli.cred" sessionID=0
DEBUG: Exit Code: 0
VERBOSE: Successfully Logged on

I did not encounter any issues.

Do you receive any errors or see the expected commands output in the debug stream?

Edit: included the mandatory step of Initialize-PoShPACLI "D:\PACLI\"

pspete commented 7 years ago

Hey @juler69 - did you manage to progress?

juler69 commented 7 years ago

Sorry - I've had a few days off sick. I copied your example above and substituted my settings and it doesn't work. I am wondering though if it is because I only have Powershell 2.0 on my laptop not 3.0?

My script only completes the Start-PVPACLI and then exits, even though I am piping to the Import, etc...

juler69 commented 7 years ago

I have proceeded without using the token feature so I can progress my testing however now I get other binding errors, for example...

DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args [New-PVSafe]
DEBUG: ParameterBinding Information: 0 :     BIND arg [Test-V7] to parameter [vault]
DEBUG: ParameterBinding Information: 0 :         Executing DATA GENERATION metadata: [System.Management.Automation.ArgumentTypeConverterAttribute]
DEBUG: ParameterBinding Information: 0 :             result returned from DATA GENERATION: Test-V7
DEBUG: ParameterBinding Information: 0 :         COERCE arg to [System.String]
DEBUG: ParameterBinding Information: 0 :             Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 :         BIND arg [Test-V7] to param [vault] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 :     BIND arg [Onboarding-Test-V7] to parameter [user]
DEBUG: ParameterBinding Information: 0 :         Executing DATA GENERATION metadata: [System.Management.Automation.ArgumentTypeConverterAttribute]
DEBUG: ParameterBinding Information: 0 :             result returned from DATA GENERATION: Onboarding-Test-V7
DEBUG: ParameterBinding Information: 0 :         COERCE arg to [System.String]
DEBUG: ParameterBinding Information: 0 :             Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 :         BIND arg [Onboarding-Test-V7] to param [user] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 :     BIND arg [JJ001_STA_01] to parameter [safe]
DEBUG: ParameterBinding Information: 0 :         Executing DATA GENERATION metadata: [System.Management.Automation.ArgumentTypeConverterAttribute]
DEBUG: ParameterBinding Information: 0 :             result returned from DATA GENERATION: JJ001_STA_01
DEBUG: ParameterBinding Information: 0 :         COERCE arg to [System.String]
DEBUG: ParameterBinding Information: 0 :             Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 :         BIND arg [JJ001_STA_01] to param [safe] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 :     BIND arg ["Jonathan's Static Safe #1"] to parameter [description]
DEBUG: ParameterBinding Information: 0 :         Executing DATA GENERATION metadata: [System.Management.Automation.ArgumentTypeConverterAttribute]
DEBUG: ParameterBinding Information: 0 :             result returned from DATA GENERATION: "Jonathan's Static Safe #1"
DEBUG: ParameterBinding Information: 0 :         COERCE arg to [System.String]
DEBUG: ParameterBinding Information: 0 :             Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 :         BIND arg ["Jonathan's Static Safe #1"] to param [description] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 :     BIND arg [365] to parameter [logRetention]
DEBUG: ParameterBinding Information: 0 :         Executing DATA GENERATION metadata: [System.Management.Automation.ArgumentTypeConverterAttribute]
DEBUG: ParameterBinding Information: 0 :             result returned from DATA GENERATION: 365
DEBUG: ParameterBinding Information: 0 :         COERCE arg to [System.Int32]
DEBUG: ParameterBinding Information: 0 :             Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 :         BIND arg [365] to param [logRetention] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 :     BIND arg [30] to parameter [fileRetention]
DEBUG: ParameterBinding Information: 0 :         Executing DATA GENERATION metadata: [System.Management.Automation.ArgumentTypeConverterAttribute]
DEBUG: ParameterBinding Information: 0 :             result returned from DATA GENERATION: 30
DEBUG: ParameterBinding Information: 0 :         COERCE arg to [System.Int32]
DEBUG: ParameterBinding Information: 0 :             Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 :         BIND arg [30] to param [fileRetention] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 :     BIND arg [30] to parameter [requestsRetention]
DEBUG: ParameterBinding Information: 0 :         Executing DATA GENERATION metadata: [System.Management.Automation.ArgumentTypeConverterAttribute]
DEBUG: ParameterBinding Information: 0 :             result returned from DATA GENERATION: 30
DEBUG: ParameterBinding Information: 0 :         COERCE arg to [System.Int32]
DEBUG: ParameterBinding Information: 0 :             Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 :         BIND arg [30] to param [requestsRetention] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [New-PVSafe]
DEBUG: ParameterBinding Information: 0 : BIND PIPELINE object to parameters: [Out-Default]
DEBUG: ParameterBinding Information: 0 :     PIPELINE object TYPE = [System.Management.Automation.ErrorRecord]
DEBUG: ParameterBinding Information: 0 :     RESTORING pipeline parameter's original values
DEBUG: ParameterBinding Information: 0 :     Parameter [InputObject] PIPELINE INPUT ValueFromPipeline NO COERCION
DEBUG: ParameterBinding Information: 0 :     BIND arg [A parameter cannot be found that matches parameter name 'safeOptions'.] to parameter [InputObject]
DEBUG: ParameterBinding Information: 0 :         BIND arg [A parameter cannot be found that matches parameter name 'safeOptions'.] to param [InputObject] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [Out-Default]
DEBUG: ParameterBinding Information: 0 : BIND PIPELINE object to parameters: [Out-LineOutput]
DEBUG: ParameterBinding Information: 0 :     PIPELINE object TYPE = [System.Management.Automation.ErrorRecord]
DEBUG: ParameterBinding Information: 0 :     RESTORING pipeline parameter's original values
DEBUG: ParameterBinding Information: 0 :     Parameter [InputObject] PIPELINE INPUT ValueFromPipeline NO COERCION
DEBUG: ParameterBinding Information: 0 :     BIND arg [A parameter cannot be found that matches parameter name 'safeOptions'.] to parameter [InputObject]
DEBUG: ParameterBinding Information: 0 :         BIND arg [A parameter cannot be found that matches parameter name 'safeOptions'.] to param [InputObject] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [out-lineoutput]
DEBUG: ParameterBinding Information: 0 : BIND PIPELINE object to parameters: [Format-Default]
DEBUG: ParameterBinding Information: 0 :     PIPELINE object TYPE = [System.Management.Automation.ErrorRecord]
DEBUG: ParameterBinding Information: 0 :     RESTORING pipeline parameter's original values
DEBUG: ParameterBinding Information: 0 :     Parameter [InputObject] PIPELINE INPUT ValueFromPipeline NO COERCION
DEBUG: ParameterBinding Information: 0 :     BIND arg [A parameter cannot be found that matches parameter name 'safeOptions'.] to parameter [InputObject]
DEBUG: ParameterBinding Information: 0 :         BIND arg [A parameter cannot be found that matches parameter name 'safeOptions'.] to param [InputObject] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [format-default]
DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 :     BIND arg [1] to parameter [Version]
DEBUG: ParameterBinding Information: 0 :         Executing DATA GENERATION metadata: [Microsoft.PowerShell.Commands.SetStrictModeCommand+ArgumentToVersionTransformationAttribute]
DEBUG: ParameterBinding Information: 0 :             result returned from DATA GENERATION: 1.0
DEBUG: ParameterBinding Information: 0 :         COERCE arg to [System.Version]
DEBUG: ParameterBinding Information: 0 :             Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 :         Executing VALIDATION metadata: [Microsoft.PowerShell.Commands.SetStrictModeCommand+ValidateVersionAttribute]
DEBUG: ParameterBinding Information: 0 :         BIND arg [1.0] to param [Version] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : CALLING BeginProcessing
DEBUG: ParameterBinding Information: 0 : CALLING EndProcessing
DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 :     BIND arg [1] to parameter [Version]
DEBUG: ParameterBinding Information: 0 :         Executing DATA GENERATION metadata: [Microsoft.PowerShell.Commands.SetStrictModeCommand+ArgumentToVersionTransformationAttribute]
DEBUG: ParameterBinding Information: 0 :             result returned from DATA GENERATION: 1.0
DEBUG: ParameterBinding Information: 0 :         COERCE arg to [System.Version]
DEBUG: ParameterBinding Information: 0 :             Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 :         Executing VALIDATION metadata: [Microsoft.PowerShell.Commands.SetStrictModeCommand+ValidateVersionAttribute]
DEBUG: ParameterBinding Information: 0 :         BIND arg [1.0] to param [Version] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : CALLING BeginProcessing
DEBUG: ParameterBinding Information: 0 : CALLING EndProcessing
DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 :     BIND arg [1] to parameter [Version]
DEBUG: ParameterBinding Information: 0 :         Executing DATA GENERATION metadata: [Microsoft.PowerShell.Commands.SetStrictModeCommand+ArgumentToVersionTransformationAttribute]
DEBUG: ParameterBinding Information: 0 :             result returned from DATA GENERATION: 1.0
DEBUG: ParameterBinding Information: 0 :         COERCE arg to [System.Version]
DEBUG: ParameterBinding Information: 0 :             Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 :         Executing VALIDATION metadata: [Microsoft.PowerShell.Commands.SetStrictModeCommand+ValidateVersionAttribute]
DEBUG: ParameterBinding Information: 0 :         BIND arg [1.0] to param [Version] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : CALLING BeginProcessing
DEBUG: ParameterBinding Information: 0 : CALLING EndProcessing
DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 :     BIND arg [1] to parameter [Version]
DEBUG: ParameterBinding Information: 0 :         Executing DATA GENERATION metadata: [Microsoft.PowerShell.Commands.SetStrictModeCommand+ArgumentToVersionTransformationAttribute]
DEBUG: ParameterBinding Information: 0 :             result returned from DATA GENERATION: 1.0
DEBUG: ParameterBinding Information: 0 :         COERCE arg to [System.Version]
DEBUG: ParameterBinding Information: 0 :             Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 :         Executing VALIDATION metadata: [Microsoft.PowerShell.Commands.SetStrictModeCommand+ValidateVersionAttribute]
DEBUG: ParameterBinding Information: 0 :         BIND arg [1.0] to param [Version] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : CALLING BeginProcessing
DEBUG: ParameterBinding Information: 0 : CALLING EndProcessing
pspete commented 7 years ago

Hi - there is a definite requirement for PowerShell Version 3 at the minimum. (For instance, the [pscustomobject] accelerator is not not supported in v2 for instance, but is widely used in the module's functions.)

The module manifest does detail this - I will update the readme also for clarity.

pspete commented 7 years ago

@juler69 - as PowerShell V2 is being depreciated, there is not much to you can do other than upgrade.