{"id":5295,"date":"2026-03-18T11:29:51","date_gmt":"2026-03-18T08:29:51","guid":{"rendered":"https:\/\/computingforgeeks.com\/?p=5295"},"modified":"2026-03-24T12:04:01","modified_gmt":"2026-03-24T09:04:01","slug":"install-powershell-ubuntu-debian","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/install-powershell-ubuntu-debian\/","title":{"rendered":"Install PowerShell 7 on Ubuntu 24.04\/22.04 and Debian 13\/12"},"content":{"rendered":"\n<p>PowerShell 7 is Microsoft&#8217;s cross-platform automation framework that runs natively on Linux, macOS, and Windows. Built on .NET, it brings a full-featured shell and scripting language to Linux systems, making it a solid choice for administrators managing hybrid environments across Azure, AWS, and on-premises infrastructure. This guide walks through installing PowerShell 7 on Ubuntu 24.04\/22.04 and Debian 13\/12 from the official Microsoft APT repository, then covers practical usage for Linux system administration.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why PowerShell 7 on Linux?<\/h2>\n\n\n\n<p>If you manage infrastructure across multiple platforms, PowerShell 7 gives you a consistent scripting environment everywhere. Here is what makes it worth installing on your Linux boxes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Cross-platform automation<\/strong> &#8211; Write scripts once, run them on Linux, Windows, and macOS without modification<\/li>\n<li><strong>Azure and AWS management<\/strong> &#8211; Native modules for managing cloud resources directly from the terminal<\/li>\n<li><strong>Object-oriented pipeline<\/strong> &#8211; Unlike traditional shells that pipe text, PowerShell pipes structured objects between commands<\/li>\n<li><strong>Built-in remoting<\/strong> &#8211; SSH-based remoting to manage remote Linux and Windows machines from a single session<\/li>\n<li><strong>Rich module ecosystem<\/strong> &#8211; Thousands of modules available through the PowerShell Gallery for every task imaginable<\/li>\n<li><strong>DSC (Desired State Configuration)<\/strong> &#8211; Configuration management built right into the platform<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>Before starting the installation, make sure you have the following in place:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A running Ubuntu 24.04\/22.04 or Debian 13\/12 system<\/li>\n<li>A user account with sudo privileges<\/li>\n<li>A working internet connection<\/li>\n<li>The <code>apt-transport-https<\/code>, <code>curl<\/code>, and <code>gpg<\/code> packages installed<\/li>\n<\/ul>\n\n\n\n<p>Update your system packages before proceeding:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update && sudo apt upgrade -y<\/code><\/pre>\n\n\n\n<p>Install the required dependencies:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install -y curl gpg apt-transport-https software-properties-common<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1 &#8211; Add the Microsoft APT Repository<\/h2>\n\n\n\n<p>Microsoft maintains an official APT repository for PowerShell and other .NET packages. Start by downloading and installing the Microsoft GPG key:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -fsSL https:\/\/packages.microsoft.com\/keys\/microsoft.asc | sudo gpg --dearmor -o \/usr\/share\/keyrings\/microsoft-archive-keyring.gpg<\/code><\/pre>\n\n\n\n<p>Now add the Microsoft APT repository. Choose the command that matches your distribution.<\/p>\n\n\n\n<p><strong>For Ubuntu 24.04 (Noble):<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"deb [arch=amd64 signed-by=\/usr\/share\/keyrings\/microsoft-archive-keyring.gpg] https:\/\/packages.microsoft.com\/ubuntu\/24.04\/prod noble main\" | sudo tee \/etc\/apt\/sources.list.d\/microsoft.list<\/code><\/pre>\n\n\n\n<p><strong>For Ubuntu 22.04 (Jammy):<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"deb [arch=amd64 signed-by=\/usr\/share\/keyrings\/microsoft-archive-keyring.gpg] https:\/\/packages.microsoft.com\/ubuntu\/22.04\/prod jammy main\" | sudo tee \/etc\/apt\/sources.list.d\/microsoft.list<\/code><\/pre>\n\n\n\n<p><strong>For Debian 13 (Trixie):<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"deb [arch=amd64 signed-by=\/usr\/share\/keyrings\/microsoft-archive-keyring.gpg] https:\/\/packages.microsoft.com\/debian\/13\/prod trixie main\" | sudo tee \/etc\/apt\/sources.list.d\/microsoft.list<\/code><\/pre>\n\n\n\n<p><strong>For Debian 12 (Bookworm):<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"deb [arch=amd64 signed-by=\/usr\/share\/keyrings\/microsoft-archive-keyring.gpg] https:\/\/packages.microsoft.com\/debian\/12\/prod bookworm main\" | sudo tee \/etc\/apt\/sources.list.d\/microsoft.list<\/code><\/pre>\n\n\n\n<p>Verify the repository file was created:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/etc\/apt\/sources.list.d\/microsoft.list<\/code><\/pre>\n\n\n\n<p>You should see the repository line you just added. If the file is empty or missing, repeat the steps above.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2 &#8211; Install PowerShell 7<\/h2>\n\n\n\n<p>Update the package index to pull metadata from the newly added repository, then install PowerShell:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install -y powershell<\/code><\/pre>\n\n\n\n<p>The installation pulls in the .NET runtime and all required dependencies automatically. Depending on your connection speed, this may take a minute or two.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3 &#8211; Verify the Installation<\/h2>\n\n\n\n<p>Confirm PowerShell 7 is installed and working by checking the version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pwsh --version<\/code><\/pre>\n\n\n\n<p>Expected output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PowerShell 7.4.x<\/code><\/pre>\n\n\n\n<p>Check the binary location to confirm it installed to the expected path:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>which pwsh<\/code><\/pre>\n\n\n\n<p>This should return <code>\/usr\/bin\/pwsh<\/code>. You can now launch an interactive PowerShell session:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pwsh<\/code><\/pre>\n\n\n\n<p>Your prompt changes to <code>PS \/home\/username&gt;<\/code>, indicating you are inside a PowerShell session. To exit back to your regular shell, type <code>exit<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4 &#8211; Basic PowerShell Usage on Linux<\/h2>\n\n\n\n<p>If you are coming from Bash, PowerShell works differently in some fundamental ways. Here are the essentials to get productive quickly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Process Management<\/h3>\n\n\n\n<p>List running processes with <code>Get-Process<\/code>, which is the PowerShell equivalent of <code>ps aux<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-Process<\/code><\/pre>\n\n\n\n<p>Filter for a specific process:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-Process -Name \"nginx\"<\/code><\/pre>\n\n\n\n<p>Sort processes by CPU usage and show the top 10:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-Process | Sort-Object CPU -Descending | Select-Object -First 10<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Service Management<\/h3>\n\n\n\n<p>On Linux, PowerShell interacts with systemd through its service cmdlets. Note that <code>Get-Service<\/code> is not natively available on Linux, but you can query systemd directly:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># List all active services via systemctl\n& systemctl list-units --type=service --state=running\n\n# Check status of a specific service\n& systemctl status nginx\n\n# Restart a service\n& sudo systemctl restart nginx<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">The Object Pipeline<\/h3>\n\n\n\n<p>The biggest difference from Bash is that PowerShell pipes structured objects, not plain text. This means you can access properties directly without parsing text with awk or grep:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Get all processes using more than 100MB of memory\nGet-Process | Where-Object { $_.WorkingSet64 -gt 100MB } | Select-Object Name, @{Name='MemoryMB';Expression={[math]::Round($_.WorkingSet64\/1MB,2)}}\n\n# Get files larger than 50MB in a directory\nGet-ChildItem \/var\/log -Recurse | Where-Object { $_.Length -gt 50MB } | Select-Object FullName, @{Name='SizeMB';Expression={[math]::Round($_.Length\/1MB,2)}}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Working with Files and Directories<\/h3>\n\n\n\n<p>PowerShell provides cmdlets that map to familiar Linux commands, plus additional functionality:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># List files (equivalent to ls -la)\nGet-ChildItem -Force\n\n# Read file contents (equivalent to cat)\nGet-Content \/etc\/hostname\n\n# Search for text in files (equivalent to grep)\nSelect-String -Path \"\/var\/log\/syslog\" -Pattern \"error\" -CaseSensitive:$false\n\n# Create a directory\nNew-Item -ItemType Directory -Path \"\/tmp\/powershell-test\"\n\n# Copy files\nCopy-Item -Path \"\/etc\/hosts\" -Destination \"\/tmp\/hosts.backup\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Installing PowerShell Modules<\/h3>\n\n\n\n<p>PowerShell modules extend functionality significantly. Install them from the PowerShell Gallery:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Search for a module\nFind-Module -Name \"PSScriptAnalyzer\"\n\n# Install a module for the current user\nInstall-Module -Name PSScriptAnalyzer -Scope CurrentUser -Force\n\n# List installed modules\nGet-InstalledModule<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5 &#8211; Install the Az Module for Azure Management<\/h2>\n\n\n\n<p>If you manage Azure resources, the Az PowerShell module lets you handle everything from VMs to storage accounts directly from your Linux terminal. Launch a PowerShell session and install the module:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pwsh -Command \"Install-Module -Name Az -Repository PSGallery -Scope CurrentUser -Force\"<\/code><\/pre>\n\n\n\n<p>The Az module is large, so the installation takes a few minutes. Once installed, verify it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pwsh -Command \"Get-InstalledModule -Name Az | Select-Object Name, Version\"<\/code><\/pre>\n\n\n\n<p>Connect to your Azure account and start managing resources:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Start PowerShell\npwsh\n\n# Connect to Azure (opens browser for authentication)\nConnect-AzAccount\n\n# List resource groups\nGet-AzResourceGroup | Format-Table ResourceGroupName, Location\n\n# List virtual machines\nGet-AzVM | Format-Table Name, ResourceGroupName, Location\n\n# Get the status of all VMs\nGet-AzVM -Status | Select-Object Name, ResourceGroupName, PowerState<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6 &#8211; Install AWS.Tools for AWS Management<\/h2>\n\n\n\n<p>For AWS environments, the modular AWS.Tools packages let you install only the service modules you need, keeping things lightweight:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pwsh -Command \"Install-Module -Name AWS.Tools.Installer -Scope CurrentUser -Force\"<\/code><\/pre>\n\n\n\n<p>Then install the specific service modules you work with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pwsh -Command \"Install-AWSToolsModule AWS.Tools.EC2, AWS.Tools.S3, AWS.Tools.IAM -Scope CurrentUser -Force\"<\/code><\/pre>\n\n\n\n<p>Verify the installation and configure your credentials:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Start PowerShell\npwsh\n\n# Verify installed AWS modules\nGet-InstalledModule -Name \"AWS.Tools.*\" | Select-Object Name, Version\n\n# Set your AWS credentials\nSet-AWSCredential -AccessKey \"YOUR_ACCESS_KEY\" -SecretKey \"YOUR_SECRET_KEY\" -StoreAs default\n\n# List EC2 instances\nGet-EC2Instance -Region us-east-1 | ForEach-Object { $_.Instances } | Select-Object InstanceId, InstanceType, State\n\n# List S3 buckets\nGet-S3Bucket | Format-Table BucketName, CreationDate<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 7 &#8211; PowerShell SSH Remoting<\/h2>\n\n\n\n<p>PowerShell 7 supports SSH-based remoting, which is the preferred method on Linux. This lets you run PowerShell commands on remote machines over SSH without WinRM.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Configure SSH for PowerShell Remoting<\/h3>\n\n\n\n<p>On the remote machine, add a PowerShell subsystem to the SSH configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tee -a \/etc\/ssh\/sshd_config &lt;&lt;'EOF'\n\n# PowerShell SSH Remoting Subsystem\nSubsystem powershell \/usr\/bin\/pwsh -sshs -NoLogo -NoProfile\nEOF<\/code><\/pre>\n\n\n\n<p>Restart the SSH service to apply the change:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart sshd<\/code><\/pre>\n\n\n\n<p>Verify sshd restarted without errors:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl status sshd<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Connect to a Remote Machine<\/h3>\n\n\n\n<p>From your local PowerShell session, create a remote session over SSH:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Start an interactive remote session\nEnter-PSSession -HostName 192.168.1.100 -UserName admin -SSHTransport\n\n# Or run a single command on the remote machine\nInvoke-Command -HostName 192.168.1.100 -UserName admin -SSHTransport -ScriptBlock {\n    Get-Process | Sort-Object CPU -Descending | Select-Object -First 5\n}\n\n# Run commands on multiple remote machines\nInvoke-Command -HostName \"server1\",\"server2\",\"server3\" -UserName admin -SSHTransport -ScriptBlock {\n    hostname\n    Get-Process | Measure-Object | Select-Object -ExpandProperty Count\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 8 &#8211; Create and Run PowerShell Scripts on Linux<\/h2>\n\n\n\n<p>PowerShell scripts use the <code>.ps1<\/code> extension and work the same way on Linux as they do on Windows.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Create a Simple Script<\/h3>\n\n\n\n<p>Create a script that gathers basic system information:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat &gt; ~\/scripts\/system-report.ps1 &lt;&lt;'SCRIPT'\n#!\/usr\/bin\/env pwsh\n\n# System Report Script\n$report = [PSCustomObject]@{\n    Hostname    = (hostname)\n    DateTime    = Get-Date -Format \"yyyy-MM-dd HH:mm:ss\"\n    Uptime      = (& uptime -p)\n    KernelVer   = (& uname -r)\n    CPUCount    = (& nproc)\n    TotalMemGB  = [math]::Round((Get-Content \/proc\/meminfo | Select-String \"MemTotal\" | ForEach-Object { ($_ -split '\\s+')[1] }) \/ 1MB, 2)\n    DiskUsage   = (& df -h \/ | Select-Object -Last 1)\n}\n\n$report | Format-List\n\n# Top 5 memory-consuming processes\nWrite-Output \"`n--- Top 5 Processes by Memory ---\"\nGet-Process | Sort-Object WorkingSet64 -Descending | Select-Object -First 5 Name, @{N='MemMB';E={[math]::Round($_.WorkingSet64\/1MB,2)}} | Format-Table -AutoSize\nSCRIPT<\/code><\/pre>\n\n\n\n<p>Make it executable and run it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir -p ~\/scripts\nchmod +x ~\/scripts\/system-report.ps1\npwsh ~\/scripts\/system-report.ps1<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Schedule Scripts with Cron<\/h3>\n\n\n\n<p>Run PowerShell scripts on a schedule using standard cron:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Run the system report every day at 8 AM\n(crontab -l 2>\/dev\/null; echo \"0 8 * * * \/usr\/bin\/pwsh \/home\/$USER\/scripts\/system-report.ps1 >> \/var\/log\/system-report.log 2>&1\") | crontab -<\/code><\/pre>\n\n\n\n<p>Verify the cron entry was added:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>crontab -l<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 9 &#8211; Configure PSReadLine for a Better Terminal Experience<\/h2>\n\n\n\n<p>PSReadLine is bundled with PowerShell 7 and provides command-line editing features similar to what you get with Bash readline. Customize it by creating a PowerShell profile:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pwsh -Command \"New-Item -Path \\$PROFILE -ItemType File -Force\"<\/code><\/pre>\n\n\n\n<p>Add your PSReadLine configuration to the profile:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat > ~\/.config\/powershell\/Microsoft.PowerShell_profile.ps1 &lt;&lt;'PROFILE'\n# PSReadLine Configuration\nSet-PSReadLineOption -PredictionSource History\nSet-PSReadLineOption -PredictionViewStyle ListView\nSet-PSReadLineOption -EditMode Emacs\nSet-PSReadLineOption -HistorySearchCursorMovesToEnd\nSet-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward\nSet-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward\nSet-PSReadLineKeyHandler -Key Tab -Function MenuComplete\n\n# Useful aliases\nSet-Alias -Name ll -Value Get-ChildItem\nSet-Alias -Name grep -Value Select-String\n\n# Custom prompt\nfunction prompt {\n    $currentDir = (Get-Location).Path.Replace($HOME, \"~\")\n    \"PS $currentDir> \"\n}\nPROFILE<\/code><\/pre>\n\n\n\n<p>Verify the profile loads correctly:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pwsh -NoExit -Command \"Write-Output 'Profile loaded successfully'\"<\/code><\/pre>\n\n\n\n<p>Key features you now have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Predictive IntelliSense<\/strong> &#8211; Shows suggestions based on your command history as you type<\/li>\n<li><strong>ListView predictions<\/strong> &#8211; Displays suggestions in a dropdown list<\/li>\n<li><strong>Emacs keybindings<\/strong> &#8211; Ctrl+A, Ctrl+E, Ctrl+K, and other familiar shortcuts work as expected<\/li>\n<li><strong>History search<\/strong> &#8211; Up\/Down arrows search through history matching what you have already typed<\/li>\n<li><strong>Tab completion<\/strong> &#8211; Menu-style tab completion for commands, parameters, and file paths<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 10 &#8211; VS Code Integration<\/h2>\n\n\n\n<p>Visual Studio Code with the PowerShell extension provides the best editing and debugging experience for PowerShell scripts on Linux.<\/p>\n\n\n\n<p>Install VS Code if you have not already:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install -y code<\/code><\/pre>\n\n\n\n<p>If VS Code is not available from your default repositories, install it from the Microsoft repository (which you already added in Step 1):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update && sudo apt install -y code<\/code><\/pre>\n\n\n\n<p>Install the PowerShell extension from the command line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>code --install-extension ms-vscode.powershell<\/code><\/pre>\n\n\n\n<p>Verify the extension is installed:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>code --list-extensions | grep -i powershell<\/code><\/pre>\n\n\n\n<p>The PowerShell extension provides:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Syntax highlighting and IntelliSense for .ps1 files<\/li>\n<li>Integrated PowerShell terminal<\/li>\n<li>Script debugging with breakpoints<\/li>\n<li>Code formatting with PSScriptAnalyzer rules<\/li>\n<li>Function and variable navigation<\/li>\n<\/ul>\n\n\n\n<p>To configure VS Code to use PowerShell 7 as the default integrated terminal, add this to your <code>settings.json<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n    \"terminal.integrated.defaultProfile.linux\": \"pwsh\",\n    \"terminal.integrated.profiles.linux\": {\n        \"pwsh\": {\n            \"path\": \"\/usr\/bin\/pwsh\",\n            \"icon\": \"terminal-powershell\"\n        }\n    },\n    \"powershell.powerShellDefaultVersion\": \"PowerShell (pwsh)\"\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Package not found after adding the repository<\/h3>\n\n\n\n<p>If <code>apt install powershell<\/code> fails with &#8220;Unable to locate package,&#8221; the repository may not have been added correctly. Check the repository file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/etc\/apt\/sources.list.d\/microsoft.list<\/code><\/pre>\n\n\n\n<p>Make sure the codename matches your distribution. Also verify the GPG key is present:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -la \/usr\/share\/keyrings\/microsoft-archive-keyring.gpg<\/code><\/pre>\n\n\n\n<p>If the file is missing or has zero size, re-download it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -fsSL https:\/\/packages.microsoft.com\/keys\/microsoft.asc | sudo gpg --dearmor -o \/usr\/share\/keyrings\/microsoft-archive-keyring.gpg<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">pwsh crashes or fails to start<\/h3>\n\n\n\n<p>If PowerShell crashes on launch, it may be a .NET dependency issue. Check the installed dependencies:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt list --installed 2>\/dev\/null | grep -E \"libicu|libssl|dotnet\"<\/code><\/pre>\n\n\n\n<p>Install any missing ICU or SSL libraries:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install -y libicu-dev libssl-dev<\/code><\/pre>\n\n\n\n<p>If the issue persists, try running PowerShell with trace output to identify the problem:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 pwsh<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Module installation fails with permission errors<\/h3>\n\n\n\n<p>Always install modules with <code>-Scope CurrentUser<\/code> to avoid permission issues. If you previously installed a module system-wide and need to fix it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pwsh -Command \"Install-Module -Name ModuleName -Scope CurrentUser -Force -AllowClobber\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">SSH remoting fails to connect<\/h3>\n\n\n\n<p>Verify that the PowerShell subsystem is configured on the remote host:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -i \"subsystem powershell\" \/etc\/ssh\/sshd_config<\/code><\/pre>\n\n\n\n<p>Make sure <code>pwsh<\/code> is installed on the remote machine and the path in the subsystem line is correct:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>which pwsh<\/code><\/pre>\n\n\n\n<p>After making any changes to <code>sshd_config<\/code>, restart the SSH service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart sshd && sudo systemctl status sshd<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">PowerShell profile not loading<\/h3>\n\n\n\n<p>Check the profile path and verify the file exists:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pwsh -Command \"Write-Output \\$PROFILE; Test-Path \\$PROFILE\"<\/code><\/pre>\n\n\n\n<p>The profile directory should be <code>~\/.config\/powershell\/<\/code>. If the directory does not exist, create it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir -p ~\/.config\/powershell<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Updating PowerShell<\/h3>\n\n\n\n<p>Since PowerShell is installed through APT, updates come through the standard package manager:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update && sudo apt upgrade powershell -y<\/code><\/pre>\n\n\n\n<p>Verify the new version after upgrading:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pwsh --version<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>PowerShell 7 on Ubuntu and Debian gives you a capable cross-platform automation tool that fits right into existing Linux workflows. With the Microsoft APT repository configured, you get regular updates through the standard package manager. Combined with the Az and AWS.Tools modules, SSH remoting, and VS Code integration, it provides a solid foundation for managing hybrid infrastructure from a single scripting environment. The object-oriented pipeline alone makes it worth learning if you spend time parsing text output from traditional Linux commands.<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>PowerShell 7 is Microsoft&#8217;s cross-platform automation framework that runs natively on Linux, macOS, and Windows. Built on .NET, it brings a full-featured shell and scripting language to Linux systems, making it a solid choice for administrators managing hybrid environments across Azure, AWS, and on-premises infrastructure. This guide walks through installing PowerShell 7 on Ubuntu 24.04\/22.04 &#8230; <a title=\"Install PowerShell 7 on Ubuntu 24.04\/22.04 and Debian 13\/12\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/install-powershell-ubuntu-debian\/\" aria-label=\"Read more about Install PowerShell 7 on Ubuntu 24.04\/22.04 and Debian 13\/12\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":5298,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[712,26,299,50,81],"tags":[787,193,145,786,527],"class_list":["post-5295","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-desktop","category-debian","category-how-to","category-linux-tutorials","category-ubuntu","tag-microsoft","tag-os","tag-powershell","tag-shell","tag-windows"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/5295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=5295"}],"version-history":[{"count":2,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/5295\/revisions"}],"predecessor-version":[{"id":164147,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/5295\/revisions\/164147"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/5298"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=5295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=5295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=5295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}