• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Is it possible to pass variables to snapins?

    Scheduled Pinned Locked Moved Solved
    General
    2
    8
    1.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Szeraax
      last edited by

      I have a snapin (pwoershell template) that I would like to run with an argument pulled from the host’s inventory (PrimaryUser field). Is this possible? Am I just too crazy?

      Man it would be cool if it can do this. I don’t know much about snapins though :S

      Wayne WorkmanW 1 Reply Last reply Reply Quote 0
      • Wayne WorkmanW
        Wayne Workman @Szeraax
        last edited by

        @szeraax said in Is it possible to pass variables to snapins?:

        Is this possible?

        Yes but not the way you’re thinking. FOG has an API, so from your powershell script just call the API and get the info you need for the host the script is running on.

        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
        Daily Clean Installation Results:
        https://fogtesting.fogproject.us/
        FOG Reporting:
        https://fog-external-reporting-results.fogproject.us/

        1 Reply Last reply Reply Quote 0
        • S
          Szeraax
          last edited by

          Can you link me to that API? or maybe an example line of calling it? Is it just rest?

          S Wayne WorkmanW 2 Replies Last reply Reply Quote 0
          • S
            Szeraax @Szeraax
            last edited by

            First result from Google: https://forums.fogproject.org/topic/11184/api-powershell-create-host-and-deploy-task-script probably should do more reading before I ask you follow up questions.

            1 Reply Last reply Reply Quote 1
            • Wayne WorkmanW
              Wayne Workman @Szeraax
              last edited by

              @szeraax This is the link: https://news.fogproject.org/simplified-api-documentation/
              Right now, news.fogproject.org is broke. I’ve messaged our senior devs and they should get it fixed relatively quick.

              You may also look at this entire thread, as it deals heavily with the API: https://forums.fogproject.org/topic/9779/can-i-use-some-kind-of-script-to-create-image-and-ghost-my-lab-machines

              Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
              Daily Clean Installation Results:
              https://fogtesting.fogproject.us/
              FOG Reporting:
              https://fog-external-reporting-results.fogproject.us/

              S 1 Reply Last reply Reply Quote 0
              • S
                Szeraax @Wayne Workman
                last edited by

                Am able to see the cached version, looks pretty easy. I’ll play and mark solved or follow up if I get stuck. Thanks a ton!

                Wayne WorkmanW 1 Reply Last reply Reply Quote 0
                • Wayne WorkmanW
                  Wayne Workman @Szeraax
                  last edited by

                  @szeraax Also so you’re aware, I vaguely remember a way to pass arguments directly into the snapin itself. This may be cleaner for you, maybe not. Search around in the forums and you’ll probably find it. I think the post is made by the user @joe-schmitt He’s the guy that made the new fog client.

                  Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
                  Daily Clean Installation Results:
                  https://fogtesting.fogproject.us/
                  FOG Reporting:
                  https://fog-external-reporting-results.fogproject.us/

                  1 Reply Last reply Reply Quote 0
                  • S
                    Szeraax
                    last edited by

                    So it looks like the API works great for what I need. But how do I mark as solved? I can’t find anything that lets me change this status 😞

                    My code from the api is something similar to:

                    $fogApiToken = 'mf...A='
                    $fogUserToken = '5Mz...NDY='
                    $fogServer = "IP ADDRESS GOES HERE"
                    
                    $headers = @{};
                    $headers.Add('fog-api-token', $fogApiToken);
                    $headers.Add('fog-user-token', $fogUserToken);
                    $BaseUri = "http://$fogServer/fog"
                    $HostURL = $baseUri +"/host/"
                    $HostResult = Invoke-RestMethod -Uri $HostURL -Method GET -Headers $headers -ContentType "application/json"
                    $ThisHost = $HostResult.hosts | ? name -eq $ENV:COMPUTERNAME
                    $PrimaryUser = $ThisHost.Inventory.PrimaryUser.Trim()
                    
                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post

                    156

                    Online

                    12.0k

                    Users

                    17.3k

                    Topics

                    155.2k

                    Posts
                    Copyright © 2012-2024 FOG Project