|
Jun24Written by:Martin 24.06.2011 21:47  To connect to the server with SwyxWare’s PowerShell module, use use connect-ippbx. It allows to either use your current Windows account or a SwyxWare username and password. When using the latter variant you typically use get-credential to prompt for user name and password. get-credential is a PowerShell cmdlet using the standard Windows credential dialog. We decided to use a credential object for connect-ippbx, because this prevents having the password as normal string parameter, visible in the shell and as clear text string in Powershell memory. Get-credential uses a .NET SecureString which is much safer. However, if your SwyxWare username contains a comma, get-credential doesn’t work, because Windows does not allow comma in user names. Here’s a workaround: If you’re trying to use the connect-ippbx cmdlet like this: connect-ippbx -ServerName myserver -UseIpPbxLogin -Credential (get-credential) get-credential pops up a standard Windows credential dialog. However, that dialog does not accept comma (,) in the user name. Use the following workaround instead: connect-ippbx -ServerName myserver -UseIpPbxLogin -Credential (new-object System.Management.Automation.PSCredential "lastname, firstname",(read-host -Prompt "Enter password:" -AsSecureString)) The trick is to create a PSCredential object directly and specify username (“Lastname, Firstname” in this example) and password as parameters using read-host to prompt for the password in a secure way. P.S. Unfortunately even if using securestring on this level is a good idea, it does not make that variant much safer, because the ConfigDataStore API needs a normal string anyway. But that’s no excuse to use the secure variant wherever you can  Tags: |
|