I am have an issue executing a ps1 script on our 2012 endpoints. The script (written by BigFix actionscript) runs on the local machine without issue. I have pulled out all the stops I know of, including wow64 redirect (thinking 64 bit Powershell was required) and push-location thinking it was the system working directory. Here is the BigFix action:
action uses wow64 redirection true
delete __appendfile
dos del /q /f C:\Windows\Temp\script.ps1
appendfile push-location -path "C:\Windows\Temp"
appendfile $Server = hostname
appendfile $Target = New-WBBackupTarget -Volume (Get-Wbvolume -allvolumes | Where-Object {{$_.Volumelabel -eq "Backup"})
appendfile $VirtualMachines = Get-WBVirtualMachine
appendfile $DailyVMWB = New-WBPolicy
appendfile $schedule = [datetime]"02:30:00"
appendfile Set-WBPerformanceConfiguration -OverallPerformanceSetting AlwaysIncremental
appendfile Set-WBSchedule -Policy $DailyVMWB -Schedule $schedule
appendfile Add-WBBackupTarget -Policy $DailyVMWB -Target $Target -Force
appendfile Add-WBVirtualMachine -Policy $DailyVMWB -VirtualMachine $VirtualMachines
appendfile Set-WBVssBackupOptions -Policy $DailyVMWB -VssFullBackup
appendfile Set-WBPolicy -Policy $DailyVMWB -AllowDeleteOldBackups -Force
appendfile Start-WBBackup -Policy $DailyVMWB -AllowDeleteOldBackups -Force
copy __appendfile "C:\Windows\Temp\script.ps1"
waithidden {pathname of file ((it as string) of value "Path" of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" of native registry)} -ExecutionPolicy Bypass -File "C:\Windows\Temp\script.ps1"
dos del /q /f C:\Windows\Temp\script.ps1
If I stop the delete, I can execute the script at C:\Windows\Temp\script.ps1 using cmd with C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File “C:\Windows\Temp\script.ps1”
or execute it directly from x64 Powershell. x32 Powershell results in missing cmdlet errors.
The action in BigFix, of course reads successful because I have not defined success relevance yet, but all commands execute without issue.
I will try executing as system on the local machine with psexec, but does anything standout?