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

Powershell-Snapin

Scheduled Pinned Locked Moved Solved
FOG Problems
4
6
2.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.
  • T
    Tywyn
    last edited by Tywyn Jul 24, 2017, 3:54 AM Jul 24, 2017, 9:47 AM

    Server
    • FOG Version: 1.4.4
    • OS: debian 9.0.0
    Client
    • Service Version:
    • OS: Windows 7 32bit
    Description

    Hi everybody,

    wrote a powershell snapin which adds a user, sets the workgroup of the client, activated windows license and so on.
    Some questions:

    • I start it with -ExecutionPolicy Bypass -NoProfile -File
      Is there any chance to capture the output of the powershell-Skript and redirect it to a file?
      Tried to add > c:\ps_out.txt which does not work.
    • I created a group, where I added 2 clients. I started the snapin on the group and client1 ran the powershell-commands and client2 did not start to do so. In the Task-Management I still see both clients: client1 says In-Progress (although done and already rebooted) and client2 says Queued, but does nothing (Think I found out why … not it the correct network to find the fog-server).
      Why is client1 still listed in the Active Task-Overview? Is it possibly so, because after the script is run, the client cannot find the fog-server, because it is in a different network with new IP-Adress?

    Thanks for your help
    Rainer

    1 Reply Last reply Reply Quote 0
    • T
      Tom Elliott
      last edited by Jul 24, 2017, 11:35 AM

      I don’t know what the script looks like, but it’s fully possible there’s another problem causing the script not to write to the file as you’re intending, for example it doesn’t make it to the point where you have the log file being written?

      Typically I like to do a script in lines of:

      1. Define the variables.
      2. Write to log stating we’re about to start the work.
      3. Do the work, redirecting output from the running command to go into the log (both errors and standard)
      4. Write to log state we’re complete with doing the work.
      5. End the script as needed.

      I’d have to see the script to help you a little more, but I don’t think FOG is failing to run the script (as this isn’t what we typically see when people post such threads.) Rather the script IS running, but the expected actions aren’t done in the manner that the Client expects them to be done, such as something waiting for user interaction.

      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

      1 Reply Last reply Reply Quote 1
      • T
        Tywyn
        last edited by Tywyn Jul 24, 2017, 5:43 AM Jul 24, 2017, 11:41 AM

        The script runs and it does what it shall do.
        The only thing is, that I would like to have the output (which is generated by Write-Output statements) redirected to a file.
        When you execute a script from the commandline I usually did a .\myscript.ps1 > C:\somelogfile.txt which worksgood.

        I was wondering, whether this can be done also with the script that runs as a snapin.

        Thanx
        Rainer

        EDIT: The issue, why on client2 the script was not running is solved. client2 was in another network an thus not reachable from the fog server.

        1 Reply Last reply Reply Quote 0
        • S
          Sebastian Roth Moderator
          last edited by Jul 24, 2017, 12:45 PM

          @Tywyn Probably just wrap another script around yours that does the call .\myscript.ps1 > C:\somelogfile.txt… Though I am not a windows guy but this might work.

          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

          T 1 Reply Last reply Jul 25, 2017, 7:59 AM Reply Quote 0
          • T
            Tywyn @Sebastian Roth
            last edited by Jul 25, 2017, 7:59 AM

            @Sebastian-Roth said in Powershell-Snapin:

            @Tywyn Probably just wrap another script around yours that does the call .\myscript.ps1 > C:\somelogfile.txt… Though I am not a windows guy but this might work.

            Will try. Thanx!

            1 Reply Last reply Reply Quote 0
            • J
              Jim Graczyk
              last edited by Jul 25, 2017, 2:19 PM

              Tom has a good point here. I’ve struggled with launching powershell from the FOG Service with the correct privilege level to prevent UAC pop ups you never see. Disabling UAC on a PC and retrying the snapin will can be a good testing step. Windows 7 and Windows 10 treat UAC differently, or so it seems. To get around UAC in Win7. Seach for elevate.cmd and elevate.vbs that came out with Server 2008/Vista. I’ve found that this can successfully elevate a PS script in Win7. I’m still working on Win10.

              if you’re actually getting powershell to start your script, you can also pipe the output to a file using the out-file cmdlet:

              powershell.exe -Executionpolicy Bypass -noprofile -file myscript.ps1 | out-file full [full path to some text file]

              Jim

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

              154

              Online

              12.1k

              Users

              17.3k

              Topics

              155.3k

              Posts
              Copyright © 2012-2024 FOG Project