We have a script we run through BigFix to check for product readiness. The script is zipped with a set of functions and it calls out each function, stores the data, then writes all the results to an HTML file. The zip file gets copied to the server and then we use a BigFix action script to run Powershell.exe with execution policy set to bypass.
We are having an issue with one of the functions, only when running it through BigFix. I have tried running our scripts through Powershell as me and as SYSTEM and it doesnât matter. If I run it manually everything runs fine. If I run it through BigFix it fails, I think on get-wmiobject. Iâm wondering if this is a known issue with security settings or something?
This is the function we are having issues with. I originally tried with get-wmiobject and I have tried get-ciminstance. We changed to gmwi since the other function works like that but this one still fails. It gives me an output of FUBAR. If I run the script manually after BigFix copies it to the machine and unzips it then it says VMWare Tools is installed.
function Get-VirtGuestTool {
$scriptName = '150-VirtGuestTool.ps1'
$checkName = 'VirtGuestTool'
$checkDescription = 'Test if virtual guest software is installed'
$checkState = ''
$data = ''
$elapsed = [System.Diagnostics.Stopwatch]::StartNew()
try
{
$computerProperties = gmwi win32_computersystem
$InstalledSoftware = Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
$softwareTable = @()
foreach ($obj in $InstalledSoftware) {
$data = New-Object PSObject
$data | Add-Member -Type NoteProperty -Name "Name" -Value $obj.GetValue('DisplayName')
$data | Add-Member -Type NoteProperty -Name "Version" -Value $obj.GetValue('DisplayVersion')
$softwareTable += $data
}
# $Endpoint = ""
# $Tools2 = ""
# $Tools3 = ""
If ($computerProperties.Manufacturer -eq "Nutanix" -or $computerProperties.Manufacturer -like "*VMware, Inc.*") {
if ($softwareTable.Name -like "*Nutanix*" -and $softwareTable.Name -like "*Nutanix Guest Tools*" -and $softwareTable.Name -like "*Nutanix VM Mobility*") {
$OK = "1"
$Reason = "Found Nutanix software required to pass PRV in the list of installed software!!"
}
elseif ($softwareTable.Name -like "*VMware*") {
$OK = "1"
$Reason = "VMWare Tools is installed"}
}
ElseIf ($computerProperties.Manufacturer -like "*Microsoft*" -and $computerProperties.Model -like "*Virtual*") {
$Tools = 'NA - Azure'
$OK = "1"
$Reason = $Tools
}
ElseIf ($computerProperties.Manufacturer -ne "Nutanix" -and $computerProperties.Manufacturer -notlike "*VMware, Inc.*" -and $computerProperties.Manufacturer -notlike "*Microsoft*") {
$Tools = 'NA - Physical'
Write-Output "Server is physical. No tools required"
$OK = "1"
$Reason = $Tools
}
Else {
$Tools = 'Not Installed'
$OK = "0"
$Reason = "Guest tools need to be installed on server"
}
}
Catch {
$OK = "0"
$Reason = "FUBAR"
}
Write-Output "[$(Get-Date -UFormat %I:%M:%S)] Generating Windows Virt Guest Tools Report"
Add-RequiredCheckListItem 'VirtGuestTool' $ok $reason
}
This is the function that works. I put % instead of the account here but that doesnât matter.
function Get-LocalAdmin {
$scriptName = '160-.ps1'
$checkName = 'LocalAdmin'
$checkDescription = 'Verifies non-domain joined servers have the % account and it is not the default SID.'
$checkState = ''
$data = ''
$elapsed = [System.Diagnostics.Stopwatch]::StartNew()
if ((gwmi win32_computersystem).partofdomain -eq $true)
{
$OK = "1"
$Reason = "Server is domain joined. % is not required."
}
Elseif ((gwmi win32_computersystem).partofdomain -eq $false)
{
#% is default SID
If (Get-LocalUser | Where {($_.name -eq '%%') -AND ($_.SID -like "S-1-5-21*500")})
{
$OK = "0"
$Reason = "The % account is using the default SID"
}
#% is default SID
ElseIf (Get-LocalUser | Where {($_.name -eq '%%') -AND ($_.SID -notlike "S-1-5-21*500")})
{
$OK = "1"
$Reason = "% account exist and is not using the default SID"
}
Else
{
$OK = "0"
$Reason = "% account is not configured on a non-domain joined server"
}
}
Write-Output "[$(Get-Date -UFormat %I:%M:%S)] Generating Windows Local Admin Account Report"
#Function defined in lib\add-requiredchecklistitem.ps1
Add-RequiredCheckListItem "LocalAdmin" $ok $reason