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

Powershell and fog

Scheduled Pinned Locked Moved
Tutorials
3
8
1.2k
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.
  • J
    Jamaal
    last edited by Dec 30, 2022, 10:48 AM

    Re: Powershell API Module

    Hello jj,

    I hope all is well with you. I am having fun with Powershell and the machine deployment. I
    have one question. So I’m having a little hard time with one thing. I would like to have Powershell create an image name in the images section in FOG. Now I can go in the console manually and create an image name for example Windows 10 22h2, but how would I go about creating it automatically in Powershell if it doesn’t exit?

    I tried new-fogobject -type object -coreobject image -jsondata $hostimage -verbose and got the 417 error. I had the json like this:

    VERBOSE: Building uri and api call
    VERBOSE: Pulling settings from settings file
    VERBOSE: Pulling settings from settings file
    VERBOSE: Building Headers…
    VERBOSE: Building api call URI…
    VERBOSE: POSTing System.Collections.Hashtable to/from http://fogsrv/fog/image/create
    VERBOSE: POST http://fogsrv/fog/image/create with -1-byte payload
    VERBOSE: POST http://fogsrv/fog/image/create with -1-byte payload
    Invoke-WebRequest : The remote server returned an error: (417) Expectation Failed.
    At C:\Program Files\WindowsPowerShell\Modules\FogApi\2103.2.12\FogApi.psm1:780 char:23

    •         $result = Invoke-WebRequest @apiCall;
      
    •                   ~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      • CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebR
        equest], WebException
      • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequ
        estCommand

    VERBOSE: finished api call

    I can’t do new-item because Powershell says it can’t find the path to the URL which I understand in that case you can’t use new-item, not like you’re creating a folder or file in the Windows operating system. I’ll keep trying, but that would be a good feature instead of creating it in the console. I’m trying to make the script more dynamic if something doesn’t exist in the console.

    Again, thanks to you and the other person (forgot his screen name) that helped with Powershell and FOG, makes a huge difference!

    T 1 Reply Last reply Dec 30, 2022, 1:08 PM Reply Quote 0
    • T
      Tom Elliott @Jamaal
      last edited by Dec 30, 2022, 1:08 PM

      @jamaal is fogsrv the actual fqdn of your fogserver?

      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! Get in contact with me (chat bubble in the top right corner) if you want to join in.

      Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

      Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

      J 1 Reply Last reply Dec 30, 2022, 1:24 PM Reply Quote 0
      • J
        Jamaal @Tom Elliott
        last edited by Dec 30, 2022, 1:24 PM

        @tom-elliott said in Powershell and fog:

        @jamaal is fogsrv the actual fqdn of your fogserver?

        Yes, just for testing purposes. Eventually I will have a different name.

        T 1 Reply Last reply Dec 30, 2022, 2:44 PM Reply Quote 0
        • T
          Tom Elliott @Jamaal
          last edited by Dec 30, 2022, 2:44 PM

          @jamaal What if you define fogsrv to the IP address of the fogserver?

          FQDN must be reachable by the device in question. Using the IP address is usually a more sure bet.

          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! Get in contact with me (chat bubble in the top right corner) if you want to join in.

          Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

          Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

          J 1 Reply Last reply Dec 30, 2022, 11:33 PM Reply Quote 0
          • S
            Sebastian Roth Moderator
            last edited by Dec 30, 2022, 10:48 PM

            @Jamaal Anything in the Apache error logs? Sure the API is enabled (user and global)?

            Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

            Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

            J 1 Reply Last reply Dec 30, 2022, 11:34 PM Reply Quote 0
            • J
              Jamaal @Tom Elliott
              last edited by Dec 30, 2022, 11:33 PM

              @tom-elliott said in Powershell and fog:

              @jamaal What if you define fogsrv to the IP address of the fogserver?

              FQDN must be reachable by the device in question. Using the IP address is usually a more sure bet.

              I’m going to try that later & let you know. Thanks for the suggestion, Tom.

              1 Reply Last reply Reply Quote 0
              • J
                Jamaal @Sebastian Roth
                last edited by Dec 30, 2022, 11:34 PM

                @sebastian-roth said in Powershell and fog:

                @Jamaal Anything in the Apache error logs? Sure the API is enabled (user and global)?

                Yes, the API is enabled. I’m not sure on how to check the apache error logs.

                1 Reply Last reply Reply Quote 0
                • S
                  Sebastian Roth Moderator
                  last edited by Dec 31, 2022, 8:18 AM

                  @jamaal said in Powershell and fog:

                  . I’m not sure on how to check the apache error logs.

                  You need console access (e.g. SSH) to your FOG server. See my signature on where to find the logs files.

                  Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                  Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  1 / 1
                  • First post
                    6/8
                    Last post

                  147

                  Online

                  12.0k

                  Users

                  17.3k

                  Topics

                  155.2k

                  Posts
                  Copyright © 2012-2024 FOG Project