Private/Invoke-DTXAPI.ps1
Function Invoke-DTXAPI{ param ( # Parameter help description [Parameter()] [String] $DTXUsername = $script:DTXUsername, # Parameter help description [Parameter()] [String] $DTXPassword = $script:DTXPassword, # Parameter help description [Parameter()] [String] $RootURI = "https://dtx-capgemini.rhysevans.co.uk", # Parameter help description [Parameter()] [String] $URI = "/project", # Parameter help description [Parameter()] [String] $Payload, # Parameter help description [Parameter()] [String] $Method = "Get", # Parameter help description [Parameter()] [String] $ContentType = "application/json" ) if($URI[0] -ne "/"){ $URI = "/" + $URI } $Splat = @{ Credential = (New-Object System.Management.Automation.PSCredential ($DTXUsername, (ConvertTo-SecureString $DTXPassword -AsPlainText -Force))) Authentication = "Basic" Uri = ($RootURI + $URI) ContentType = $ContentType Method = $Method SslProtocol = "Tls12" } if($Payload){ $Splat.Body = $Payload } Invoke-RestMethod @Splat } |