How to invoke SharePoint powershell from BigFix

Hi,
I’ve a client requirement with Server Automation wherein after patching SharePoint servers, we need to execute few lines of commands in SharePoint shell.
Is there a way to execute commands in SharePoint shell through BigFix ?
I tried from Powershell but it doesn’t work ( JGSTEW’s method at https://bigfix.me/fixlet/details/3860 )

Hey there @hemantgaikwad10,

I would suggest you start your deeper troubleshooting with one of these threads:

If those don’t help, can you share more about what part of invoking your powershell with BigFix is not working?
Any error codes, BigFix client logs, screenshots?
Can you share the details about the powershell script itself?

1 Like

Hi there, thanks for the response
I’m trying to execute the following command from Bigfix.
It adds SharePoint snapin if not added already and then I invoke PSCONFIG.exe with a service account.
I’ve tried it thrice and the action failed.
In one action I skipped the powershell part and just executed the PSCONFIG.exe command, which completed with exit code 1.
We executed the command manually on the Sharepoint server in command prompt and it works well.

override wait
hidden=true
completion=job
user=DOMAIN\USERNAME
password=required
// Disable wow64 redirection on x64 OSes
action uses wow64 redirection
delete __createfile
// CREATEFILE
createfile until END_OF_FILE
// Script Code
if((Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null)
{​​​​​​​​{​​​​​​​​
Add-PsSnapin Microsoft.SharePoint.PowerShell
}​​​​​​​​
get-help | Out-File "{​​​​​​​​(pathname of folder “__BESData__Global\Logs” of parent folder of client)}​​​​​​​​\config_powershell.log"
END_OF_FILE
delete powershell.ps1
move __createfile powershell.ps1

wait {​​​​​​​​ 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 powershell.ps1

wait cmd.exe /c “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\bin” psconfig.exe -cmd upgrade -inplace b2b -force -cmd applicationcontent -install -cmd installfeatures

You aren’t actually disabling 32-bit redirection due to a syntax issue.
action uses wow64 redirection
Should be
action uses wow64 redirection false

See if that helps

3 Likes

It may be issue in posting action script, but the script you have posted contains several problems.

  1. Override is not a declaration, but an action script command. “override wait” ends with “wait.” From syntax point of view, lines from action uses wow64 redirection to move are invalid parameters to override.
  2. Add-PsSnapin adds snapin to current powershell session only. In your case, when .ps1 exits, the effect of Add-PsSnapin is gone. I think you need to run psconfig.exe in the .ps1 file if psconfig.exe requires share point snappin.
    Note: Without asadmin=true, the override command executes the command in the context of specified user, but with limited token (without admin privileges).

Thank you all for your suggestions. I was able to resolve the issue with the following-
override wait
hidden = false
completion = job
RunAs = localuser
user = DOMAIN\USER
password = required
wait cmd.exe /c “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\bin\psconfig.exe” -cmd upgrade -inplace b2b -force -cmd applicationcontent -install -cmd installfeatures

I skipped the Powershell part since that was a one time thing and user had already added the snapin.

3 Likes

Thanks for posting the solution that finally worked for you. Other users and lurkers will appreciate that in the future…