AndrewPla / TOPdeskPS

PowerShell module to interact with the TOPdesk API
MIT License
30 stars 12 forks source link

Password won't store, please enable plain text passwd store. #83

Closed whatthehomepod closed 5 years ago

whatthehomepod commented 5 years ago

Prerequisites

Put an X between the brackets on each line to confirm you have completed them:

Describe the bug Module keeps asking for credentials. Each time when an user account is created the module keeps asking for the password and won't store it.

To Reproduce n/a

Expected behavior Just a way to store the password in plain text. EG: Connect-TdSerivce -url 'http://localhost/' -username USERNAME -password PASSWORD.

Screenshots or Transcripts n/a

System Details

Additional context Add any other context about the problem here. Is there any other information like system configuration or data that might help us understand the problem.

ChrisLGardner commented 5 years ago

I'd be very against storing the password in plain text. Using something like BetterCredentials to store them in the Windows Credential Store would be a better approach or worst case storing them as secure strings in a carefully managed file or registry entry (perhaps using PSFramework settings as currently used for other settings).

whatthehomepod commented 5 years ago

I'd be very against storing the password in plain text. Using something like BetterCredentials to store them in the Windows Credential Store would be a better approach or worst case storing them as secure strings in a carefully managed file or registry entry (perhaps using PSFramework settings as currently used for other settings).

I know it's not a smart choice however, I think you have to give the users the choice. Some users doesn't have that kind of privileges. I tried for almost a year to make the TOPdesk test env approachable for us however our network team was running this change just after a year... Now, the test env finally works I really want to get this script ready, same as the error issue I openend.

AndrewPla commented 5 years ago

Storing creds is something that I wanted to avoid, but I have considered using psframework to store credentials. I won't be allowing plaintext passwords, but let me show you a method for connecting automatically that should fix your problem for the time being.

# Quick and dirty way that you could use with your test environment
$pass = 'plaintextpass' | convertto-securestring -asplaintext -force
$username = 'TDLoginName'
$credential = New-Object System.Management.Automation.PSCredential($username,$pass)
Connect-TdService $Credential

If you want a more reusable solution you can checkout a module that manages/stores credentials for you. @ChrisLGardner suggested BetterCredentials, but I'm only familiar with CredentialManager. https://github.com/davotronic5000/PowerShell_Credential_Manager https://www.powershellgallery.com/packages/CredentialManager/2.0

Here is an example of using a stored credential

# Install the module
Install-Module CredentialManager

# Lets create a persistent credential that we can retrieve later
# Persist enterprise will cause the credential to be stored and retrievable from different sessions. This is only accessible by the account that created the credential.
New-StoredCredential -Target 'topdesk\username' -password 'password' -persist enterprise

# Grab the Cred
$credential = Get-StoredCredential -Target 'topdesk\username'

# Connect to TOPdesk
Connect-TdService -credential $credential

If I end up adding the ability to store credentials I'll let you know.