79645002

Date: 2025-05-30 06:42:35
Score: 1
Natty:
Report link

Thanks for your responses. I modified the code to specify powershell7 and got the correct output.

def get_powershell_table(command):
    """Executes a PowerShell command and returns the formatted table output as a string."""
    try:
        result = subprocess.run(
            [r"C:\Program Files\PowerShell\7\pwsh.exe", "-Command", command],
            capture_output=True,
            text=True,
            check=True,
        )
        return result.stdout
    except subprocess.CalledProcessError as e:
        print(f"Error executing PowerShell command: {e}")
        return None
Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: zhao bin