Posts made by 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.
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.
-
fog API powershell help
@jj-fullmer or someone also that’s working on API
Hello, all,
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
-
RE: Powershell API Module
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.
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.
-
RE: API - Powershell Create host and Deploy task script
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… -
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.
-
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. -
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. -
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? -
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)
- You want other employees to put info about a new computer into that product in some way
- That product sends that info to a powershell script
- 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.
-
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.
-
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.
-
RE: Setting up a Windows 2012 server as a FOG Storage Node
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.
-
Need Powershell help
Hello,
I was viewing a powershell script I saw online about 2 days ago and I got it to add the new machine in the fog server with the MAC address fine. I also saw how to add 1 or more snapins if needed, so thank you for that.
Here’s my question. So is there a powershell command to select adding the Active Directory option to the new host instead of going to the console to check off for each new host?
I know how to do it in the console, but want to know how to do it in this script I saw on the forum by ScottyBullet: https://forums.fogproject.org/topic/11183/api-create-host-deploy-task-error-invalid-tasking-type-passed/7?_=1590872437608
So I’m basically putting the Powershell script together when the other techs put in the valid info in Microsoft Orchestrator, it will kick off the powershell script, add the machine to the fog database and kick off imaging while plugged into the network.
Appreciate all the hard work on this forum. I’ve learned a lot on here and imaged a lot of computers from last year.
-
RE: Setting up a Windows 2012 server as a FOG Storage Node
George,
How did this work for you? I’m thinking about doing this as I’m starting to run out of room on a hyper v box and thinking about just building a Windows Server 2019 vm and make it as a secondary storage server.
-
RE: API - Create Host Deploy Task "error": "Invalid tasking type passed"
@Sebastian-Roth said in API - Create Host Deploy Task "error": "Invalid tasking type passed":
@Jamaal From the error message I would imagine that this last call is failing because an earlier query also failed and variables are not being set correctly because of the earlier error. So you need to post the full error you see!
I am not a PowerShell wiz but from what I know the
read-host
stuff you added should work.Thanks man, you pointed me in the right direction.
So I went back to your script again and ran it and noticed it kept giving an error message after the 1st throw command, like Powershell was skipping the 2nd and 3rd throw command.What I had to do was do a read-host, but kept the $ (read-host “enter machine name”) for example:
[String] $MachineName = $( read-host “Provide the target machines Name”),
[String] $MacAddress = $(Read-Host “Provide the target machine Address”),
[String] $ImageName = $(read-host “Provide the Image Name to assign to the new target host”)
So I saw the task in the task list right away. I’m so so with powershell and starting to get better with it, you know. What I would like to do is maybe figure out powershell commands to add the snapins as a read-host so the tech can select which snapins to use instead of going to the Fog console to be more automatic.And I would like Powershell to start the task once the hostname is added to Fog. I can start playing around that.
-
RE: API - Create Host Deploy Task "error": "Invalid tasking type passed"
I’m having issues with this, not sure what I’m doing wrong.
I’ll still troubleshoot, but getting this error:Invoke-RestMethod : Cannot validate argument on parameter 'Uri'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. At E:\Temp\Scripts\fogtest2.ps1:66 char:52 + $TasktypesResult = Invoke-RestMethod -Uri $TasksURL -Method ... + ~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Invoke-RestMethod], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeRestMethodCommand Invoke-RestMethod : The remote server returned an error: (501) Not Implemented. At E:\Temp\Scripts\fogtest2.ps1:79 char:23 + ... askResult = Invoke-RestMethod -Method Post -Uri $TaskURL -Headers $he ...
This is how I have it edited from the beginning, not sure if this messing it up:
$vmname =read-host "Enter the computer name you want to name" $MacAddress = read-host "Enter the MAC Address of the host computer you're going to image" $ImageName = read-host " Enter the name of the image you want to use"
I edited it like that because I want to test for example, another technician to just put the values in there and then your script will automate everything.
-
RE: unable to install CA certificate (MDT 2013)
@Sebastian-Roth said in unable to install CA certificate (MDT 2013):
@Jamaal said in unable to install CA certificate (MDT 2013):
I changed from the quiet switch to passive and I noticed the CA certificate error.
Please give us more information about this. Exact error message? Possible take a screenshot and port here.
Please close this ticket! It was my mistake. The issue was that I found a powershell script to disable the internet access during the MDT process, but the program was since fog tried to reach the ip address of the fog server, it was being blocked due to non internet access. I moved the script further down the process and it installed. Thanks for all of your input though.
-
RE: unable to install CA certificate (MDT 2013)
@Jamaal said in unable to install CA certificate (MDT 2013):
@Sebastian-Roth said in unable to install CA certificate (MDT 2013):
@Jamaal said in unable to install CA certificate (MDT 2013):
I changed from the quiet switch to passive and I noticed the CA certificate error.
Please give us more information about this. Exact error message? Possible take a screenshot and port here.
It was working before…
Which components exactly were used when it worked last? Windows 10, which build version? fog-client 0.11.16 I suppose? MDT 2013?? Just trying to rule out what we can here.
Ok, I’m using MDT 2013 update 2 and during building the reference image, I used Windows 10 build 1803. To be honest, I don’t remember the build of the fog client, just used the new MSI one, not the legacy one.
for some reason, I can’t get that error no more, but after looking in the logs of MDT, I get this: Application Fog - install returned an unexpected return code: 1603.
The version of the fog client is 0.11.16 -
RE: unable to install CA certificate (MDT 2013)
@Sebastian-Roth said in unable to install CA certificate (MDT 2013):
@Jamaal said in unable to install CA certificate (MDT 2013):
I changed from the quiet switch to passive and I noticed the CA certificate error.
Please give us more information about this. Exact error message? Possible take a screenshot and port here.
It was working before…
Which components exactly were used when it worked last? Windows 10, which build version? fog-client 0.11.16 I suppose? MDT 2013?? Just trying to rule out what we can here.
Ok, I’m using MDT 2013 update 2 and during building the reference image, I used Windows 10 build 1803. To be honest, I don’t remember the build of the fog client, just used the new MSI one, not the legacy one.