Hi Tom,
thanks for the answer, this works fine during the host creation.
I’ve tryed to activate the modules after the host creation by creating a moduleassociation for the newly created host object.
For example:
#Hostname Changer
$TaskdataSet = @{
"hostID" = $HostID
"moduleID" = "9"
"state" = "1"
}
Try{
$taskdataToSend = ConvertTo-JSON($TaskdataSet)
New-FogObject -type object -coreObject moduleassociation -jsonData $TaskdataSet
}Catch{Write-Host "Failed to create Module association for Module 4 in Fog" -ForegroundColor Red
$error[0] | Format-List -Force
Exit 1
}
But i think this was the wrong way. Could you tell me the right way to activate the modules after the host creation step?
And one further question:
If i try to define a ‘AllSnapin task’ for the new created host it doesn’t work.
So my last step should be the deployment of the already, successfully assigned snapins after the hostname was
changed (which is now working if i activate the hostchanger module during the host creation step). That’s why i try to create a “AllSnapin” task for
the newly created host object like this:
#Create Snapin Tasks for new Host
$HostID = $createHostResult.id
$TaskURL = $baseUri + "/host/" + $HostID + "/task"
$TaskdataSet = @{
"hostname" = $createHostResult.name
"taskTypeID" = $AllSnapinID
}
Try{
$taskdataToSend = ConvertTo-JSON($TaskdataSet)
$TaskResult = Invoke-RestMethod -Method Post -Uri $TaskURL -Headers $headers -Body $taskdataToSend -ContentType "application/json"
}Catch{Write-Host "Failed to create All Snapin Task in Fog" -ForegroundColor Red
$error[0] | Format-List -Force
Exit 1
}
But this dosen’t work, i guess because the deployment task is in the queue for the new host? Would it be the right way to create the “AllSnapin Task”
after the deployment task has finished? Is that the clue?
Thank you for your support!