• 0 Votes
    11 Posts
    3k Views
    S

    I changed the code to PHP and now it works, so I think it was something security related from the browser.

  • How to delete a MAC address from a Host

    Solved FOG Problems
    7
    0 Votes
    7 Posts
    1k Views
    JJ FullmerJ

    @ajm2358 Is this a usb mac (or macs) that you use on devices that don’t have built-in lan?

    I have a powershell method for doing this via the api, but the full solution requires some infrastructure work to store the defined macs used for imaging somewhere you can get them. I embed them in an internal powershell module I use for provisioning. You may really just need one or 2 functions from this example and I also haven’t tested it working just copy paste. You would for sure need to install the module and connect to the api first. I took this from my module but I believe it should work once you have the module installed, imported, and connected.

    After a computer finishes imaging and provisioning, my last step is uses the powershell fogapi module (see the links in my signature for info on the module) to run

    $usbmacs = [pscustomobject]@{ mac = "00:00:00:00:00"; description = "mac description, I have these defined in a json, this is an inline example"; } $result = Remove-UsbMac -usbMacs.mac -hostname ($ENV:COMPUTERNAME);

    Then I make sure all the macs that are valid are present

    $physicalMacs = (get-netadapter | select-object -expand macaddress).replace("-",":") $fogHost = (Get-FogHost -hostName $ENV:COMPUTERNAME) $hostID = ($fogHost.id); $pendingFogmacs = Get-FogHostPendingMacs -hostID $hostID; $pendingFogmacs | ForEach-Object { $pendingMac = $_; if ($usbMacs.mac -notcontains $pendingMac.mac) { "Mac $pendingMac is pending and is not usbmac" | Out-Host; if ($physicalMacs -contains $pendingMac) { "Mac $($pendingMac.mac) is attached to this device, approving" | Out-Host; Approve-FogPendingMac -macObject $pendingMac; } else { if ($pendingMac.hostID -eq $hostID) { "Mac $($pendingMac.mac) is not attached to this device, removing it from Fog" | Out-Host Deny-FogPendingMac -macObject $pendingMac; } } } else { "Mac $($pendingMac.mac) is a usbmac, removing it from Fog" | Out-Host Deny-FogPendingMac -macObject $pendingMac; } } $fogMacs = Get-FogMacAddresses; $physicalMacs | ForEach-Object { $mac = $_; $fogMac = $fogmacs | Where-Object mac -eq $mac; if ($null -eq $fogMac) { if ($mac -notin $usbMacs.mac) { "$mac doesn't exist in fog, adding it for the host" | Out-Host; try { Add-FogHostMac -hostID $hostID -macAddress $_ -forceUpdate; } catch { Write-Warning "secondary mac address $($_) failed to add to host" } } else { "Usb mac $mac is attached, remove usb mac after provisioning!" | out-host; } } else { $otherHost = Get-FogHost -hostid $fogmac.hostId "Mac address $mac is already assigned to or pending for a different host, $($otherhost.name)" | out-host; } }

    Then I make sure I didn’t break the host on accident during that by unintentionally deleting all the macs

    try { $hostObj = (Get-FogHost -hostName $ENV:COMPUTERNAME) if (!$hostObj) { throw "host not found by name, trying by active mac instead" } } catch { $mac = get-activeMacAddress; $hostObj = Get-FogHost -macAddr $mac; } if ($hostObj.pending -ne '0') { Write-Verbose "The host is pending or not explicitly set to not pending in fog, adjust host to be approved be setting pending to '0'"; try { Reset-HostEncryption -fogHost $hostObj; $hostObj.pending = "0"; $jsonData = $hostObj | Select-Object id,pending | ConvertTo-Json; Update-FogObject -type object -coreObject host -IDofObject $hostObj.id -jsonData $jsonData; Restart-Service FOGService; } catch { Write-Verbose "There was an issue resetting host encryption or when running set-fogou -force. Host id is $($hostObj.id)" } }

    TL;DR

    Take a look at the Fog API Powershell Module especially the Remove-USBMac function and the Deny-FogPendingMac function. You can also use the above example for a more robust solution. The above solution also assumes its being run from the host in question, you can also manage any host remotely through the api.

  • 0 Votes
    18 Posts
    3k Views
    JJ FullmerJ

    @typotony That’s Great to hear!
    Glad you got it working and that it was as easy as intended.

  • API PUT request not working

    FOG Problems
    5
    0 Votes
    5 Posts
    1k Views
    B

    @judzk sorry I just saw this and yes I also see the error.

    Glad its working for you now.

    I also didn’t use the powershell module.

  • 0 Votes
    4 Posts
    1k Views
    JJ FullmerJ

    @r-pawlowski I would be happy to help in anyway I can. Personally, I deploy a bootmanager (grub2win) and the ipxe.efi file to each machines efi partition. Then I can just change the boot managers default to boot straight to fog. It takes a bit of time to get setup, but I found it to be the most reliable as I then didn’t have to worry as much about the bios settings. Theoretically you can use bcdedit commands to change the boot order to boot to network, but that also differs on different hardware.

    I digress though, the easy bit for queueing an image to deploy

    Follow the setup instructions for the fog API (involves installing the module from powershell gallery and then inputting your API keys and fog server address) Then make sure the host you’re imaging is assigned the correct image, this can be changed in the API if you need that, but for this quick example, we’ll pretend it’s set correct. For an example, we’ll say the hostname of a computer in fog is ‘test-computer’, so this will find the host in fog, then queue an image to deploy on it right now $hostID = (Get-FogHost -hostname 'Test-Computer').id #create a quick json string, this can also be done in a powershell object and converted, but this is just a quick example. #tasktypeID of 1 is a deploy task, if no runtime/schedule time is specified, it defaults to instant deploy # shutdown = 0 is not scheduling with shutdown # I believe other2 = 0 means not a debug # other4 = 1 means to enable wol # isactive =1 means the task is active $jsonData = "{`"taskTypeID`": 1,`"shutdown`":`"0`",`"other2`":`"0`",`"other4`":`"1`",`"isActive`":`"1`" }"; # make the API call to create the new task for your host New-FogObject -type objecttasktype -coreTaskObject host -jsonData $jsonData -IDofObject $hostId;

    Once you have this all setup in a powershell module or script internally, you can get things automated pretty smoothly. It’s meant to be modular so it can be applied to any infrastructure or workflow and built upon.

    If you need more help let me know and I’ll see what I can do.

  • USB Network Adapters

    FOG Problems
    8
    0 Votes
    8 Posts
    1k Views
    JJ FullmerJ

    My solution for this problem has been to use the api the remove usb macs when my provisioning script is done. I have it working by using the client.
    The basics are

    Computer gets registered with usb adapter My custom provisioning starts and the fog service is started which will add pending macs I leave the usb adapter plugged in until my provisioning is complete (so software install and whatnot happens over ethernet not wifi) Last step of provisioning uses a powershell api function to remove any existing usb macs (I have a saved list in the powershell of macs in my code) Adapter can then be removed and used on the next device

    My custom functions uses my published fogapi powershell module, particularly this function https://fogapi.readthedocs.io/en/latest/commands/Remove-UsbMac/
    Here’s a link to the code on github https://github.com/darksidemilk/FogApi/blob/master/FogApi/Public/Remove-UsbMac.ps1
    The function also handles making a new mac the client found be the primary mac if the usb mac is the current primary.
    If you’re not using the client, you could also create a custom automation to find the mac addresses of the machine during a postscript/firstlogon/provisioning step and have it use https://github.com/darksidemilk/FogApi/blob/master/FogApi/Public/Add-FogHostMac.ps1 to add a new unique mac then use the remove-usbmac function to remove specified usb macs.

    If you’d like more info or examples I’d be happy to help, just wanted to offer a quick overview of a possible solution.

  • 1 Votes
    6 Posts
    1k Views
    JJ FullmerJ

    @Chris-Whiteley I finally had some time to work on the module and created a Start-FogSnapin function that can deploy a single snapin task.

    See also https://fogapi.readthedocs.io/en/latest/commands/Start-FogSnapin/

  • fog API powershell help

    General
    7
    0 Votes
    7 Posts
    1k Views
    JJ FullmerJ

    @Jamaal
    @jj-fullmer said in fog API powershell help:

    Glad I had the code for get-foggroups somewhere to be found. It looks like something weird happened to the get-foggroups function and all the code disappeared from it. I’ll need to get that fixed as soon as I can as that function is used all over the place. I have made an issue for it https://github.com/darksidemilk/FogApi/issues/3

    I just published a new version of the module fixing the issue with get-foggroups and subsequently get-foggroupsbyname if you update to the new version 2103.2.12 those functions should work now.

  • FOG 1.5.4 API host module settings

    Solved FOG Problems
    10
    0 Votes
    10 Posts
    2k Views
    JJ FullmerJ

    @jj-fullmer said in FOG 1.5.4 API host module settings:

    @JJ-Fullmer said in FOG 1.5.4 API host module settings:

    @Jamaal Glad you got it figured out, sorry I didn’t see this early as adding it to the host splat that you convert to json adds it to the json data that @Tom-Elliott references here. I will make a note about adding something with setting modules to my module in the future

    Look, I made a note https://github.com/darksidemilk/FogApi/issues/1

    @Jamaal I also finally did something with this. I hope to at some point develop this a lot further and have dynamic parameters for snapins and groups when adding a host in powershell. But for now there is at least a basic new-foghost function that will create a host with a given name and mac list and enable the modules that you have set as default in your fog server.

    This is published in version 2103.2.12
    https://www.powershellgallery.com/packages/FogApi/2103.2.12
    https://github.com/darksidemilk/FogApi/releases/tag/2103.2.12

  • 4 Votes
    32 Posts
    13k Views
    JJ FullmerJ

    Another Release(s)! 2506.9.22
    https://github.com/darksidemilk/FogApi/releases/tag/2506.9.22

    2506.9.19-22 are a slew of releases where I kept finding issues in broader tests right after I released each version. So apologies for the over-releasing there.

    Fixed send-fogimage to work with more use cases and utilize more parameters available to scheduled tasks like bypassbitlocker. Also simplified the parameter sets to avoid errors when using the command with different parameter sets. Also added links to PSGallery and chocolatey in each github release going forward.

    Full Release Note History: https://fogapi.readthedocs.io/en/latest/ReleaseNotes/
    Powershell Gallery Listing for this version: https://www.powershellgallery.com/packages/FogApi/2506.9.22
    Chocolatey Package Listing for this version (may take 1-60 days from release to be approved by chocolatey moderators): https://community.chocolatey.org/packages/FogApi/2506.9.22

  • 0 Votes
    9 Posts
    6k Views
    JJ FullmerJ

    @jape You can use the api (See the powershell api module links in my signature). You can use it to create the scheduled task. i.e. (provided you got the module all setup prior) the following would create a scheduled deploy task for host with id ‘1234’
    at 8 pm tonight. The following is all powershell that can be run from your admin workstation.

    #define the schedule time in the linux format $startAtTime = (get-date 8pm) $EpochDiff = New-TimeSpan "01 January 1970 00:00:00" $($startAtTime) $scheduleTime = [INT] $EpochDiff.TotalSeconds - [timezone]::CurrentTimeZone.GetUtcOffset($(get-date)).totalseconds #define the schedule time in human readable format $runTime = get-date $StartAtTime -Format "yyyy-M-d HH:MM" $jsonData = @" { "name":"Deploy Task", "type":"S", "taskTypeID":"1", "runTime":"$runTime", "scheduleTime":"$scheduleTime", "isGroupTask":"0", "hostID":"1234", "shutdown":"0", "other2":"0", "other4":"1", "isActive":"1" } "@ #create the scheduled deploy task with the defined json New-FogObject -type object -coreObject scheduledtask -jsonData $jsonData