Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
WFA SOAP script - getting windows credentials to avoid hardcoding pwds in the script
2015-01-07
08:45 AM
4,725 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
Does anyone know how to connect to WFA ( via SOAP powershell script ) so the powershell can use the existing windows credentials where the script is being executed ?
This is to avoid having to plaintext or hardcode the password somewhere in the script.
Thanks in advance!
Solved! See The Solution
1 ACCEPTED SOLUTION
trentino123 has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't think we can use the existing windows user credentials for this. If you do not want to hardcode the WFA login password in the script, you can do the following:
1. Prompt the user for Credentials when executing the script. This is open a prompt for the user to enter credentials.
$wfaCreds = Get-Credential
#Now use this credential in your code with
$wfa = New-WebServiceProxy -Uri $uri -Credential $wfaCreds
2. Save the credentials in encrypted form in a password file. Only the windows user who created the file can decrypt it. So its fairly secure and can only be run by 1 user.
"password" | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString |Out-File C:\pass.txt
Now in your Powersell script: Get the contents of this file, convert to secure string and build your credential.
$pass = Get-Content C:\pass.txt
$wfaCreds = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $username,($pass | ConvertTo-SecureString)
sinhaa
If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
4 REPLIES 4
trentino123 has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't think we can use the existing windows user credentials for this. If you do not want to hardcode the WFA login password in the script, you can do the following:
1. Prompt the user for Credentials when executing the script. This is open a prompt for the user to enter credentials.
$wfaCreds = Get-Credential
#Now use this credential in your code with
$wfa = New-WebServiceProxy -Uri $uri -Credential $wfaCreds
2. Save the credentials in encrypted form in a password file. Only the windows user who created the file can decrypt it. So its fairly secure and can only be run by 1 user.
"password" | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString |Out-File C:\pass.txt
Now in your Powersell script: Get the contents of this file, convert to secure string and build your credential.
$pass = Get-Content C:\pass.txt
$wfaCreds = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $username,($pass | ConvertTo-SecureString)
sinhaa
If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Sinhaa! It did the trick.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You can cache your domain credentials in the WFA credential cache and invoke the workflow from a remote host using the REST API. The workflow can then retrieve the domain credentials using the "Get-WFACredential" Command to ensure the workflow you want to invoke is executed within the correct security context. There are some examples of using the REST API here:
/matt
If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Matt,
That works fine , you only need the credentials stored in advance.
Thanks!
