Software Architect IT 개발 knowhow, tip & tech Current: Windows Powershell Tip & Howto Windows Powershell Tip & Howto 파워쉘 유용한 명령어 정리. 모두 파워쉘 프롬프트에서 실행 필요 power shell 명령 종료 상태 값(command exit status) 확인 powershell 을 command line 에서 실행할 때 "'<' 연산자는 나중에 사용하도록 예약되어 있습니다". 에러 Network drive 로그인 정보 확인https://stackoverflow.com/questions/9037503/determine-domain-and-username-used-to-map-a-network-drive gwmi -Query 'Select LocalName, RemoteName, UserName from Win32_NetworkConnection' CODE 환경 변수 사용 환경 변수 출력echo 나 print 를 사용하지 않고 출력할 환경 변수 값(Ex: Path 일 경우 $env:Path) 을 적어줌. $env:Path ;C:\Python38\Scripts\;C:\Python38\;C:\Program Files (x86)... POWERSHELL 모든 환경 변수 목록 출력 Get-ChildItem env: Name Value ---- ----- ALLUSERSPROFILE C:\ProgramData APPDATA C:\Users\lesstif\AppData\Roaming ChocolateyInstall C:\ProgramData\chocolatey HOME C:\Users\lesstif ... USERPROFILE C:\Users\lesstif windir C:\WINDOWS ... POWERSHELL PATH 환경 변수 처리PATH 변수 변경bash 의 PATH 에 새로운 경로를 추가하는 것과 비슷한 문법 export PATH=/add/some/path/:$PATH CODE powershell 은 SET 으로 환경 변수를 설정하지 않고 $env: 밑에 설정할 변수명을 바로 지정.아래는 PHP 를 PATH 의 맨 앞에 추가. $env:Path="C:\devel\php\php-7.3.14-nts-Win32-VC15-x64\;" + $env:Path POWERSHELL 맨 뒤에 추가할 경우 += 연산자로 string concatenation 처리 $env:Path += ";C:\devel\php\php-7.3.14-nts-Win32-VC15-x64" POWERSHELL 시스템 PATH 변수 다시 읽기console - Reload the path in PowerShell - Stack Overflow"고급 시스템 설정 보기" 에서 PATH 환경 변수를 바꿨을 경우 terminal 을 종료하지 않고 반영하기 $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") POWERSHELL 함수로 만들면 더욱 편함 ${function:reload-path} = { $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") } POWERSHELL windows-cmd powershell ×