PowerShell Credentials

Modified on Tue, 19 Dec 2023 at 05:43 AM

Here, you can find detailed information on using our "ready to au2mate"  PowerShell Scripts.



TABLE OF CONTENTS



Credentials


We use stored "Credentials" in our PowerShell Scripts to make it easier for you to deploy.


The following list should help you see the "Credentials" we are using.


 NameVariable for CredVariable for FileFilename
SMTP Credentials$SMTPcredential$SMTPcredential_FileSMTPCreds.xml
Teams Graph API$TeamsCred$TeamsCred_FileTeamsCreds.xml
Azure REST API$AzureRestAPICred$AzureRestAPICred_FileAzureRestCreds.xml
Azure Graph API$AzureADGraphAPICred$AzureADGraphAPICred_FileAzureADCreds.xml
Mail Graph API$AzureGraphMailCred$AzureGraphMailCred_FileAzureGraphMailCreds.xml
MS Graph API$MSGraphAPICredMSGraphAPICred_FileMSGraphAPICred.xml





SMTP Credentials

These Credentials are used to send Emails via SMTP.


$credential = Get-Credential $credential | Export-CliXml -Path 'C:\TFS\PS-Services\CredentialStore\SMTPCreds.xml'




Teams Graph API

It is used to send Teams Adaptive Cards via Graph API


Create an Azure App Registration with the following “Delegated MS GRAPH API” Permissions

  • User.Read
  • User.ReadWrite
  • User.ReadBasic.All
  • User.Read.All
  • User.ReadWrite.All
  • GroupMember.Read.All
  • Directory.AccessAsUser.All
  • Channel.ReadBasic.All
  • ChannelSettings.Read.All
  • ChannelSettings.ReadWrite.All
  • Group.Read.All
  • Group.ReadWrite.All
  • Directory.Read.All
  • Directory.ReadWrite.All
  • ChannelMessage.Send
  • Chat.Create
  • Chat.ReadWrite
  • ChatMessage.Send
  • Chat.ReadWrite


You need to create an Azure App Registration with appropriate Rights. 

See MS Documentations for Details

Graph API Documentation: Use the Microsoft Graph API to work with Microsoft Teams - Microsoft Graph v1.0 | Microsoft Docs 

Azure App: Register your app with the Azure AD v2.0 endpoint - Microsoft Graph | Microsoft Docs

 

[hashtable]$values = @{ }
$values.clientId = "a0000a00-0e0d-000e-aaaf-ed000b00df00"
$values.clientSecret = "~V00gCE~aAUW-0oRd~I0LQYAof00r-r0z0"
$values.tenantName = "tenant.onmicrosoft.com"
$values.User= "usernam@domain.com"
$values.PW = "yoursupperpassword"
$values| Export-CliXml -Path 'C:\TFS\PS-Services\CredentialStore\TeamsCreds.xml'



Azure Rest API

These credentials are used to make MS GRAPH API Rest Calls and execute the Actions needed in our Scripts.

Create an Azure App Registration with the following “Application MS GRAPH API” Permissions


  • Application.ReadWrite.All
  • Application.ReadWrite.OwnedBy
  • User.Read
[hashtable]$values = @{ }
$values.clientId = "a0000a00-0e0d-000e-aaaf-ed000b00df00"
$values.clientSecret = "V00gCE~aAUW-0oRd~I0LQYPJ4-vxg-2x3"
$values.tenantID = "a0ba3ab6-fde5-0000-000d-e000c00dc000"
$values| Export-CliXml -Path 'C:\_SCOworkingDir\TFS\PS-Services\CredentialStore\MSGraphAPICred.xml.xml'



Azure Graph API

These credentials are used to make REST API Calls and execute the Actions needed in our Scripts.


  • Create an Azure App Reg
  • Add Azure App Reg the Contributor Role in your Subscription
  • List, Start, and Stop VM (Details: https://www.techguy.at/control-azure-vm-with-powershell-and-azure-rest-api)



[hashtable]$values = @{ }
$values.clientId = "a0000a00-0e0d-000e-aaaf-ed000b00df00"
$values.clientSecret = "V00gCE~aAUW-0oRd~I0LQYPJ4-vxg-2x3"
$values.tenantID = "a0ba3ab6-fde5-0000-000d-e000c00dc000"
$values| Export-CliXml -Path 'C:\_SCOworkingDir\TFS\PS-Services\CredentialStore\AzureRestCreds.xml'



Mail Graph API




MS Graph API


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article