UNSOLVED Trouble executing PowerShell script through Fog
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.
Avaryan 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
Wayne Workman last edited by Wayne Workman
@oasis All snapins run on windows as the
SYSTEMuser, and all snapins run on Linux as the
rootuser. If your script runs manually but not through FOG, this generally means your script has issues running as