Post Download Scripts and Powershell
-
Hello everyone,
I am new to FOG and imaging in general, so any help would be appreciated!I am getting familiar with post download scripts through this article: https://forums.fogproject.org/topic/7740/the-magical-mystical-fog-post-download-script
and I was wondering if it would be possible to execute a Powershell script on a target machine using post download scripts?
Or would it be possible to trigger a Snap-in (that is pretty much that same powershell script) using post download scripts?Thanks!
-
@ayashkam said in Post Download Scripts and Powershell:
I was wondering if it would be possible to execute a Powershell script on a target machine using post download scripts
The short answer is no. The FOS Linux engine (the OS that captures and deploys images) is linux based and powershell is Windows based. There is no way for FOS Linux to directly call powershell and interact with the windows target system. Postdownload and PostInit scripts have to be bash or csh based.
Once the target OS has started and the FOG Client is installed on the target computer you can run snapins on the target computer. Those snapins can call executable or scripts that execute on the target computer.
What are you trying to accomplish? As you see from that tutorial you can leave “breadcrumbs” behind, where windows WinSetup/OOBE can pickup and use. FOG’s main goal is to push the image to the target computer the fastest way possible, then exit. This leaves the target computer’s setup to complete the configuration process.
-
how is FOG able to set the hostname in Windows immediately after imaging though? I’ve noticed that after imaging, the computer name in Windows is set to whatever i set the hostname to during the Full Registration process.
-
@george1421 I believe Microsoft has been trying to create a cross platform powershell (https://devblogs.microsoft.com/dotnet/powershell-is-now-open-source-and-cross-platform/), though I don’t see us integrating that into FOS.
-
@brakcounty said in Post Download Scripts and Powershell:
how is FOG able to set the hostname in Windows immediately after imaging though?
If you use the standard name hosting within FOG, that is the FOG Clients job to rename the system. In this way the system when it first comes up will have the default system name and then will be renamed by the FOG Client. There is an early name change options, but I’m not sure that still works with Win10.
As you seen in my scripts, I update the unattend.xml file from FOG during a post install script process. Here is a bit more refined tutorial that I mentioned before, it has less details but is more straight forward with the scripts: https://forums.fogproject.org/topic/11126/using-fog-postinstall-scripts-for-windows-driver-injection-2017-ed
-
@george1421 said in Post Download Scripts and Powershell:
how is FOG able to set the hostname in Windows immediately after imaging though?
Actually there is a mechanism in FOS that uses Linux tools to modify Windows registry files to set the hostname. It’s kind of a hack but obviously works quite well.
Still I don’t see why we should add powershell scripting capability. What exactly are you trying to do??
-
@george1421 Thanks for quick response!
What I need is for some of the powershell scripts to execute on the host machines after the deployment. They are quite complex and Windows specific, so it is not desired to convert them into bash scripts.
I was actually reading through this forum and somewhere it was written that Snapins associated with the host get executed after deployment (I initially thought they were just sent, but not executed). Could you please confirm that this is correct? I tested on one machine and it looks correct, but I would feel safer if you could confirm.
If so, my problem would be solved by using snapins! -
@ayashkam said in Post Download Scripts and Powershell:
I was actually reading through this forum and somewhere it was written that Snapins associated with the host get executed after deployment
That is correct, you can assign a snapin to a client or client group and when the system is images, that snapin task will be added to the task queue for that host. That task will be deployed once imaging is done. The only requirement is to have the FOG Client installed on the target computer. I believe there is even a template for powershell (sorry I can’t be absolute since I don’t use snapins in my environment).
-
@george1421 I confirm that exist powershell template :D:D:D .
@ayashkam You can do it, The automated snapin execution is basic for me, my images are living entities and my software requirements continously changes (Education environment with more than 250 different sites and more than 15.500 computers).
I have my image’s configured to install fogclient and start it on the first boot, you can do it with the unattended deployment procedures (setupcomplete.cmd) for example if you sysprep the images or use other ways like scheduling it at start up.
I download the installer with the postdownloadscript to ensure that the current version is installed. Take care because at the moment that you run the service the snapins start to be executed, you can have problems with another installations or the configuration can be disrupted by needed reboots. You know your systems and must take the cautions needed.