How to Build Windows Machine with PiKVM

This documentation is generated by Attune

Automate This

Use the Attune GUI for your Scripts

    1 Download Attune
    2 Copy the Attune Project URL
    3 Clone the Project in Attune
    4 Plan your Job(s)
    5 Run your Job(s)

You've automated: Build Windows Machine with PiKVM


Get the most out of automation with our get started videos, product demonstrations, and more.

Learn Attune Automation

The following steps will guide you through the manual process.

Connect via ssh:

ssh {automationworkerlinuxuser}@{automationworkerlinuxnode}

Execute the following script:

                
CURL_OUTPUT=$(curl --insecure \
    --header X-KVMD-User:{pikvmUserAdmin.user} \
    --header X-KVMD-Passwd:{pikvmUserAdmin.password} \
    https://{pikvmIpAddress}/api/auth/check)

echo "${CURL_OUTPUT}" | jq '.'

OK=$(echo "${CURL_OUTPUT}" | jq '.ok')

if [ "${OK}" != "true" ]
then
    echo "Error"
    exit 1
fi
                
            

Execute the following script:

                
CURL_OUTPUT=$(curl --insecure \
    --header X-KVMD-User:{pikvmUserAdmin.user} \
    --header X-KVMD-Passwd:{pikvmUserAdmin.password} \
    https://{pikvmIpAddress}/api/info)
    
echo "${CURL_OUTPUT}" | jq '.'

OK=$(echo "${CURL_OUTPUT}" | jq '.ok')

if [ "${OK}" != "true" ]
then
    echo "Error"
    exit 1
fi
                
            

Execute the following script:

                
curl --insecure \
    --header X-KVMD-User:{pikvmUserAdmin.user} \
    --header X-KVMD-Passwd:{pikvmUserAdmin.password} \
    https://{pikvmIpAddress}/api/atx
                
            

Execute the following script:

                
curl --insecure \
    --request POST \
    --header X-KVMD-User:{pikvmUserAdmin.user} \
    --header X-KVMD-Passwd:{pikvmUserAdmin.password} \
    "https://{pikvmIpAddress}/api/atx/click?button=power_long" \
    | jq '.'
                
            

Execute the following script:

                
CURL_OUTPUT=$(curl --insecure \
    --header X-KVMD-User:{pikvmUserAdmin.user} \
    --header X-KVMD-Passwd:{pikvmUserAdmin.password} \
    https://{pikvmIpAddress}/api/msd)
    
echo "${CURL_OUTPUT}" | jq '.'
                
            

Execute the following script:

                
curl --insecure --verbose \
    --request POST \
    --header X-KVMD-User:{pikvmUserAdmin.user} \
    --header X-KVMD-Passwd:{pikvmUserAdmin.password} \
    https://{pikvmIpAddress}/api/msd/set_connected?connected=0 \
    | jq '.'
                
            

Execute the following script:

                
curl --insecure \
    --request POST \
    --header X-KVMD-User:{pikvmUserAdmin.user} \
    --header X-KVMD-Passwd:{pikvmUserAdmin.password} \
    https://{pikvmIpAddress}/api/msd/reset | jq '.'
                
            

Execute the following script:

                
curl --insecure --verbose \
    --request POST \
    --header X-KVMD-User:{pikvmUserAdmin.user} \
    --header X-KVMD-Passwd:{pikvmUserAdmin.password} \
    https://{pikvmIpAddress}/api/msd/remove?image=kickstart_{newNode.fqn}.iso
                
            

Execute the following script:

                
cd {automationWorkerBaseDirectory}

curl --insecure \
    -T "kickstart_{newNode.fqn}.iso" \
    -X POST \
    --header X-KVMD-User:{pikvmUserAdmin.user} \
    --header X-KVMD-Passwd:{pikvmUserAdmin.password} \
    https://{pikvmIpAddress}/api/msd/write?image=kickstart_{newNode.fqn}.iso
                
            

Execute the following script:

                
curl --insecure \
    --request POST \
    --header X-KVMD-User:{pikvmUserAdmin.user} \
    --header X-KVMD-Passwd:{pikvmUserAdmin.password} \
    "https://{pikvmIpAddress}/api/msd/set_params?image=kickstart_{newNode.fqn}.iso&cdrom=1" \
    | jq '.'
                
            

Execute the following script:

                
curl --insecure --verbose \
    --request POST \
    --header X-KVMD-User:{pikvmUserAdmin.user} \
    --header X-KVMD-Passwd:{pikvmUserAdmin.password} \
    https://{pikvmIpAddress}/api/msd/set_connected?connected=1 \
    | jq '.'
                
            

Execute the following script:

                
curl --insecure --verbose \
    --request POST \
    --header X-KVMD-User:{pikvmUserAdmin.user} \
    --header X-KVMD-Passwd:{pikvmUserAdmin.password} \
    https://{pikvmIpAddress}/api/atx/power?action=on \
    | jq '.'
                
            

Execute the following script:

                
function numLock() {
    curl --insecure  \
        --request GET \
        --header X-KVMD-User:{pikvmUserAdmin.user} \
        --header X-KVMD-Passwd:{pikvmUserAdmin.password} \
        "https://{pikvmIpAddress}/api/hid" 2> /dev/null \
        | jq '.result.keyboard.leds.num'

}

echo "Numlock is $(numLock)"

while [ "$(numLock)" = 'false' ]
do
    echo "Waiting for PowerOn"
    sleep 1
done

echo "Numlock is $(numLock)"

while [ "$(numLock)" = 'true' ]
do
    echo "Waiting for WinPE to turn off numlock"
    sleep 5
done

echo "Numlock is $(numLock)"

while [ "$(numLock)" = 'false' ]
do
    echo "Waiting reboot to turn numlock back on again"
    sleep 2
done

echo "Numlock is $(numLock)"
                
            

Execute the following script:

                
curl --insecure --verbose \
    --request POST \
    --header X-KVMD-User:{pikvmUserAdmin.user} \
    --header X-KVMD-Passwd:{pikvmUserAdmin.password} \
    https://{pikvmIpAddress}/api/msd/set_connected?connected=0 \
    | jq '.'
                
            

Execute the following script:

                
curl --insecure --verbose \
    --request POST \
    --header X-KVMD-User:{pikvmUserAdmin.user} \
    --header X-KVMD-Passwd:{pikvmUserAdmin.password} \
    https://{pikvmIpAddress}/api/msd/remove?image=kickstart_{newNode.fqn}.iso
                
            

Check if TCP Port 0 is listening.

Use Telnet to check if the TCP Service is accepting connections.

Check if TCP Port 0 is listening. Make sure the TCP Port goes down for 1 seconds. When the TCP Port is up, wait 5 seconds.

Use Telnet to check if the TCP Service is accepting connections.

Wait until the load average is less than 15, or 2 minutes have passed.

This is a quicker aproach than the "wait 2 minutes" ping step.

Connect via RDP:

mstsc /admin /v:{newwindowsnode}

Login as user {newnodewindowsuser} and open a command prompt.

Execute the following script:

                
$Start = Get-Date
$count=0

do {
    $pct=$(Get-WmiObject win32_processor | select LoadPercentage).LoadPercentage;
    Write-Host "LoadPercentage: $pct, Count: $count";
    if ($pct -lt 15) {
        $count += 1;
    } else {
        $count=0
    }
    
    if ( $count -ge 10 ) {
        Write-Host "Wait completed, we were idle for 10 seconds";
        break;
    }
    
    if ( ( Get-Date ) -gt $Start.AddMinutes(2) ) {
        Write-Host "Wait timed out, we waited two minutes";
        break;
    }
    
} until ($false);
                
            

Completed

You have completed this instruction.

Attune - Powered by ServerTribe

Automate with Attune

Download the Attune Community Edition.

DOWNLOAD!!!

Discuss this Project in Discord

Join our Discord channel and connect with like-minded individuals who share your passion. Engage in lively discussions, gain valuable insights, and stay updated on the latest trends in our industry. Don't miss out on this opportunity to network, learn, and grow together.


Click the link below and become a part of our vibrant community on Discord today!

Join NOW!!!