Hello
We’re having a bit of an issue when trying to run below PS script through octo steps:
This step is supposed to disable the server through KEMP API url
$uri = “https://bal:xxxx@10.252.20.5/access/modrs?vs=10.252.20.12&port=80&prot=tcp&rs=10.252.20.188&rsport=80&enable=n”
$secpasswd = ConvertTo-SecureString “xxxx” -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential (“bal”, $secpasswd)
[System.Net.ServicePointManager]::Expect100Continue = $true
[System.Net.ServicePointManager]::MaxServicePointIdleTime = 10000
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$request = [System.Net.HttpWebRequest]::Create($uri)
$request.Credentials = $mycreds
$response = $request.GetResponse()
When execuded through PS console on the target server it works flawlessly (logged in with octopus service account we are using in tentacle and server services). When run through octo it fails with :
Windows PowerShell transcript end
End time: 20160509104029
Windows PowerShell transcript start
Start time: 20160509121525
Username: WINTECH\sa_OctopusDeploy
RunAs User: WINTECH\sa_OctopusDeploy
Machine: UK-DEPLOY02 (Microsoft Windows NT 6.3.9600.0)
Host Application: C:\Windows\system32\WindowsPowershell\v1.0\PowerShell.exe -NoLogo -ExecutionPolicy Unrestricted -Command . {. ‘C:\Octopus\Work\20160509111522-8\Bootstrap.Script.ps1’; if ((test-path variable:global:lastexitcode)) { exit $LastExitCode }}
Process ID: 6212
Transcript started, output file is c:\kemp\log01.txt
PS>TerminatingError(): “Exception calling “GetResponse” with “0” argument(s): “The remote server returned an error: (401) Unauthorized.””
TerminatingError(): “Exception calling “GetResponse” with “0” argument(s): “The remote server returned an error: (401) Unauthorized.””
TerminatingError(): “Exception calling “GetResponse” with “0” argument(s): “The remote server returned an error: (401) Unauthorized.””
TerminatingError(): “Exception calling “GetResponse” with “0” argument(s): “The remote server returned an error: (401) Unauthorized.””
Exception calling “GetResponse” with “0” argument(s): “The remote server returned an error: (401) Unauthorized.”
Exception calling “GetResponse” with “0” argument(s): “The remote server returned an error: (401) Unauthorized.”
At C:\Octopus\Work\20160509111522-8\Script.ps1:12 char:1
- $response = $request.GetResponse()
-
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : WebException
PS>$global:?
False
Windows PowerShell transcript end
End time: 20160509121525
I’m running out of ideas what could be causing this issue. Any input would be greatly appreciated.
Thanks,
Andrzej