사용자 도구

사이트 도구


windows:powershell

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
다음 판 양쪽 다음 판
windows:powershell [2018/05/18 08:54]
kwon37xi
windows:powershell [2018/09/04 10:36]
kwon37xi
줄 5: 줄 5:
   * [[https://mva.microsoft.com/en-us/training-courses/getting-started-with-powershell-3-0-jump-start-8276?l=r54IrOWy_2304984382|Microsoft PowerShell Tutorial & Training Course – Microsoft Virtual Academy]]   * [[https://mva.microsoft.com/en-us/training-courses/getting-started-with-powershell-3-0-jump-start-8276?l=r54IrOWy_2304984382|Microsoft PowerShell Tutorial & Training Course – Microsoft Virtual Academy]]
  
 +===== 기본 개인 profile 파일 =====
 +  * [[https://technet.microsoft.com/en-us/library/bb613488(v=vs.85).aspx|Understanding profile]]
 +  * ''$PROFILE'' 환경변수 값으로 프로필 파일 생성<code>
 +New-Item $profile -force -itemtype file
 +</code>
 +  * ''$Home\[My ]Documents\WindowsPowerShell\Profile.ps1''
 ===== Powershell Core ===== ===== Powershell Core =====
   * [[https://blogs.msdn.microsoft.com/powershell/2018/01/10/powershell-core-6-0-generally-available-ga-and-supported/|Powershell Core 6.0 GA Linux / MacOS X Support]]   * [[https://blogs.msdn.microsoft.com/powershell/2018/01/10/powershell-core-6-0-generally-available-ga-and-supported/|Powershell Core 6.0 GA Linux / MacOS X Support]]
   * Powershell Core는 Linux와 Mac 까지 지원한다.   * Powershell Core는 Linux와 Mac 까지 지원한다.
  
 +===== sudo =====
 +  * [[windows:sudo|Windows sudo]]
 +
 +===== Color ls =====
 +  * [[https://github.com/joonro/Get-ChildItemColor|Get-ChildItemColor]]
 +  * [[windows:powershell:gallery|PowerShell Gallary]] 로 설치
 +  * ''$Home\[My ]Documents\WindowsPowerShell\Profile.ps1''에 다음 추가하면 ''l'', ''ls''로 명령실행가능. 기존 명령은 ''dir''로 가능<code>
 +# for colored ls
 +Import-Module Get-ChildItemColor
 +
 +Set-Alias ls Get-ChildItemColor -option AllScope
 +Set-Alias ll Get-ChildItemColorFormatWide -option AllScope
 +</code>
  
 ===== 명령창 없이 명령 실행하기 ===== ===== 명령창 없이 명령 실행하기 =====
줄 20: 줄 39:
   * https://hodgkins.io/ultimate-powershell-prompt-and-git-setup   * https://hodgkins.io/ultimate-powershell-prompt-and-git-setup
  
 +===== process 목록 =====
 +<code sh>
 +ps *foo*
 +get-process | findstr foo
 +get-process | where ProcessName -like "*foo*"
 +</code>
 +
 +===== 환경변수 Environment Variable =====
 +  * [[https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-6|about_Environment_Variables | Microsoft Docs]]
 +<code>
 +#값 읽기
 +$Env:<variable-name>
 +$Env:PATH
 +
 +# 값 지정
 +$Env:<variable-name> = "<new-value>"
 +
 +$Env:path = $env:path + ";c:\temp"
 +Set-Item -Path Env:Path -Value ($Env:Path + ";C:\Temp")
 +
 +# 환경변수 목록
 +Get-ChildItem Env:
 +</code>
 +
 +===== 기본명령 =====
 +  * 디렉토리 삭제<code>
 +Remove-Item [dirname] -Force
 +</code>
 +  * Symoblic Link<code>
 +# 관리자 권한 필요
 +New-Item -ItemType SymbolicLink -Name MySymLinkFile.txt -Target $pshome\profile.ps1
 +New-Item -ItemType SymbolicLink -Path C:\Temp\MySymLinkFile.txt -Value $pshome\profile.ps1
 +</code>
 +  * grep 대체 [[https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/select-string?view=powershell-6|Select-String]]<code>
 +# 문자열 filter
 +"Hello","HELLO" | Select-String -Pattern "HELLO" -CaseSensitive
 +# *.xml 파일들에서 문자열 탐색
 +Select-String -Path "*.xml" -Pattern "the the"
 +
 +# 매칭이 안되는 부분 찾기
 +Select-String -Path "process.txt" -Pattern "idle, svchost" -NotMatch
 +</code>
 +  * rename - [[https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/rename-item?view=powershell-6|Rename-Item]]<code>
 +Rename-Item -Path old_name -NewName new_name [-Force]
 +</code>
 +===== curl =====
 +  * [[linux:curl|Curl]] 을 사용하려면 ''cinst curl''로 설치하고
 +  * ''$profile'' 파일에 PowerShell에 자체 ''curl'' alias를 지워야 실제 ''curl'' 명령이 실행된다.<code>
 +remove-item alias:curl
 +</code>
 +
 +===== wget =====
 +  * ''wget'' 명령은 ''Invoke-WebRequest''의 alias 이다. [[https://superuser.com/questions/362152/native-alternative-to-wget-in-windows-powershell|Native alternative to wget in Windows PowerShell?]]
 +
 +<code sh>
 +wget http://blog.stackexchange.com/ -OutFile out.html
 +</code>
 +
 +===== alias =====
 +<code>
 +# vi 를 vim.exe 실행하는 것으로 alias 걸기
 +set-alias -name vi -value vim.exe
 +</code>
 ===== 참조 ===== ===== 참조 =====
   * [[https://gist.github.com/jchandra74/5b0c94385175c7a8d1cb39bc5157365e|PowerShell, Cmder / ConEmu, Posh-Git, Oh-My-Posh, Powerline Customization]]   * [[https://gist.github.com/jchandra74/5b0c94385175c7a8d1cb39bc5157365e|PowerShell, Cmder / ConEmu, Posh-Git, Oh-My-Posh, Powerline Customization]]
  
windows/powershell.txt · 마지막으로 수정됨: 2024/03/05 13:00 저자 kwon37xi