i have a powershell which i tried to exeucte from bigfix action script when i exueute it from the local server to check the cluster resources i can see the output generated but when i execute it from bigfix action script it does not
Remove-Item –path "C:\temp\output.txt"
$modulePath = "C:\Windows\system32\WindowsPowerShell\v1.0\Modules\FailoverClusters\FailoverClusters.psd1"
Import-Module -Name $modulePath -Force
try{
$output = Get-ClusterResource | Where-Object {$_.ResourceType -like "Physical Disk"} | Get-ClusterParameter
if ($output) {
$output | Out-File -FilePath "C:\temp\output.txt" -Append
Write-Output "Command executed successfully." | Out-File -Filepath "C:\temp\output.txt" -Append
} else {
Write-Output "No output or blank output." | Out-File -FilePath "C:\temp\output.txt" -Append
}
}
catch {
$errorMessage = "An error occurred: $($_.Exception.Message)"
Write-Host $errorMessage
Write-Output "This is catch part " | Out-File -FilePath "C:\temp\output.txt" -Append
$errorMessage | Out-File -FilePath "C:\temp\output.txt" -Append
}
from local system output.txt
bject Name Value Type
------ ---- ----- ----
Cluster Disk 1 DiskIdType 1 UInt32
Cluster Disk 1 DiskSignature 0x0 UInt32
Cluster Disk 1 DiskIdGuid {4fc1c83d-265c-4f57-a8ef-35300450f20a} String
Cluster Disk 1 DiskRunChkDsk 0 UInt32
Cluster Disk 1 DiskUniqueIds {16, 0, 0, 0...} ByteArray
Cluster Disk 1 DiskVolumeInfo {1, 0, 0, 0...} ByteArray
Cluster Disk 1 DiskArbInterval 3 UInt32
Cluster Disk 1 DiskPath String
Cluster Disk 1 DiskReload 0 UInt32
Cluster Disk 1 MaintenanceMode 0 UInt32
Cluster Disk 1 CsvEnforceWriteThrough 0 UInt32
Cluster Disk 1 EnableBlockCache 1 UInt32
Cluster Disk 1 SnapshotDiffSize 0 UInt32
Cluster Disk 1 DiskRecoveryAction 0
=================================================================
from bigfix console action script
// Enter your action script here
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:\temp\powershell.ps1"
c:\temp\output.txt
This is catch part
An error occurred: The term 'Get-ClusterResource' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.