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

    Trouble executing PowerShell script through Fog

    Scheduled Pinned Locked Moved Unsolved
    Windows Problems
    3
    4
    1.5k
    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.
    • O
      Oasis
      last edited by

      Hi all,

      We are running Fog version 1.4.4. Not sure if this is the right forum, but I am currently having trouble getting a PowerShell script to run on a Windows 10 machine through Fog. Here is the script, it’s something I want to run after Fog images the machine as it gets rid of packages we don’t want our users having access to (these packages are installed automatically after sysprep).

      Get-AppxPackage windowsalarms | Remove-AppxPackage
      Get-AppxPackage windowscommunicationsapps | Remove-AppxPackage
      Get-AppxPackage officehub | Remove-AppxPackage
      Get-AppxPackage skypeapp | Remove-AppxPackage
      Get-AppxPackage solitairecollection | Remove-AppxPackage
      Get-AppxPackage zunevideo | Remove-AppxPackage
      Get-AppxPackage onenote | Remove-AppxPackage
      Get-AppxPackage soundrecorder | Remove-AppxPackage
      Get-AppxPackage bingweather | Remove-AppxPackage
      Get-AppxPackage Microsoft.XboxApp | Remove-AppxPackage
      Get-AppxPackage zunemusic | Remove-AppxPackage
      Get-AppxPackage people | Remove-AppxPackage

      The snapin command is:

      powershell.exe -ExecutionPolicy Bypass -NoProfile -File Windows10Uninstall.ps1

      If I send the ps1 file to PowerShell locally on the client, it runs fine, but when I run it through Fog nothing happens… I get the message through the fog client that it runs, but still nothing. I added “>> C:\log.txt” to all of the commands in the ps1 file and it just creates an empty file.

      Any help would be appreciated, thanks.

      Wayne WorkmanW AvaryanA 2 Replies Last reply Reply Quote 0
      • Wayne WorkmanW
        Wayne Workman @Oasis
        last edited by Wayne Workman

        @oasis All snapins run on windows as the SYSTEM user, and all snapins run on Linux as the root user. If your script runs manually but not through FOG, this generally means your script has issues running as SYSTEM.

        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
        • AvaryanA
          Avaryan @Oasis
          last edited by Avaryan

          @Oasis So, just from experience, this probably isn’t going to work the way you want to.

          Get-AppxPackage will only return AppxPackages that the user running the command has (SYSTEM). It will also only be removing them from the SYSTEM profile… which won’t really do anything.

          You’ll want to add the AllUsers flag.

          Get-AppxPackage -AllUsers | Where-Object -Property Name -Match <packagename> | Remove-AppxPackage
          

          Or maybe this might work?

          Get-AppxPackage -AllUsers | Where-Object -Property Name -Match <packagename> | Remove-AppxPackage -AllUsers
          
          1 Reply Last reply Reply Quote 1
          • O
            Oasis
            last edited by

            Thanks @Avaryan and @Wayne-Workman. What you’ve mentioned about Fog running scripts as the System user and it not running for all users is correct. I’m going to have to go about what I wanted to do a different way but there was no issue with Fog or anything, thanks again.

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

            233

            Online

            12.0k

            Users

            17.3k

            Topics

            155.2k

            Posts
            Copyright © 2012-2024 FOG Project