How to pass credentials in powershell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 02:29 AM
I am working on a Servicenow Orchestration use case. In this, i have to connect to Teams session using credentials (Connect-MicrosoftTeams -Credential $credentials).
I created a custom PowerShell activity for this use case. Please let me know how to pass the credentials in the PowerShell activity

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 02:38 AM
Hi
PowerShell selects a "Windows" type Credential from your Credential (discovery_credentials) table in ServiceNow (or runs as your MID Servers service account) and passes the credential into the script as the $cred variable. You can use the $cred in your script like this:
Get-WmiObject -Credential $cred -Class "Win32_Service"
refer the following thread it similar to your question it might help you.
If it help mark helpful or correct
Thanks and regards
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 03:01 AM
Hi,
In addition to
https://hi.service-now.com/kb_view.do?sysparm_article=KB0697306
Hope this helps.
Regards,
Hemant