XCODX |

PowerShell Online Compiler & Interpreter

Select Language
Online Code Compiler
Full HTML IDE
Py main.py
Program Output Ready
  Welcome to XCODX Online Compiler

  Quick Start:
  Ctrl+Enter  Run code
  Ctrl+S      Save / Download
  Ctrl+L      Clear output

  Select a language and start coding.
Success
Operation completed

About PowerShell

PowerShell is a shell and scripting language Microsoft introduced in 2006 and rebuilt as open-source, cross-platform software in 2016, so current releases — the pwsh 7.x line, built on modern .NET — run natively on Linux and macOS as well as Windows. What sets it apart from Bash and other shells is that its pipeline passes structured .NET objects rather than plain text, so you filter and reshape data by property with Where-Object and Select-Object instead of parsing strings. The language has variables, functions, loops, try/catch error handling, and direct access to the whole .NET Base Class Library. It is a daily tool for Windows and cloud administrators, DevOps engineers, and security analysts. On XCODX it runs as pwsh in a live terminal, where Read-Host waits for your keyboard and output streams as each line executes; the version is shown in the badge.

Hello World in PowerShell

$name = Read-Host "Your name"
Write-Host "Hi $name - let's rank some numbers."

$limit = [int](Read-Host "Count up to what number")

# The pipeline carries .NET objects, not text
$rows = 1..$limit | ForEach-Object {
    [pscustomobject]@{
        N      = $_
        Square = $_ * $_
        IsEven = ($_ % 2 -eq 0)
    }
}

$rows | Where-Object IsEven | Sort-Object Square -Descending | Format-Table
Write-Host "Even count: $( ($rows | Where-Object IsEven).Count )"

When to use PowerShell

PowerShell fluency is a baseline expectation for Windows and Azure administration, Microsoft 365 and Intune scripting, and a growing share of DevOps work, and this page suits practicing the language itself: the object pipeline, Where-Object and ForEach-Object, hashtables, custom objects, functions, and try/catch. Choose it for certification prep (the scripting portions of exams like AZ-104), for checking syntax from a Mac or Linux machine without installing pwsh, or for working through a course from any browser. The full .NET Base Class Library is reachable, so [datetime], [math], and [regex] behave as they do in a real session. The honest limitation is that there is no machine to manage here: cmdlets like Get-Service or Get-Process, and anything touching Azure or Active Directory, target the empty sandbox rather than your computer, so treat this as a script runner, not an administration console.

Common questions

Does Read-Host work interactively here?

Yes. This is a real terminal session, so Read-Host prints its prompt and blocks until you type a line and press Enter, while earlier Write-Host or Write-Output lines have already streamed to the screen. You can chain several prompts, or read inside a loop, and each answer is processed live; alternatively, paste input into the Stdin Box and end the stream with Ctrl+D.

Can I run Install-Module or use the PowerShell Gallery?

No. Install-Module, Find-Module, and the PowerShell Gallery all need network access, which the sandbox does not have, so third-party modules cannot be downloaded. You get the built-in cmdlets and the full .NET Base Class Library, but not community modules like Az, Pester, or ImportExcel. Anything that depends on an external module will not load here.

Is this Windows PowerShell 5.1 or PowerShell 7?

It is the cross-platform PowerShell 7.x line (pwsh) running on Linux, not the legacy Windows-only 5.1. For scripting practice the language behaves almost identically, and 7.x adds conveniences such as the ternary operator, ForEach-Object -Parallel, and null-coalescing operators. The exact version is printed in the badge and in $PSVersionTable.

Why does Get-Service or Get-Process return nothing useful?

Because those cmdlets query the sandbox, not your own machine, and the sandbox is a minimal, isolated Linux container with almost nothing running. Anything that inspects or changes a real system — services, the registry, Active Directory, Azure resources — has no target here. This page is a script runner for the language, not a console for administering a live environment.

Can I call a REST API with Invoke-RestMethod or save a file?

No. Invoke-RestMethod and Invoke-WebRequest need the network, which is blocked, so web calls fail. The filesystem is temporary and wiped after each run, so a file written with Set-Content or Export-Csv exists only for that run. Keep scripts self-contained and use the data they generate within the same run.

Can I use .NET types and classes directly in PowerShell?

Yes. PowerShell sits on top of .NET, so you can call static members like [math]::Sqrt(2), construct types such as [datetime] and [regex], and build [pscustomobject] records that flow through the pipeline. The Base Class Library is available even though external modules are not, which makes the page good for practicing the language's deeper features.

How PowerShell runs on XCODX

Sandbox filename
main.ps1
Entry point
single main source file
Editor grammar
shell
Reading stdin
Read-Host
Input delivery
live WebSocket stream
Prompt flushing
flushes before reading input
Compile limit
10 s
Run limit
3 s batch · up to 3 min live
Memory
256 MB per stage
Max source
50,000 characters

Default program on this page

# PowerShell Script
Write-Host "Hello from PowerShell!"
Write-Host "Welcome to XCODX Online Compiler!"

# Array operations
$numbers = 1..10
Write-Host "Numbers: $numbers"
$sum = ($numbers | Measure-Object -Sum).Sum
Write-Host "Sum: $sum"

# Hashtable
$info = @{
    Name = "XCODX"
    Type = "Compiler"
    Languages = 85
}
foreach ($key in $info.Keys) {
    Write-Host "  $key = $($info[$key])"
}