$UserName = "user"$Password = "password"$API_URL = "https://jenkinsservername"$JobName = "firstjob"$JobToken = "generatedtoken"$header = @{}$header.Add('Authorization', 'Basic '+ [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$(${UserName}):$(${Password})")))$Params = @{uri = "https://${API_URL}/crumbIssuer/api/json"; Method = 'Get'; Headers = $header;}$API_Crumb = Invoke-RestMethod @Paramswrite-host $API_Crumb$h.Add('Jenkins-Crumb', $API_Crumb.crumb)$Params['uri'] = "https://jenkinsservername/$JobName/build?token=$JobToken"$Params['Method'] = 'Post'$Params['Headers'] = $headerInvoke-RestMethod @Params
Invoke-RestMethod : The remote name could not be resolved: 'https'At C:\path\to\script.ps1:12 char:14
$API_Crumb = Invoke-RestMethod @Params1
~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
- FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Invoke-RestMethod : Object reference not set to an instance of an object.At C:\path\to\script.ps1:19 char:1
- Invoke-RestMethod @Params2 -WebSession $Session
+ CategoryInfo : NotSpecified: (:) [Invoke-RestMethod], NullReferenceException+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
You contributions will be appreciated