If you want to set an Environment Variable in PowerShell for Mac, you can make use of the $env automatic variable or by making use of the Set-Item cmdlet.
Let's take a look at both ways with an example each.
Example 1: Set Environment Variable Using $env automatic variable
$env:SERVER_NAME = "Production"

Example 2: Set Environment Variable Using Set-Item cmdlet
PS /> SET-Item -Path Env:VERSION -Value "3.5"
PS /> GET-Item Env:VERSION
Name Value
---- -----
VERSION 3.5

-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to Powershell,
- PowerShell: How to Check if a Module is Already Installed
- PowerShell: How to Write Output to a File
- PowerShell: Steps to Connect to connect to Exchange Online
- PowerShell Fix: Get-Help cannot find the Help files for this cmdlet on this computer
- PowerShell Traditional For Loop Example
- How to Run PowerShell Script as Administrator (Elevate)
- Update Powershell Using Command Line
- How to delete a file using PowerShell [Windows/macOS]
- PowerShell: Grep Command Alternative - Select-String
- PowerShell Concatenate String Examples
- How to add Sleep to PowerShell Script
- Connect Azure AD (Active Directory) for PowerShell
- How to Open PowerShell on Mac?
- List of PowerShell Function Commands for Mac
- How to Connect to Azure AD Account using PowerShell on Mac
- Download Google Chrome setup exe file using PowerShell
- Set Environment Variable in PowerShell for Mac
- How to switch to Powershell on Mac Terminal
- How to add sleep in Powershell Script
- PowerShell on Mac: The term get-service is not recognized as a name of a cmdlet, function, script file, or executable program
- How to Identify installed PowerShell version
- How to check PowerShell version
- How to install PowerShell on Mac using Brew
- PowerShell Switch Statement with Examples
- PowerShell ISE Alternative for Mac
More Posts:
- SharePoint error 2130575251 - The security validation for this page is invalid and might be corrupted - SharePoint
- How to install and Configure sar sysstat tools in Ubuntu Linux - Linux
- Java 8 Display time in 12 hour AM PM format - Java
- Java equals method - Tutorial - Java
- Accept Only 0-9 Numbers RegEx Example - HowTos
- How to Save Eclipse console logs in external log file - Eclipse
- How to escape HTML characters in Java - Java
- How to check if Key Exists in Python Dictionary? - Python