Windows Powershell Commands
Check if profile exists
Test-Path $PROFILE
Create profile if it doesn't exist
New-Item -Type File -Path $PROFILE -Force
Edit the profile using notepad
notepad $PROFILE
Add a function to set java 25
function set-java-25 {
$env:JAVA_HOME = "C:\Users\windows\Tools\OpenJDK25U-jdk_x64_windows_hotspot_25.0.2_10\jdk-25.0.2+10"
$env:Path = $env:JAVA_HOME + "\bin;" + $env:Path
}
Add a function to set java 21
function set-java-21 {
$env:JAVA_HOME = "C:\Users\windows\Tools\OpenJDK21U-jdk_x64_windows_hotspot_21.0.10_7\jdk-21.0.10+7"
$env:Path = $env:JAVA_HOME + "\bin;" + $env:Path
}
Change the execution policy to execute user functions
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Reload the profile to test the user functions
. $PROFILE
Remove the profile if the user functions is no longer needed
Remove-Item $PROFILE