• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login
    1. Home
    2. Jamaal
    3. Posts
    J
    • Profile
    • Following 1
    • Followers 0
    • Topics 14
    • Posts 85
    • Groups 0

    Posts

    Recent Best Controversial
    • Fog Location help via FOG API

      Hello, all

      I’m starting to get closer, but not sure what I’m missing. I read up on pscustomobject and I did the following in the script. So in the first screen shot, I got the member properties from get-foghost -hostname $machinename | get-member

      The screenshot called “before”, doesn’t have the location field.

      before.PNG

      What I did was created a pscustomobject by creating a variable called $member

      so $member = new-object -typename psobject
      The screenshot I did later was called “after”
      after.PNG

      I then did $member | get-member and it added location as you can see in the screen shot.
      In the parameter, I did location = Westbury for example. Here’s some screen shots of my script.

      parameters.PNG

      code that I used to add location:
      location.PNG

      So I already have the plugin Location installed with values such as Woodbury and Edison.

      I’m trying to get Powershell to just load my section from $location to location as seen below, but it’s not working despite I used the pscustomobject
      accomplish.PNG

      posted in FOG Problems
      J
      Jamaal
    • RE: FOG API help

      @sebastian-roth said in FOG API help:

      @jamaal said in FOG API help:

      Cannot convert value “http://your fog server hostname or ip address to be used for created the url used in api calls default is fog-server or fogServer/fog/task/active”

      I have not used @JJ-Fullmer’s FogApi yet I have to admit. But this message seems to stem from the settings.json not being setup correctly: https://github.com/darksidemilk/FogApi/blob/master/FogApi/lib/settings.json

      I’ll definitely check this out today, thanks Sebastian. One more question. How would I add location via api? We have our main site and also have another location and I wanted the techs to select Boston as a site for example. I do have the plug in enabled via the console, but want to do it in the Powershell script if possible.

      posted in General
      J
      Jamaal
    • FOG API help

      Hello all,

      I haven’t posted in a while, so I need a little help.
      I’m running Server 2019 Data Center on my test desktop machine and have FOG API installed. The script runs great by itself, ex; adding the machine name and snapins based on parameters, but here’s the issue.

      I’m testing out a third party software called Au2mator. It can use an engine like Powershell. I have the questions in parameters and when it runs, it creates the task and machine name in Powershell, but doesn’t add the machine to the group or does it add the snapins. I have the Au2mator software using a service account that has local AD rights on the box, the pool has the correct service account and password, but still get these errors when I run it with the Au2mator software:

      Log Name: PowerShellCore/Operational
      Source: PowerShellCore
      Date: 2/3/2022 6:16:31 AM
      Event ID: 4100
      Task Category: Executing Pipeline
      Level: Warning
      Keywords: None
      User: JBCORP\Au2umator
      Computer: HYPER-SRV.jbcorp.com
      Description:
      Error Message = Cannot bind parameter ‘Uri’. Cannot convert value “http://your fog server hostname or ip address to be used for created the url used in api calls default is fog-server or fogServer/fog/task/active” to type “System.Uri”. Error: “Invalid URI: The hostname could not be parsed.”
      Fully Qualified Error ID = CannotConvertArgumentNoMessage,Invoke-FogApi

      Context:
      Severity = Warning
      Host Name = Default Host
      Host Version = 7.1.3
      Host ID = ad4c57c0-2fac-4d68-a7c0-d9af957dc1a0
      Host Application = C:\Inetpub\au2mator\A2M.Presentation.dll
      Engine Version = 7.1.3
      Runspace ID = 4e8439ad-a4ba-4dc0-adeb-519501e60f21
      Pipeline ID = 1
      Command Name = Invoke-FogApi
      Command Type = Function
      Script Name = C:\Program Files\WindowsPowerShell\Modules\FogApi\2103.2.12\FogApi.psm1
      Command Path =
      Sequence Number = 31
      User = testdomain\testaccount
      Connected User =
      Shell ID = Microsoft.PowerShell

      User Data:

      Event Xml:
      <Event xmlns=“http://schemas.microsoft.com/win/2004/08/events/event”>
      <System>
      <Provider Name=“PowerShellCore” Guid=“{f90714a8-5509-434a-bf6d-b1624c8a19a2}” />
      <EventID>4100</EventID>
      <Version>1</Version>
      <Level>3</Level>
      <Task>106</Task>
      <Opcode>19</Opcode>
      <Keywords>0x0</Keywords>
      <TimeCreated SystemTime=“2022-02-03T11:16:31.401253300Z” />
      <EventRecordID>1654</EventRecordID>
      <Correlation ActivityID=“{b5238339-183a-0002-0598-30b53a18d801}” />
      <Execution ProcessID=“12736” ThreadID=“14664” />
      <Channel>PowerShellCore/Operational</Channel>
      <Computer>HYPER-SRV.jbcorp.com</Computer>
      <Security UserID=“S-1-5-21-3280824798-2153847428-653206688-5347” />
      </System>
      <EventData>
      <Data Name=“ContextInfo”> Severity = Warning
      Host Name = Default Host
      Host Version = 7.1.3
      Host ID = ad4c57c0-2fac-4d68-a7c0-d9af957dc1a0
      Host Application = C:\Inetpub\au2mator\A2M.Presentation.dll
      Engine Version = 7.1.3
      Runspace ID = 4e8439ad-a4ba-4dc0-adeb-519501e60f21
      Pipeline ID = 1
      Command Name = Invoke-FogApi
      Command Type = Function
      Script Name = C:\Program Files\WindowsPowerShell\Modules\FogApi\2103.2.12\FogApi.psm1
      Command Path =
      Sequence Number = 31
      User = JBCORP\au2umator
      Connected User =
      Shell ID = Microsoft.PowerShell
      </Data>
      <Data Name=“UserData”>
      </Data>
      <Data Name=“Payload”>Error Message = Cannot bind parameter ‘Uri’. Cannot convert value “http://your fog server hostname or ip address to be used for created the url used in api calls default is fog-server or fogServer/fog/task/active” to type “System.Uri”. Error: “Invalid URI: The hostname could not be parsed.”
      Fully Qualified Error ID = CannotConvertArgumentNoMessage,Invoke-FogApi
      </Data>
      </EventData>
      </Event>

      I’ve tried a few things like putting the url directly instead of using $baseuri, even tried “$baseuri/restofurl” same issue. I’m not sure what I’m missing here.

      I know I’ve worked with a few guys on here with the FOG API via Powershell, so if I can get assistance, I appreciate it.

      posted in General
      J
      Jamaal
    • RE: fog API powershell help

      @jj-fullmer said in fog API powershell help:

      $snapinsToRemove = @(‘snapin’,‘names’,‘here’);

      That’s what I needed, an array to choose from a list. Thank you so much! Really appreciate you on helping me on this.

      posted in General
      J
      Jamaal
    • RE: fog API powershell help

      @jj-fullmer said in fog API powershell help:

      @jamaal I have a function for inventory here https://fogapi.readthedocs.io/en/latest/commands/Get-FogInventory/
      It gets the same inventory information via powershell and adds it to fog.
      I can also help you with queuing the native inventory task, but that might be a bit trickier. I think you can schedule more than one task for a machine when it’s a scheduled task, but I’m not sure.

      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

      Thanks jj, appreciate it. And another question. So I read in the fog forums and also the general fog page that snapins for groups don’t function, correct? I created a group called sales and when I added snapins to it, they never stayed. I then started reading up on it and said the groups only serve mostly as a category for naming& imaging purposes.

      It would be create if there was a way to add snapins to groups so when the other technicians use Microsoft Forms for example, they select which group the pc will go to and then the pc will automatically have all the snapins.

      If somehow that gets done in future, please let me know. Or do you know of a powershell command to add multiple snapins at once? Ex; the tech would click on the checkbox on Microsoft Form for more than one snapin, so I need to create a powershell statement to group more than one snapin.

      posted in General
      J
      Jamaal
    • RE: Powershell API Module

      @jj-fullmer said in Powershell API Module:

      vscode

      Thanks jj,

      I’ll install & try out.

      posted in Tutorials
      J
      Jamaal
    • RE: fog API powershell help

      Ok, I think I got this figured out just now.
      Thanks to you jj, I followed your example from your original link:

      https://forums.fogproject.org/topic/12026/powershell-api-module/11

      So far I got this to work on one host: Here’s what I did by using your script:

      $newAssocs = New-Object System.Collections.Generic.List[object];
      $computer = (get-foghost -hostname “itloaner”).id
      $groups = (get-fogobject -type object -coreobject group).groups | where-object name -eq “sales”
      $groupAssocs = Get-FogObject -Type Object -CoreObject groupassociation

      $json = @{
      “hostID”=$computer;
      “groupID”=“$($groups.id)”;
      } | ConvertTo-Json;
      # Note, when creating the json splat and then piping it to convertto-json you must encapsulate properties and values in quotes and match the case of the original property (i.e. ID instead of Id) as in this example or it won’t parse right and will return a 417 error from the api

      $result = New-FogObject -type object -coreObject groupassociation -jsonData $json;
      $NewAssocs.Add($result);

      #list the newassocs that added the laptops to your group
      $NewAssocs;

      It then showed up as it added as per the results attached in this message.test1.PNG

      For further proof, I went to my test host and verified it was added via the new-fogobject command. I’m starting to understand now how this works. I just need to keep playing around with it and should be good going forward.

      My next task is to try to create a task via powershell to get the inventory of the machine before deploying the image. If you know of any commands, please let me know and I’ll keep trying myself as well.

      Again thanks for the info.

      posted in General
      J
      Jamaal
    • fog API powershell help

      @jj-fullmer or someone also that’s working on API

      Hello, all,parameter not recognized.PNG

      Thanks for the fog api notes, appreciate you helping us out. I’m not sure if you remembered me, but have a few questions.

      I’m trying to do 2 things. One to assign a group to a machine one created in fog via powershell. I tried get-foggroupbyname, but says the parameter is not recognized.parameter not recognized.

      It then told me to go to c:\program files… until I got to fogapi.psm1

      I copied and pasted the command for cmdletBinding.

      It didn’t error out, but didn’t return anything. Ex; , I know I created a Sales group in the Fog Gui with snapins assigned to it, so I wanted the machine to be assigned to that group to make it more dynamic. Please see attached pics. I’ll keep trying as well on my side. I’m so so on Powershell, but came a long way.parameter

      posted in General fogapi-psmodule
      J
      Jamaal
    • RE: Powershell API Module

      @jj-fullmer

      Hello, jj,

      Thanks for the fog api notes, appreciate you helping us out. I’m not sure if you remembered me, but have a few questions.

      I’m trying to do 2 things. One to assign a group to a machine one created in fog via powershell. I tried get-foggroupbyname, but says the parameter is not recognized.parameter not recognized.PNG

      It then told me to go to c:\program files… until I got to fogapi.psm1

      I copied and pasted the command for cmdletBinding.

      It didn’t error out, but didn’t return anything. Ex; , I know I created a Sales group in the Fog Gui with snapins assigned to it, so I wanted the machine to be assigned to that group to make it more dynamic. Please see attached pics. I’ll keep trying as well on my side. I’m so so on Powershell, but came a long way.parameter 2.PNG

      posted in Tutorials
      J
      Jamaal
    • RE: API - Powershell Create host and Deploy task script

      @scottybullet

      This was very helpful! Thanks for sharing this.
      I used it with Microsoft Forms which goes back a SharePoint list, then talks to Microsoft
      Orchestrator with all the variables, ex; image name, MAC, etc…

      posted in Tutorials
      J
      Jamaal
    • RE: Need Powershell help

      @JJ-Fullmer said in Need Powershell help:

      @Jamaal I believe that the wake on lan is enabled by default, so you don’t need to do anything to include it when creating the deploy task via the api.

      Ok, gotcha.

      Thank you very much for letting me know of this.

      posted in General
      J
      Jamaal
    • RE: FOG 1.5.4 API host module settings

      @Sebastian-Roth said in FOG 1.5.4 API host module settings:

      Pinging @JJ-Fullmer on this. 🙂

      All,

      I figured this out! I got hostname changer via PowerShell. So here’s what I did to resolve it.
      So with the script I got from this forum last week, I know it had the Json in a splat format. I’m so so with PowerShell
      and doing a lot better than a few years back. So basically what KaterKarlo said, he has moduleid = 9.

      It wasn’t working for me. To get the correct name and ID number, I ended up going to my fog server via the browser, then right click on the browser and view page source did a search for hostname changer. Then it came up the name modules and the value of 9. I finally ended up putting it with the rest of the splat and joined it with no issues:

      “modules” = 9

      I hope this helps someone as well if they need to get the values of a host.
      But thank you guys always for pointing me in the right direction.

      posted in FOG Problems
      J
      Jamaal
    • RE: FOG 1.5.4 API host module settings

      @Sebastian-Roth said in FOG 1.5.4 API host module settings:

      Pinging @JJ-Fullmer on this. 🙂

      Thanks Sebastian,

      Appreciate you and everyone else assisting. I’m still learning PowerShell up to this day
      and like the fact the scripts on this forum is making Fog work even more dynamic.

      posted in FOG Problems
      J
      Jamaal
    • RE: FOG 1.5.4 API host module settings

      @Tom-Elliott said in FOG 1.5.4 API host module settings:

      @katerkarlo99 when creating the host via api, you can associate snapins, printers, groups, and modules using the ids of the relevant item as an array using the respective key as the object identifier.

      For example, creating a host with associating the client modules your data element would be:

      {
        "macs" : [ "00:01:02:03:04:05" ],
        "name" : "hostname",
        "modules" : [ 1,2,3,4,5,6,7,8,9,10,11,12 ]
      }
      

      Or very similar.

      The api call would be to /fog/host/create of POST request.

      Did you all ever get this figured out in Powershell?
      I’m trying to activate hostname changer as well so the computer automatically joins the domain. In the PowerShell script I got from this forum, it has the force AD, but if the hostname changer is not selected by default, it won’t join the domain. If you got this working, can you please tell me what you did exactly?

      posted in FOG Problems
      J
      Jamaal
    • RE: Need Powershell help

      @JJ-Fullmer said in Need Powershell help:

      TL;DR
      The quick answer is the ‘useAD’ property of a host in the api checks that box, but will not pull your default settings when done through the api. So you need to provide all domain join info.

      @Jamaal Good day sir! Sorry for a delayed reply, haven’t been on here in a bit, had been trying to stay active during my quarantine but eventually my infant son won all my attention while I was home. But I am now back at work and am excited to see someone with a powershell api question =).

      I took a look at that old post and @scottybullet and I should clearly be friends. Looks like he posted some powershell api stuff before I published my module publicly.

      So as @Sebastian-Roth mentioned, check out the powershell module (check the links in my signature). If you use that as a dependency of your script you’ll have a good time. If this leads to some more functions needing to be added to the module to make it easier we can make the functions and get them added.

      So let me see if I got this straight.

      You have microsoft orchestrator (I’m not actually familiar with that product, but I think I get what it does from context)

      1. You want other employees to put info about a new computer into that product in some way
      2. That product sends that info to a powershell script
      3. The script adds the computer to fog and queues it to start imaging with wake on lan as soon as you plug it in to the network.

      Currently it isn’t auto joining the domain but you want it to.

      Well sir I believe the answer may be pretty easy. I usually add fog hosts using the pxe boot menu
      Firstly, something built in fog is setting default AD settings at http://fog-server/fog/management/index.php?node=about&sub=settings (select Active directory defaults). I pull that info when I register a host in the pxe boot menu and then edit it during a provisioning script to put things in the right OU. But I just realized that doesn’t matter because it doesn’t pull that information when you create from the API, but it’s still a feature that exists and there may be a way to leverage it in your situation but we’ll come back to that if we need to.

      Ok so first let’s create a host

      # you can also just do name, description, and macs and add the rest after with a set-fogobject command
      $HostJson = @{
          "name"=  "testHost-1"
          "description"=  "a test"
          "macs" =  @("11:22:33:44:55:66")
          "imageID" = "29"
          "useAD" = 1 
          "ADDomain" = "yourDomain.com"
          "ADOU" =  "OU=OUname,OU=ParentOU,OU=GrandParrentOU,DC=yourDomain,DC=com"
          "ADUser" = "domainUsername"
          "ADPass" = "plainTextPassword"
          "enforce" = 1
      }
      #note that "useAD" = 1 checks the join domain after deploy box
      #note that "enforce" = 1 checks the force rename and join even if user is logged in box
      #note that the password is in plaintext via the api because you are already authenticated to get to this point, this is why I prefer to pull from the existing default so I don't pass the password in plaintext anywhere. 
      
      #convert to ps object to a json string
      $json = $hostJson | ConvertTo-Json
      $newHost = New-FogObject -type object -coreObject host -jsonData $json
      

      Sidenote: @Tom-Elliott or @Sebastian-Roth is it possible to pull the default domain settings include username/password from the fog settings via the api? So that to add domain join info through an api call doesn’t require a plaintext password, or maybe some other solution, like making it so the defaults are pulled if a host created with the api has that join after deploy/useAD box checked?

      So that above code would add a new host with the domain information and stores the host info in a variable. You could then queue the image of the host with (I should really make a function for this)

      $jsonObj = @{
          "taskTypeID" = 1
      }
      $jsonData = $jsonObj | ConvertTo-Json;
      # create the image task on the newhost 
      New-FogObject -type objecttasktype -coreTaskObject host -jsonData $jsonData -IDofObject $newHost.ID;
      

      Thank you so much! Much appreciated. I’m starting to play around with both your script and Scotty’s as well. I started looking over the get-fogobject and just trying to get the option to use wake on LAN. If you have any idea on how to do so, I appreciate it.

      posted in General
      J
      Jamaal
    • RE: Need Powershell help

      @Sebastian-Roth said in Need Powershell help:

      @Jamaal I have not used the PowerShell stuff myself yet and so I can only refer you to the great information @JJ-Fullmer provided here: https://forums.fogproject.org/topic/12026/powershell-api-module (he might also be able to answer the question more thoroughly)

      If there is really something missing in the API itself you guys just need to call out for us to fix this.

      Thank you, Sebastian.

      posted in General
      J
      Jamaal
    • RE: Setting up a Windows 2012 server as a FOG Storage Node

      @george1421 said in Setting up a Windows 2012 server as a FOG Storage Node:

      @Jamaal The tutorial was more of a proof of concept than something that should be used in production. Did it work, yeah. Would I probably use it… maybe not but some of the dedup capabilities in 2016 and 2019 make it sound intreaging.

      For your case if you have additional space on your VM host server you might consider adding an additional virtual disk to your fog server then adding it to the LVM group for your fog server. There are a number of ways to go about this, but that discussion should be moved to a new thread.

      Ok, I’ll create a new post, thanks for your assistance.

      posted in Tutorials
      J
      Jamaal
    • RE: Setting up a Windows 2012 server as a FOG Storage Node

      @Sebastian-Roth

      Thanks for getting back to me Sebastian. So I have Fog on a vm via Windows Server 2019 running Ubuntu 18.xx, forgot the exact version. So I see I’m at 95 % on the fog server and I think it’s due to me saving Windows drivers to use when the laptops or desktops are done to bring them down after Fog images. I tried one day on how to make more space in Ubuntu, but I’m not really a Linux guy, only Windows.

      I know a little few commands based on this forum and looking things up in Google, so my goal is to at least have 50% storage space at all times so I don’t run out of space. If you can guide me, I appreciate it.

      posted in Tutorials
      J
      Jamaal
    • 1 / 1