Powershell and fog
-
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
- CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebR
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!
-
-
@jamaal is fogsrv the actual fqdn of your fogserver?
-
@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.
-
@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.
-
@Jamaal Anything in the Apache error logs? Sure the API is enabled (user and global)?
-
@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.
-
@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.
-
@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.