ionos-cloud/ionosctl

Can not start server with PowerShell and ionosctl server start command

Closed this issue · 6 comments

Description

If i want to start a server with the commands

ionosctl login --user "USER" --password "PASSWORT" --force

ionosctl server start --datacenter-id "DATACENTER-ID" --server-id "SERVER-ID" --wait-for-request --force

in PowerShell, the single lines worked and start the server. If i create a PowerShell script with the two lines and start the file with the Task Scheduler in Windows Server, the server did not start.

If i create a PowerShell script with the ionosctl server stop command and start it with the Windows Task Scheduler, it worked and the server stopped.

Expected behavior

Why did a PowerShell script executed in Windows Task-Scheduler with the stop-command worked and with the start-command not?

Environment

IONOS Enterprise Cloud

Ionosctl version:
Latest, just installed.

OS:
Windows Server 2019

Hi! Please provide the following so that we have a bit more information on the issue:

  • the specs of the server you're trying to start
  • the location in which the server is provisioned
  • the OS of the server
  • the output of the start script when run with IONOS_LOG_LEVEL=trace

Hi,
here are the specifications:

  • the specs of the server you're trying to start
    Virtual Maschine in IONOS DCD
    CPU Intel Xeon
    Cores 2
    RAM 16 GB
    HDD 100 GB

  • the location in which the server is provisioned
    Data Center: Germany/Berlin

  • the OS of the server
    Window Server 2019/2022

  • the output of the start script when run with IONOS_LOG_LEVEL=trace
    Can not execute IONOS_LOG_LEVEL=trace in PowerShell

  • Can not execute IONOS_LOG_LEVEL=trace in PowerShell

IONOS_LOG_LEVEL needs to be set as an environment variable. Also, the host server might require a restart in order to actually recognize that the variable has been set.

Can you describe how to create an environment variable in IONOS Data Center Designer?

Hello, sorry for the slow reply! The environment variable should be set within Windows, on the machine that is supposed to be running the script with Task Scheduler.

I, however, have not been able to reproduce the issue. The Powershell script runs without issue both with the start and with the stop command. I believe this might be a scheduling issue with the Task Scheduler. I would recommend contacting customer support for further assistance. Their email is support@cloud.ionos.com.

I suggest providing them the logs from the script after you set the environment variable.

Hi, I also couldn't reproduce this. I would remove the login command from the job since it generates a new token for every login. You only need one successful login in this case, which you can run manually separately from the job.

Also the job might hang if you have some bad credentials. I suggest piping the output to a log file using powershell. Here's an example of how to capture output using powershell by just using your job's args :

Program / Script: powershell.exe
Add Arguments (optional): -Command "& 'script-path-here.ps1' *> 'log-file-here.txt'"

Regarding the environment variable, it's meant to be set on your local machine (or on the machine running the script) and can be done via powershell: $env:MY_VARIABLE = "MyValue" i.e. $env:IONOS_LOG_LEVEL = "trace"

I'll close this issue, but feel free to comment if you still encounter something unexpected