Not sure if this is the correct place for this post but I am using the PowerShell module created by: JJ Fullmer
https://github.com/FOGProject/fog-community-scripts/tree/master/PowershellModules/FogApi
Can someone look over this code for me? Trying to move hosts from one group to another:
Import-Module FogApi
$Groupnames = Get-FogObject -type object -coreObject group
$groupassoc = (Get-FogObject -type object -coreObject groupassociation).groupassociations
$queue = $Groupnames.groups | where {$_.Name -eq "Queued"}
$Hostnames = (Get-FogObject -type object -coreObject host).hosts
$sys_queue = $groupassoc | where {$_.groupID -eq $queue.id}
$free_sys = $groupassoc | where {$_.groupID -eq "0"}
if($free_sys.Count -gt 0){
Write-host I found $free_sys.count hosts to move to Queued.
foreach($freehost in $free_sys){
#command to move $free_sys to queued group.
$HostJson = (@{hosts = $free_sys.ID} | ConvertTo-Json)
write-host Update-FogObject ...
Update-FogObject -type object -coreObject group -jsonData $HostJson -IDofObject $queue.ID
}
}
output:
Update-FogObject ...
Invoke-RestMethod : The remote server returned an error: (501) Not Implemented.
At C:\Program Files\WindowsPowerShell\Modules\FogApi\FogApi.psm1:270 char:19
+ $result = Invoke-RestMethod @apiCall;
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
PS C:\Users\Administrator> $HostJson
{
"hosts": [
"34",
"35",
"36",
"37",
"38",
"39",
"40",
"41",
"42",
"43"
]
}
PS C:\Users\Administrator> $queue.ID
35