Print-HelloWorld2.psm1
function Write-HelloWorld { <# .SYNOPSIS Configures Twilio API credentials (Account SID and Auth Token) and set thes API URI with the Account SID. .DESCRIPTION Configures Twilio API credentials (Account SID and Auth Token) and set thes API URI with the Account SID. This requires a Twilio account with a configured Account SID and Auth Token. Can also optionally set the Twilio account phone number for sending SMS messages. .PARAMETER PhoneNumber Allows option to set the Twilio account phone number for sending SMS messages. Must be in E.164 format and a valid telephone number. This parameter is optional; however, if omitted, requires running Set-TwilioAccountPhoneNumber. .PARAMETER Credential Takes a PSCredential object saved in a PowerShell variable. This is the Account SID and Auth Token for your Twilio account. .EXAMPLE PS C:\> Connect-TwilioService This example will prompt for the Account SID and Auth Token to configure the API connection. .EXAMPLE $creds = Get-Credential PS C:\> Connect-TwilioService -Credential $creds This example saves the Account SID and Auth Token to a PowerShell variable and then configures the API connection. .EXAMPLE PS C:\> Connect-TwilioService -PhoneNumber +15551234567 This example will set the from phone number to +15551234567 and prompt for the Account SID and Auth Token to configure the API connection. .LINK https://www.twilio.com/docs/iam/credentials/api#authentication #> [CmdletBinding()] param( [Parameter()] [ValidatePattern("^\+[1-9]\d{1,14}$")] # Regex taken from: https://www.twilio.com/docs/glossary/what-e164 [string] $PhoneNumber, [Parameter()] [PSCredential] $Credential ) if ($PSBoundParameters.ContainsKey('Credential')) { $Script:TWILIO_CREDS = $Credential } else { $Script:TWILIO_CREDS = Get-Credential -Message "User name = Account SID, Password = Auth Token" } Set-TwilioApiUri -SID $Script:TWILIO_CREDS.UserName if ((Test-TwilioCredentials -Credential $Script:TWILIO_CREDS) -eq $true) { if ($PSBoundParameters.ContainsKey('PhoneNumber')) { Set-TwilioAccountPhoneNumber -PhoneNumber $PhoneNumber } } } # End of Connect-TwilioService |