pspete / psPAS

PowerShell module for CyberArk Privileged Access Security REST API
https://pspas.pspete.dev
MIT License
295 stars 92 forks source link

Help on the using New-PASUser for creating Multiple Vault Users. #268

Closed Ksurabhi08 closed 4 years ago

Ksurabhi08 commented 4 years ago

Expected Behaviour

I'm looking for an help on an example , if you an example on how to request for creating more than one Vault user. So , I can input txt file with vault users name and users are created in using New-PASUser function.

Current Behaviour

I'm using New-PASUser to create users in the vault , it works good when I create one User in the vault.I see an issue with creating account , when I use txt or csv file and foreach with the New-PASUser1

Steps to Reproduce (for bug reports)

$LogonCredential = Get-Credential

New-PASSession -Credential $LogonCredential -BaseURI https://pvwa.domain.com

$Accounts = Import-Csv -Path C:\Safes.txt

foreach($Account in $Accounts){

New-PASUser -UserName $Accounts -InitialPassword (ConvertTo-SecureString Cyberark1 –asplaintext –force) -userType AppProvider -ChangePassOnNextLogon $false -passwordNeverExpires $True

}

Close-PASSession

Txt File contains: API_TEST3 API_TEST4

Sample Output

ID UserName Source UserType Suspended enableUser ExpiryDate Location


211 @{API_TEST3=API_TEST4} CyberArk AppProvider False True \

Context

Trying to create multiple Vault Users using New-PASUser and foreach with taking input from txt file

pspete commented 4 years ago
New-PASUser -UserName $Accounts

You are sending the entire contents of your input file as the username.

There are examples for similar operations here: https://pspas.pspete.dev/docs/bulk-operations/

Ksurabhi08 commented 4 years ago

Thank you pete for the quick response. Yup , you are right. Thank you for pointing out to the right direction.

Ksurabhi08 commented 4 years ago

Error

Hi Pete , I see the error while trying to use the Invoke-PASCPMOperation for reconcile.

pspete commented 4 years ago

@Ksurabhi08 - this is completely unrelated to the original (resolved) issue you raised. Please create a new issue, providing the required details. FWIW, almost every psPAS function calls on Get-PASParameter at some point; the issue likely exists on your system and not in the module code.