PowerShell Exec MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@PowerShell Exec MCP Server generate an Intune detection script for checking if a specific Windows update is installed"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
PowerShell Exec MCP Server
A secure Model Context Protocol (MCP) server that provides controlled PowerShell command execution capabilities through MCP tools. This server includes security features to prevent dangerous commands, provides timeouts for command execution, and specializes in enterprise script generation for Microsoft Intune and IBM BigFix management platforms.
Features
Secure PowerShell command execution
JSON-formatted output for structured data
System information retrieval
Service management and monitoring
Process monitoring and analysis
Event log access
PowerShell script generation
Template-based script generation
Dynamic script generation
Microsoft Intune detection and remediation script generation
IBM BigFix relevance and action script generation
Command timeout support
Blocking of dangerous commands
Non-interactive and profile-less execution
Async support
Type hints and input validation
Project Structure
mcp-powershell-exec/
├── mcp_powershell_exec/ # Main package directory
│ ├── __init__.py # Package initialization
│ ├── __main__.py # Entry point
│ ├── server.py # Server implementation
│ ├── templates/ # PowerShell script templates
│ │ ├── basic_script.ps1 # Basic script template
│ │ ├── system_inventory.ps1 # System inventory template
│ │ ├── intune_detection.ps1 # Intune detection script template
│ │ ├── intune_remediation.ps1 # Intune remediation script template
│ │ ├── bigfix_relevance.ps1 # BigFix relevance script template
│ │ └── bigfix_action.ps1 # BigFix action script template
│ └── py.typed # Type hints marker
├── pyproject.toml # Project metadata and dependencies
├── setup.py # Package installation
└── README.md # DocumentationInstallation
Installing via Smithery
To install PowerShell Exec Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @DynamicEndpoints/powershell-exec-mcp-server --client claudeManual Installation
Ensure you have Python 3.7+ installed
Install the package:
pip install .Or install in development mode:
pip install -e .Usage
Running the Server
You can run the server in several ways:
Using the MCP CLI:
mcp run mcp_powershell_execUsing Python module:
python -m mcp_powershell_execUsing the console script:
mcp-powershell-execFor development and testing:
mcp dev mcp_powershell_execInstalling in Claude Desktop
To install the server in Claude Desktop:
mcp install mcp_powershell_execAvailable Tools
run_powershell
The base tool for executing PowerShell commands securely with timeout support.
Parameters:
code(required): PowerShell code to executetimeout(optional): Command timeout in seconds (1-300, default 60)
Example:
result = await run_powershell(
code="Get-Process | Select-Object Name, Id, CPU",
timeout=30
)get_system_info
Retrieve system information using Get-ComputerInfo cmdlet.
Parameters:
properties(optional): List of ComputerInfo properties to retrievetimeout(optional): Command timeout in seconds (1-300, default 60)
Example:
result = await get_system_info(
properties=["OsName", "OsVersion", "OsArchitecture"]
)get_running_services
Get information about Windows services.
Parameters:
name(optional): Filter services by name (supports wildcards)status(optional): Filter by status (Running, Stopped, etc.)timeout(optional): Command timeout in seconds (1-300, default 60)
Example:
result = await get_running_services(
name="*sql*",
status="Running"
)get_processes
Monitor running processes with filtering and sorting capabilities.
Parameters:
name(optional): Filter processes by name (supports wildcards)top(optional): Limit to top N processessort_by(optional): Property to sort by (e.g., CPU, WorkingSet)timeout(optional): Command timeout in seconds (1-300, default 60)
Example:
result = await get_processes(
top=5,
sort_by="CPU"
)get_event_logs
Access Windows event logs with filtering capabilities.
Parameters:
logname(required): Name of the event log (System, Application, Security, etc.)newest(optional): Number of most recent events to retrieve (default 10)level(optional): Filter by event level (1: Critical, 2: Error, 3: Warning, 4: Information)timeout(optional): Command timeout in seconds (1-300, default 60)
Example:
result = await get_event_logs(
logname="System",
newest=5,
level=2 # Error events only
)generate_script_from_template
Generate PowerShell scripts using predefined templates.
Parameters:
template_name(required): Name of the template to use (without .ps1 extension)parameters(required): Dictionary of parameters to replace in the templateoutput_path(optional): Where to save the generated scripttimeout(optional): Command timeout in seconds (1-300, default 60)
Example:
result = await generate_script_from_template(
template_name="basic_script",
parameters={
"SYNOPSIS": "My Test Script",
"DESCRIPTION": "A test script generated from template",
"PARAM1_DESCRIPTION": "First parameter",
"PARAM2_DESCRIPTION": "Second parameter",
"PARAM1_MANDATORY": "true",
"PARAM2_MANDATORY": "false",
"PARAM1_DEFAULT": "",
"PARAM2_DEFAULT": "default_value",
"MAIN_CODE": "Write-Host 'Hello World!'"
},
output_path="test_script.ps1"
)generate_custom_script
Generate custom PowerShell scripts based on description.
Parameters:
description(required): Natural language description of what the script should doscript_type(required): Type of script to generate (file_ops, service_mgmt, etc.)parameters(optional): List of parameters the script should acceptinclude_logging(optional): Whether to include logging functions (default: true)include_error_handling(optional): Whether to include error handling (default: true)output_path(optional): Where to save the generated scripttimeout(optional): Command timeout in seconds (1-300, default 60)
Example:
result = await generate_custom_script(
description="Script to monitor CPU usage and log high utilization",
script_type="monitoring",
parameters=[
{
"name": "ThresholdPercent",
"type": "int",
"mandatory": "true",
"default": "90"
},
{
"name": "LogPath",
"type": "string",
"mandatory": "false",
"default": "cpu_usage.log"
}
],
output_path="monitor_cpu.ps1"
)generate_intune_detection_script
Generate Intune detection scripts with proper exit codes and logging.
Parameters:
description(required): What the script should detectdetection_logic(required): PowerShell code that performs the detectionoutput_path(optional): Where to save the scripttimeout(optional): Command timeout in seconds (1-300, default 60)
Example:
result = await generate_intune_detection_script(
description="Check if Chrome is installed with correct version",
detection_logic="""
$app = Get-ItemProperty HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe
$version = (Get-Item $app.Path).VersionInfo.FileVersion
$compliant = [version]$version -ge [version]"100.0.0.0"
Complete-Detection -Compliant $compliant -Message "Chrome version: $version"
""",
output_path="detect_chrome.ps1"
)generate_intune_remediation_script
Generate Intune remediation scripts with system restore points and error handling.
Parameters:
description(required): What the script should remediateremediation_logic(required): PowerShell code that performs the remediationoutput_path(optional): Where to save the scripttimeout(optional): Command timeout in seconds (1-300, default 60)
Example:
result = await generate_intune_remediation_script(
description="Install or update Chrome browser",
remediation_logic="""
$installer = "C:\\Windows\\Temp\\ChromeSetup.exe"
Invoke-WebRequest -Uri "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile $installer
Start-Process -FilePath $installer -Args "/silent /install" -Wait
Remove-Item $installer
Complete-Remediation -Success $true -Message "Chrome installation completed"
""",
output_path="remedy_chrome.ps1"
)generate_intune_script_pair
Generate both detection and remediation scripts as a matched pair.
Parameters:
description(required): What the scripts should detect and remediatedetection_logic(required): PowerShell code that performs the detectionremediation_logic(required): PowerShell code that performs the remediationoutput_dir(optional): Directory to save the scriptstimeout(optional): Command timeout in seconds (1-300, default 60)
Example Usage:
Software Installation Check:
result = await generate_intune_script_pair(
description="Manage Chrome browser installation and version",
detection_logic="""
$app = Get-ItemProperty HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe
$version = (Get-Item $app.Path).VersionInfo.FileVersion
$compliant = [version]$version -ge [version]"100.0.0.0"
Complete-Detection -Compliant $compliant -Message "Chrome version: $version"
""",
remediation_logic="""
$installer = "C:\\Windows\\Temp\\ChromeSetup.exe"
Invoke-WebRequest -Uri "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile $installer
Start-Process -FilePath $installer -Args "/silent /install" -Wait
Remove-Item $installer
Complete-Remediation -Success $true -Message "Chrome installation completed"
""",
output_dir="chrome_scripts"
)BitLocker Encryption:
result = await generate_intune_script_pair(
description="Check and enable BitLocker encryption on system drive",
detection_logic="""
$systemDrive = $env:SystemDrive
$bitlockerVolume = Get-BitLockerVolume -MountPoint $systemDrive
$compliant = $bitlockerVolume.ProtectionStatus -eq 'On'
Complete-Detection -Compliant $compliant -Message "BitLocker status: $($bitlockerVolume.ProtectionStatus)"
""",
remediation_logic="""
$systemDrive = $env:SystemDrive
Enable-BitLocker -MountPoint $systemDrive -TpmProtector -UsedSpaceOnly
Backup-BitLockerKeyProtector -MountPoint $systemDrive -KeyProtectorId $bitlockerVolume.KeyProtector[0].KeyProtectorId
Complete-Remediation -Success $true -Message "BitLocker enabled with TPM protection"
""",
output_dir="bitlocker_scripts"
)Windows Update Configuration:
result = await generate_intune_script_pair(
description="Check and configure Windows Update settings",
detection_logic="""
$wu = New-Object -ComObject Microsoft.Update.AutoUpdate
$settings = $wu.Settings
$compliant = ($settings.NotificationLevel -eq 4) -and ($settings.NoAutoRebootWithLoggedOnUsers -eq $true)
Complete-Detection -Compliant $compliant -Message "Windows Update settings status"
""",
remediation_logic="""
$wu = New-Object -ComObject Microsoft.Update.AutoUpdate
$settings = $wu.Settings
$settings.NotificationLevel = 4
$settings.NoAutoRebootWithLoggedOnUsers = $true
$settings.Save()
Complete-Remediation -Success $true -Message "Windows Update settings configured"
""",
output_dir="windows_update_scripts"
)Security Settings:
result = await generate_intune_script_pair(
description="Check and configure basic Windows security settings",
detection_logic="""
$firewall = Get-NetFirewallProfile
$uac = (Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System).EnableLUA
$screenSaver = (Get-ItemProperty 'HKCU:\\Control Panel\\Desktop').ScreenSaveActive
$compliant = ($firewall.Enabled -contains $true) -and ($uac -eq 1) -and ($screenSaver -eq 1)
Complete-Detection -Compliant $compliant -Message "Security settings status"
""",
remediation_logic="""
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True
Set-ItemProperty -Path HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System -Name EnableLUA -Value 1
Set-ItemProperty -Path 'HKCU:\\Control Panel\\Desktop' -Name ScreenSaveActive -Value 1
Complete-Remediation -Success $true -Message "Security settings configured"
""",
output_dir="security_scripts"
)BigFix Script Generation Tools
generate_bigfix_relevance_script
Generate BigFix relevance scripts to determine if computers need action.
Parameters:
description(required): What the script should checkrelevance_logic(required): PowerShell code that determines relevanceoutput_path(optional): Where to save the scripttimeout(optional): Command timeout in seconds (1-300, default 60)
Example:
result = await generate_bigfix_relevance_script(
description="Check if Chrome needs updating to version 100.0.0.0",
relevance_logic="""
try {
$app = Get-ItemProperty "HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe" -ErrorAction Stop
$version = (Get-Item $app.'(Default)').VersionInfo.FileVersion
$needsUpdate = [version]$version -lt [version]"100.0.0.0"
Complete-Relevance -Relevant $needsUpdate -Message "Chrome version: $version (Target: 100.0.0.0+)"
} catch {
Complete-Relevance -Relevant $true -Message "Chrome not found - installation needed"
}
""",
output_path="chrome_relevance.ps1"
)generate_bigfix_action_script
Generate BigFix action scripts to perform remediation or configuration changes.
Parameters:
description(required): What the script should accomplishaction_logic(required): PowerShell code that performs the actionoutput_path(optional): Where to save the scripttimeout(optional): Command timeout in seconds (1-300, default 60)
Example:
result = await generate_bigfix_action_script(
description="Install Chrome browser to latest version",
action_logic="""
try {
$installer = "$env:TEMP\\ChromeSetup.exe"
Write-BigFixLog "Downloading Chrome installer..."
Invoke-WebRequest -Uri "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile $installer -UseBasicParsing
Write-BigFixLog "Installing Chrome silently..."
Start-Process -FilePath $installer -Args "/silent /install" -Wait
Remove-Item $installer -Force
Complete-Action -Result "Success" -Message "Chrome installation completed successfully"
} catch {
Complete-Action -Result "RetryableFailure" -Message "Chrome installation failed: $($_.Exception.Message)"
}
""",
output_path="chrome_action.ps1"
)generate_bigfix_script_pair
Generate both relevance and action scripts as a matched pair for BigFix fixlet deployment.
Parameters:
description(required): What the scripts should accomplishrelevance_logic(required): PowerShell code that determines relevanceaction_logic(required): PowerShell code that performs the actionoutput_dir(optional): Directory to save the scriptstimeout(optional): Command timeout in seconds (1-300, default 60)
Example Usage:
Chrome Browser Management:
result = await generate_bigfix_script_pair(
description="Manage Chrome browser installation with version 100.0.0.0 or higher",
relevance_logic="""
try {
$app = Get-ItemProperty "HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe" -ErrorAction Stop
$version = (Get-Item $app.'(Default)').VersionInfo.FileVersion
$needsAction = [version]$version -lt [version]"100.0.0.0"
Complete-Relevance -Relevant $needsAction -Message "Chrome version: $version (Target: 100.0.0.0+)"
} catch {
Complete-Relevance -Relevant $true -Message "Chrome not found - installation needed"
}
""",
action_logic="""
try {
$installer = "$env:TEMP\\ChromeSetup.exe"
Write-BigFixLog "Downloading Chrome installer..."
Invoke-WebRequest -Uri "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile $installer -UseBasicParsing
Write-BigFixLog "Installing Chrome silently..."
Start-Process -FilePath $installer -Args "/silent /install" -Wait
Remove-Item $installer -Force
Complete-Action -Result "Success" -Message "Chrome installation completed successfully"
} catch {
Complete-Action -Result "RetryableFailure" -Message "Chrome installation failed: $($_.Exception.Message)"
}
""",
output_dir="chrome_bigfix_scripts"
)Windows Update Configuration:
result = await generate_bigfix_script_pair(
description="Ensure Windows Update service is running and configured properly",
relevance_logic="""
$service = Get-Service -Name "wuauserv" -ErrorAction SilentlyContinue
$needsAction = ($service.Status -ne "Running") -or ($service.StartType -ne "Automatic")
Complete-Relevance -Relevant $needsAction -Message "Windows Update service status: $($service.Status), StartType: $($service.StartType)"
""",
action_logic="""
try {
Set-Service -Name "wuauserv" -StartupType Automatic
Start-Service -Name "wuauserv"
Complete-Action -Result "Success" -Message "Windows Update service configured and started"
} catch {
Complete-Action -Result "RetryableFailure" -Message "Failed to configure Windows Update service: $($_.Exception.Message)"
}
""",
output_dir="windows_update_bigfix_scripts"
)Security Settings Configuration:
result = await generate_bigfix_script_pair(
description="Ensure basic Windows security settings are properly configured",
relevance_logic="""
$firewall = Get-NetFirewallProfile
$uac = (Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System).EnableLUA
$firewallOk = ($firewall | Where-Object { $_.Enabled -eq $false }).Count -eq 0
$needsAction = (-not $firewallOk) -or ($uac -ne 1)
Complete-Relevance -Relevant $needsAction -Message "Security settings check - Firewall OK: $firewallOk, UAC Enabled: $($uac -eq 1)"
""",
action_logic="""
try {
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True
Set-ItemProperty -Path HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System -Name EnableLUA -Value 1
Complete-Action -Result "Success" -Message "Security settings configured successfully"
} catch {
Complete-Action -Result "RetryableFailure" -Message "Failed to configure security settings: $($_.Exception.Message)"
}
""",
output_dir="security_bigfix_scripts"
)Security Features
The server implements several security measures:
Blocks dangerous commands like:
Recursive deletions
Drive formatting
System shutdown/restart
Service manipulation
User account manipulation
Dynamic code execution
Command timeout enforcement
Non-interactive mode to prevent hangs
No profile loading to ensure clean execution environment
JSON output formatting for consistent data structures
Input validation for all tool parameters
Development
The project uses modern Python packaging tools and includes full type hints support. To set up a development environment:
Clone the repository
Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activateInstall development dependencies:
pip install -e .Contributing
Contributions are welcome! Please ensure any changes maintain the security standards of the server.
License
MIT License
Available Tools
14 toolsensure_directoryBInspect
Ensure directory exists and return absolute path.
Inputs: path (required). Returns: result
generate_bigfix_action_scriptAInspect
Generate a BigFix action script to perform remediation or configuration changes.
Creates a PowerShell action script that follows IBM BigFix best practices:
- Proper exit codes (0=success, 1=retryable failure, 2=non-retryable failure)
- BigFix client log integration for monitoring
- System restore point creation before changes
- Comprehensive error handling and logging
- Event log integration for troubleshooting
⚠️ IMPORTANT: For complete BigFix deployments, you need BOTH relevance and action scripts.
Consider using 'generate_bigfix_script_pair' instead to create both scripts together.
IBM BigFix References:
- Action Scripts: https://help.hcltechsw.com/bigfix/11.0/platform/Platform/Console/c_creating_action_scripts.html
- Exit Codes: https://help.hcltechsw.com/bigfix/11.0/platform/Platform/Console/c_action_script_exit_codes.html
- Best Practices: https://help.hcltechsw.com/bigfix/11.0/platform/Platform/Console/c_best_practices_for_creating_fixlets.html
- Client Logging: https://help.hcltechsw.com/bigfix/11.0/platform/Platform/Installation/c_bes_client_logging.html
Args:
description: Clear description of what the script should accomplish (e.g., 'Install Chrome browser', 'Configure Windows firewall')
action_logic: PowerShell code that performs the action. Use 'Complete-Action -Result "Success/RetryableFailure/NonRetryableFailure" -Message "details"' to indicate completion
output_path: Optional file path where the script will be saved. If not provided, returns script content
timeout: Command timeout in seconds (1-300, default 60)
Returns:
Generated script content or path where script was saved
Example:
Generate a script to install Chrome:
```
result = await generate_bigfix_action_script(
description="Install Chrome browser to latest version",
action_logic='''
try {
$installer = "$env:TEMP\ChromeSetup.exe"
Write-BigFixLog "Downloading Chrome installer..."
Invoke-WebRequest -Uri "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile $installer -UseBasicParsing
Write-BigFixLog "Installing Chrome silently..."
Start-Process -FilePath $installer -Args "/silent /install" -Wait
Remove-Item $installer -Force
Complete-Action -Result "Success" -Message "Chrome installation completed successfully"
} catch {
Complete-Action -Result "RetryableFailure" -Message "Chrome installation failed: $($_.Exception.Message)"
}
''',
output_path="chrome_action.ps1"
)
```
Tips:
- Always use Complete-Action function to set proper exit codes
- Use "Success" for completed actions
- Use "RetryableFailure" for temporary issues (network, locks, etc.)
- Use "NonRetryableFailure" for permanent issues (unsupported OS, etc.)
- Test action logic in safe environments first
- Consider creating system restore points for major changes
- Use Write-BigFixLog for detailed logging and troubleshooting
- Make actions idempotent (safe to run multiple times)
Inputs: description (required), action_logic (required), output_path, timeout. Returns: result
generate_bigfix_relevance_scriptAInspect
Generate a BigFix relevance script to determine if computers need action.
Creates a PowerShell relevance script that follows IBM BigFix best practices:
- Proper output format (TRUE/FALSE for BigFix consumption)
- BigFix client log integration for monitoring
- Event log integration for troubleshooting
- Comprehensive error handling and logging
- Fast execution optimized for frequent evaluations
💡 TIP: For complete BigFix deployments, you need BOTH relevance and action scripts.
Consider using 'generate_bigfix_script_pair' to create both scripts together with matching logic.
IBM BigFix References:
- Relevance Language Guide: https://help.hcltechsw.com/bigfix/11.0/relevance/Relevance/c_relevance_language.html
- Action Scripts: https://help.hcltechsw.com/bigfix/11.0/platform/Platform/Console/c_creating_action_scripts.html
- Best Practices: https://help.hcltechsw.com/bigfix/11.0/platform/Platform/Console/c_best_practices_for_creating_fixlets.html
- Client Logging: https://help.hcltechsw.com/bigfix/11.0/platform/Platform/Installation/c_bes_client_logging.html
Args:
description: Clear description of what the script should check (e.g., 'Check if Chrome needs updating', 'Verify Windows patches are current')
relevance_logic: PowerShell code that determines relevance. Use 'Complete-Relevance -Relevant $true/$false -Message "status"' to indicate result
output_path: Optional file path where the script will be saved. If not provided, returns script content
timeout: Command timeout in seconds (1-300, default 60)
Returns:
Generated script content or path where script was saved
Example:
Generate a script to check if Chrome needs updating:
```
result = await generate_bigfix_relevance_script(
description="Check if Chrome browser needs updating to version 100.0.0.0 or higher",
relevance_logic=''',
try {
$app = Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" -ErrorAction Stop
$version = (Get-Item $app.'(Default)').VersionInfo.FileVersion
$needsUpdate = [version]$version -lt [version]"100.0.0.0"
Complete-Relevance -Relevant $needsUpdate -Message "Chrome version: $version (Target: 100.0.0.0+)"
} catch {
Complete-Relevance -Relevant $true -Message "Chrome not found or inaccessible - installation needed"
}
''',
output_path="chrome_relevance.ps1"
)
```
Tips:
- Keep relevance logic fast and efficient (evaluated frequently)
- Return TRUE when action is needed, FALSE when compliant
- Always use Complete-Relevance function for proper BigFix output format
- Use try-catch blocks for robust error handling
- Test relevance logic thoroughly across different environments
- Use Write-BigFixLog for detailed progress tracking
Inputs: description (required), relevance_logic (required), output_path, timeout. Returns: result
generate_bigfix_script_pairAInspect
Generate a complete pair of BigFix relevance and action scripts for deployment.
This is the RECOMMENDED tool for BigFix fixlet creation as it creates both required scripts:
- Relevance script: Determines which computers need the action (TRUE/FALSE output)
- Action script: Performs the necessary changes with proper error handling
Both scripts follow IBM BigFix best practices:
- Proper BigFix output formats and exit codes
- BigFix client log integration for centralized monitoring
- System restore points before changes (action only)
- Comprehensive error handling and logging
- Event log integration for troubleshooting
- No user interaction (silent execution required)
IBM BigFix References:
- Fixlet Development: https://help.hcltechsw.com/bigfix/11.0/platform/Platform/Console/c_creating_fixlets.html
- Relevance Language: https://help.hcltechsw.com/bigfix/11.0/relevance/Relevance/c_relevance_language.html
- Action Scripts: https://help.hcltechsw.com/bigfix/11.0/platform/Platform/Console/c_creating_action_scripts.html
- Best Practices: https://help.hcltechsw.com/bigfix/11.0/platform/Platform/Console/c_best_practices_for_creating_fixlets.html
- Testing Guidelines: https://help.hcltechsw.com/bigfix/11.0/platform/Platform/Console/c_testing_fixlets.html
Args:
description: Clear description of what the scripts should accomplish (e.g., 'Manage Chrome browser installation and updates')
relevance_logic: PowerShell code that determines if action is needed. Use 'Complete-Relevance -Relevant $true/$false -Message "status"' to indicate result
action_logic: PowerShell code that performs the remediation. Use 'Complete-Action -Result "Success/RetryableFailure/NonRetryableFailure" -Message "details"' to indicate completion
output_dir: Optional directory to save both scripts. If not provided, returns script content in response
timeout: Command timeout in seconds (1-300, default 60)
Returns:
Dictionary containing both scripts: {"relevance_script": "content/path", "action_script": "content/path"}
Example:
Generate scripts to manage Chrome browser installation:
```
result = await generate_bigfix_script_pair(
description="Manage Chrome browser installation with version 100.0.0.0 or higher",
relevance_logic=''',
try {
$app = Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" -ErrorAction Stop
$version = (Get-Item $app.'(Default)').VersionInfo.FileVersion
$needsAction = [version]$version -lt [version]"100.0.0.0"
Complete-Relevance -Relevant $needsAction -Message "Chrome version: $version (Target: 100.0.0.0+)"
} catch {
Complete-Relevance -Relevant $true -Message "Chrome not found - installation needed"
}
''',
action_logic=''',
try {
$installer = "$env:TEMP\ChromeSetup.exe"
Write-BigFixLog "Downloading Chrome installer..."
Invoke-WebRequest -Uri "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile $installer -UseBasicParsing
Write-BigFixLog "Installing Chrome silently..."
Start-Process -FilePath $installer -Args "/silent /install" -Wait
Remove-Item $installer -Force
Complete-Action -Result "Success" -Message "Chrome installation completed successfully"
} catch {
Complete-Action -Result "RetryableFailure" -Message "Chrome installation failed: $($_.Exception.Message)"
}
''',
output_dir="chrome_bigfix_scripts"
)
```
Tips:
- Always test both scripts in a controlled environment first
- Ensure relevance logic matches the conditions that action script addresses
- Use descriptive logging messages for easier troubleshooting
- Consider the scope and impact of actions (test groups first)
- Make sure relevance logic is efficient (evaluated frequently)
- Ensure action logic is idempotent (safe to run multiple times)
- Use Write-BigFixLog for detailed progress tracking
- Test across different OS versions and configurations
Inputs: description (required), relevance_logic (required), action_logic (required), output_dir, +1 more. Returns: result
generate_custom_scriptBInspect
Generate a custom PowerShell script based on description.
Args:
description: Natural language description of what the script should do
script_type: Type of script to generate (file_ops, service_mgmt, etc.)
parameters: List of parameters the script should accept
include_logging: Whether to include logging functions
include_error_handling: Whether to include error handling
output_path: Where to save the generated script (optional)
timeout: Command timeout in seconds (1-300, default 60)
Returns:
Generated script content or path where script was saved
Inputs: description (required), script_type (required), parameters, include_logging, +3 more. Returns: result
generate_intune_remediation_scriptAInspect
Generate a Microsoft Intune remediation script with enterprise-grade features.
Creates a PowerShell remediation script that follows Microsoft Intune best practices:
- Proper exit codes (0=success, 1=failure, 2=error)
- Event log integration for monitoring and troubleshooting
- System restore point creation before making changes
- Comprehensive error handling and logging
- No user interaction (required for Intune deployment)
⚠️ IMPORTANT: For complete Intune compliance, you need BOTH detection and remediation scripts.
Consider using 'generate_intune_script_pair' instead to create both scripts together.
Microsoft References:
- Intune Remediation Scripts: https://docs.microsoft.com/en-us/mem/intune/fundamentals/remediations
- Best Practices: https://docs.microsoft.com/en-us/mem/intune/fundamentals/remediations-script-samples
- PowerShell Script Requirements: https://docs.microsoft.com/en-us/mem/intune/apps/intune-management-extension
- Exit Code Standards: https://docs.microsoft.com/en-us/mem/intune/apps/troubleshoot-mam-app-installation#exit-codes
Args:
description: Clear description of what the script should remediate (e.g., 'Install Chrome browser', 'Configure Windows firewall')
remediation_logic: PowerShell code that performs the remediation. Use 'Complete-Remediation -Success $true -Message "description"' to indicate completion
output_path: Optional file path where the script will be saved. If not provided, returns script content
timeout: Command timeout in seconds (1-300, default 60)
Returns:
Generated script content or path where script was saved
Example:
Generate a script to install Chrome:
```
result = await generate_intune_remediation_script(
description="Install Chrome browser to latest version",
remediation_logic='''
$installer = "$env:TEMP\ChromeSetup.exe"
Invoke-WebRequest -Uri "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile $installer
Start-Process -FilePath $installer -Args "/silent /install" -Wait
Remove-Item $installer -Force
Complete-Remediation -Success $true -Message "Chrome installation completed successfully"
''',
output_path="remediate_chrome.ps1"
)
```
Tips:
- Always use Complete-Remediation function to set proper exit codes
- Test your remediation_logic in a safe environment first
- Consider creating a system restore point for major changes
- Use Write-IntuneLog for detailed logging and troubleshooting
- Ensure no user interaction is required (scripts run silently)
Inputs: description (required), remediation_logic (required), output_path, timeout. Returns: result
generate_intune_script_pairAInspect
Generate a complete pair of Microsoft Intune detection and remediation scripts.
This is the RECOMMENDED tool for Intune compliance as it creates both required scripts:
- Detection script: Checks current system state and determines compliance
- Remediation script: Fixes non-compliant conditions with proper safeguards
Both scripts follow Microsoft Intune best practices:
- Proper exit codes (Detection: 0=compliant, 1=non-compliant, 2=error; Remediation: 0=success, 1=failure, 2=error)
- Event log integration for centralized monitoring
- System restore points before changes (remediation only)
- Comprehensive error handling and logging
- No user interaction (silent execution required)
Microsoft References:
- Intune Remediation Scripts Overview: https://docs.microsoft.com/en-us/mem/intune/fundamentals/remediations
- Script Deployment Best Practices: https://docs.microsoft.com/en-us/mem/intune/fundamentals/remediations-script-samples
- PowerShell Requirements: https://docs.microsoft.com/en-us/mem/intune/apps/intune-management-extension
- Exit Code Standards: https://docs.microsoft.com/en-us/mem/intune/apps/troubleshoot-mam-app-deployment
- Monitoring and Reporting: https://docs.microsoft.com/en-us/mem/intune/fundamentals/remediations-monitor
Args:
description: Clear description of what the scripts should detect and remediate (e.g., 'Ensure Chrome browser is installed with latest version')
detection_logic: PowerShell code that performs the compliance check. Use 'Complete-Detection -Compliant $true/$false -Message "status"' to indicate result
remediation_logic: PowerShell code that fixes non-compliant conditions. Use 'Complete-Remediation -Success $true/$false -Message "result"' to indicate completion
output_dir: Optional directory to save both scripts. If not provided, returns script content in response
timeout: Command timeout in seconds (1-300, default 60)
Returns:
Dictionary containing both scripts: {"detection_script": "content/path", "remediation_script": "content/path"}
Example:
Generate scripts to manage Chrome browser installation:
```
result = await generate_intune_script_pair(
description="Ensure Chrome browser is installed with version 100.0.0.0 or higher",
detection_logic='''
try {
$app = Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" -ErrorAction Stop
$version = (Get-Item $app.'(Default)').VersionInfo.FileVersion
$compliant = [version]$version -ge [version]"100.0.0.0"
Complete-Detection -Compliant $compliant -Message "Chrome version: $version (Required: 100.0.0.0+)"
} catch {
Complete-Detection -Compliant $false -Message "Chrome not found or inaccessible"
}
''',
remediation_logic='''
try {
$installer = "$env:TEMP\ChromeSetup.exe"
Write-IntuneLog "Downloading Chrome installer..."
Invoke-WebRequest -Uri "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile $installer -UseBasicParsing
Write-IntuneLog "Installing Chrome silently..."
Start-Process -FilePath $installer -Args "/silent /install" -Wait
Remove-Item $installer -Force
Complete-Remediation -Success $true -Message "Chrome installation completed successfully"
} catch {
Complete-Remediation -Success $false -Message "Chrome installation failed: $($_.Exception.Message)"
}
''',
output_dir="chrome_intune_scripts"
)
```
Tips:
- Always test both scripts in a controlled environment first
- Use descriptive logging messages for easier troubleshooting
- Consider the impact of remediation actions (e.g., system restarts, user disruption)
- Use Write-IntuneLog for detailed progress tracking
- Ensure detection logic is fast and efficient (runs frequently)
- Make remediation logic idempotent (safe to run multiple times)
Inputs: description (required), detection_logic (required), remediation_logic (required), output_dir, +1 more. Returns: result
generate_script_from_templateBInspect
Generate a PowerShell script from a template.
Args:
template_name: Name of the template to use (without .ps1 extension)
parameters: Dictionary of parameters to replace in the template
output_path: Where to save the generated script (optional)
timeout: Command timeout in seconds (1-300, default 60)
Returns:
Generated script content or path where script was saved
Inputs: template_name (required), parameters (required), output_path, timeout. Returns: result
get_event_logsBInspect
Get Windows event logs.
Args:
logname: Name of the event log (System, Application, Security, etc.)
newest: Number of most recent events to retrieve (default 10)
level: Filter by event level (1: Critical, 2: Error, 3: Warning, 4: Information)
timeout: Command timeout in seconds (1-300, default 60)
Inputs: logname (required), newest, level, timeout. Returns: result
get_processesAInspect
Get information about running processes.
Args:
name: Filter processes by name (supports wildcards)
top: Limit to top N processes
sort_by: Property to sort by (e.g., CPU, WorkingSet)
timeout: Command timeout in seconds (1-300, default 60)
Inputs: name, top, sort_by, timeout. Returns: result
get_running_servicesBInspect
Get information about running services.
Args:
name: Filter services by name (supports wildcards)
status: Filter by status (Running, Stopped, etc.)
timeout: Command timeout in seconds (1-300, default 60)
Inputs: name, status, timeout. Returns: result
get_system_infoBInspect
Get system information.
Args:
properties: List of ComputerInfo properties to retrieve (optional)
timeout: Command timeout in seconds (1-300, default 60)
Inputs: properties, timeout. Returns: result
run_powershellAInspect
Execute PowerShell commands securely.
Args:
code: PowerShell code to execute
timeout: Command timeout in seconds (1-300, default 60)
ctx: MCP context for logging and progress reporting
Returns:
Command output as string
Inputs: code (required), timeout, ctx. Returns: result
run_powershell_with_progressBInspect
Execute PowerShell commands with detailed progress reporting.
Args:
code: PowerShell code to execute
timeout: Command timeout in seconds (1-300, default 60)
ctx: MCP context for logging and progress reporting
Returns:
Command output as string with execution details
Inputs: code (required), timeout, ctx. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 14 tools
The tool set has clear groupings but some overlap exists. The BigFix and Intune script generation tools have distinct purposes (relevance/detection vs action/remediation), but 'generate_custom_script' and 'generate_script_from_template' could be confused with each other and with the specialized script generators. The system monitoring tools (get_event_logs, get_processes, etc.) are clearly distinct from script generation tools.
Most tools follow a consistent verb_noun pattern with snake_case (e.g., generate_bigfix_action_script, get_event_logs, run_powershell). The main deviation is 'ensure_directory' which uses a different verb style than others, but overall the naming is predictable and readable across the set.
14 tools is reasonable for a PowerShell execution server with script generation and system monitoring capabilities. The count feels slightly high but justified by covering both BigFix and Intune ecosystems plus general PowerShell execution. Some tools like 'run_powershell' and 'run_powershell_with_progress' could potentially be consolidated.
The server provides good coverage for PowerShell script generation (BigFix, Intune, custom) and system monitoring. Minor gaps exist: there's no tool for managing scheduled tasks or registry operations which are common PowerShell domains, and the script generation tools focus heavily on enterprise deployment scenarios while lacking simpler one-off script creation options beyond 'generate_custom_script'.
Related MCP Connectors
Microsoft 365, CRM, Partner Center and tenant operations for organisations and MSPs.
Troubleshoot enrolled client PCs from your AI client, with human approval and an audit trail.
- DNS-DATA RemoteDeprecatedcom.dns-data
Connect AI assistants to authorized Windows and macOS devices for files, commands, and management.
Remote Desktop Commander: use files, terminal and processes on your own computers from any AI app.