CLI
Refresh environment variables without reboot windows
- open cmd commend prompt window
- input: set PATH=C -> this will refresh the environment variables
- close and restart cmd window
- input: echo %PATH% to test
- can use setx command to set variable permanentlyFind current loggged-on user
Get-ADuser $(quser /server:$servername | ForEach-Object { ($_ -replace '^\s+|\s+$','') -split '\s{2,}' | Select-Object -First 1 } | select-object -last 1)
# If there's multiple users
quser /server:$servername | ForEach-Object { ($_ -replace '^\s+|\s+$','') -split '\s{2,}' | Select-Object -First 1 } | Where-Object {$_ -notmatch 'USERNAME'} | foreach-object {get-aduser $_}
# Explanation of the replace part:
ForEach-Object {
($_ -replace '^\s+|\s+$','') # Step 1: Trim leading/trailing whitespace
-split '\s{2,}' # Step 2: Split the cleaned line by 2+ spaces
| Select-Object -First 1 # Step 3: Select the first token (usually the username)
}Find User accoung using Full Name
List member of AD Group
Last updated