PowerShell Helper scripts to add/update/remove environment helpers for aspnet core, repositories, custom variables.
- Copy the files
- Open Command Line or PowerShell (Window + X, A)
- If you opened Command Prompt, then type powershell in order to use PowerShell commands
- Navigate to the scripts directory
cd your_directory
- Type
Import-Module .\EnvironmentVariables.psm1
- Now you can use the methods from your PowerShell session
- Enable execution policy using PowerShell Admin
Set-ExecutionPolicy Unrestricted
- Navigate to the profile path
cd (Split-Path -parent $PROFILE)
- Open the location in Explorer
ii .
- Create the user profile if it does not exist
If (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
- Import the module in the PowerShell profile
Import-Module -Path script_directory -ErrorAction SilentlyContinue
Adds Repository details to user environment variables.
Prompt for details
Set-Repository-EnvVariable
Specify details
Set-Repository-EnvVariable -Name 'RepositoryName' -RemoteUrl 'https://github.com/jhonnyelhelou91/EnvironmentVariables.git' -LocalPath 'C:\git\PowerShell\EnvironmentHelpers\'
Set the ASPNETCORE_ENVIRONMENT environment variable.
Set to default
Set-AspNetCore-EnvVariable
Specify value
Set-AspNetCore-EnvVariable -Value 'Production'
Create or Update environment variable.
Prompt for details
Set-EnvVariable -Name 'MyVariable' -Prompt $true
Add Environment Variable with *name* and *value* for *current user*
Set-EnvVariable -Name 'MyVariable' -Value 'MyValue'
Add Environment Variable with *name* and *value* for *current machine*
Set-EnvVariable -Name 'MyVariable' -Value 'MyValue' -Target 'Machine'
Add Environment Variable with *name* and *value* for *current process*
Set-EnvVariable -Name 'MyVariable' -Value 'MyValue' -Target 'Process'
Set the Dev.MSBuildPath environment variable.
Set to default (Path for Build Tools 2017)
Set-BuildPath-EnvVariable
Specify value
Set-BuildPath-EnvVariable -Value 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe'