Courses/PowerShell/File System and Registry

    File System and Registry

    Navigate drives, manage files and folders, and read/write the Windows Registry.

    What You'll Learn

    • PowerShell Provider drives (FileSystem, Registry, Env)
    • Creating, copying, moving, and deleting files & folders
    • Reading/writing the Windows Registry
    • Managing environment variables

    PowerShell Providers

    PowerShell's Provider system is brilliant: it lets you navigate the file system, registry, environment variables, and certificates using the same commands โ€” Get-ChildItem, Set-Location, New-Item, etc.

    ๐ŸŽฏ Real-World Analogy: Imagine if you could browse the Windows Registry the same way you browse folders โ€” cd HKLM:\SOFTWARE then ls. That's exactly what Providers enable.

    Get-PSDrive          # List all available drives
    Get-PSProvider       # List all providers
    
    cd HKCU:\Software    # Navigate registry like folders!
    cd Env:              # Browse environment variables
    cd Cert:\LocalMachine # Browse SSL certificates

    File Operations

    File management and reading/writing content.

    Try it Yourself ยป
    JavaScript
    // File System Operations โ€” simulated in JavaScript
    console.log("=== PowerShell Provider Drives ===");
    console.log();
    console.log("PowerShell treats everything as a 'drive' via Providers:");
    const drives = [
      { drive: "C:\\, D:\\",      provider: "FileSystem",    desc: "Files and folders" },
      { drive: "HKLM:\\, HKCU:\\", provider: "Registry",     desc: "Windows Registry" },
      { drive: "Env:\\",          provider: "Environment",  desc: "Environment variables" },
      { drive: "Cert:\\",         pr
    ...

    Registry & Environment Variables

    The Windows Registry is a hierarchical database storing system and app configuration. PowerShell gives you full CRUD access using familiar Item cmdlets:

    # Read a registry value
    $ver = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").ProductName
    
    # Create a key for your app
    New-Item -Path "HKCU:\Software\MyApp" -Force
    
    # Set a value
    Set-ItemProperty "HKCU:\Software\MyApp" -Name "Theme" -Value "Dark"

    โš ๏ธ Common Mistake

    Editing HKLM:\ (Local Machine) requires Administrator privileges. Always run PowerShell as Admin when modifying machine-wide settings. HKCU:\ (Current User) doesn't need elevation.

    Registry & Env Vars

    Navigate the registry and manage environment variables.

    Try it Yourself ยป
    JavaScript
    // Windows Registry & Env Vars โ€” simulated in JavaScript
    console.log("=== Windows Registry ===");
    console.log();
    console.log("PowerShell navigates the Registry like a file system:");
    console.log();
    console.log("  PS> Set-Location HKCU:\\Software");
    console.log("  PS> Get-ChildItem     # Browse registry keys");
    console.log("  PS> Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion");
    console.log();
    
    console.log("=== Common Registry Tasks ===");
    console.log("  # Read a value");
    co
    ...

    ๐Ÿ’ก Pro Tip

    Use Get-Content -Wait to live-tail log files (like tail -f on Linux). Combine with Select-String for real-time filtering: Get-Content app.log -Wait | Select-String "ERROR".

    ๐Ÿ“‹ Quick Reference

    CmdletPurpose
    Get-ChildItemList files / registry keys
    Get-ContentRead file contents
    Set-ContentWrite to file (overwrite)
    Test-PathCheck if path exists
    Get-ItemPropertyRead registry values
    $env:VARNAMEAccess environment variable

    ๐ŸŽ‰ Lesson Complete!

    You can now manage files, registry keys, and environment variables like a pro. Next up: automating tasks and scheduling scripts.

    Sign up for free to track which lessons you've completed and get learning reminders.

    Previous

    Cookie & Privacy Settings

    We use cookies to improve your experience, analyze traffic, and show personalized ads. You can manage your preferences below.

    By clicking "Accept All", you consent to our use of cookies for analytics and personalized advertising. You can customize your preferences or reject non-essential cookies.

    Privacy Policy โ€ข Terms of Service