Skip to content

jhonnyelhelou91/EnvironmentVariables

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Environment Helpers

PowerShell Helper scripts to add/update/remove environment helpers for aspnet core, repositories, custom variables.

Getting Started

  • 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

Adding Script to Profile [Optional]

  • 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

Examples

Set-Repository-EnvVariable Examples

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-AspNetCore-EnvVariable Examples

Set the ASPNETCORE_ENVIRONMENT environment variable.

Set to default

Set-AspNetCore-EnvVariable

Specify value

Set-AspNetCore-EnvVariable -Value 'Production'

Set-EnvVariable Examples

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-BuildPath-EnvVariable Examples

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'

About

PowerShell Helper scripts to manage environment variables

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published