사용자 도구

사이트 도구


windows:powershell

차이

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

차이 보기로 링크

양쪽 이전 판이전 판
다음 판
이전 판
windows:powershell [2024/02/10 10:47] – [두번째, 현재 로그온 한 사용자에게 적용되는 프로파일인 다음 파일들이 순서대로 실행된다.] taekguwindows:powershell [2025/04/15 10:05] (현재) – 바깥 편집 127.0.0.1
줄 1: 줄 1:
 +====== PowerShell ======
 +파워쉘을 실행하기 위해서는 권한을 부여하여 주어야 한다.
 +기본적으로 script실행을 OS에서 비활성화 시켜 놓았다.(이것떄문에 많은 시간을 소비하였음)
  
 +===== Profile =====
 +==== Profile이 존재하는지 확인 ====
 +
 +<code sh>
 +Test-Path $profile
 +</code>
 +  - True : 존재
 +  - False : 미존재
 +==== 프로파일을 생성하려면 ====
 +
 +<code sh>
 +New-Item -Path $profile -type file -Force
 +</code>
 +
 +===== Powershell Console 을 실행하면 어떤 Profile 파일이 순서적으로 자동으로 실행되는가? =====
 +
 +
 +==== 첫 번째, 모든 사용자에게 적용되는 프로파일인 다음 파일들이 순서대로 실행된다. ====
 +
 +1) $PROFILE.AllUsersAllHosts (Profile.ps1)
 +2) $PROFILE.AllUsersCurrentHost (Microsoft.PowerShell_profile.ps1)
 +
 +==== 두번째, 현재 로그온 한 사용자에게 적용되는 프로파일인 다음 파일들이 순서대로 실행된다. ====
 +
 +3) $PROFILE.CurrentUserAllHosts (Profile.ps1)
 +4) $PROFILE.CurrentUserCurrentHost (Microsoft.PowerShell_profile.ps1)
 +
 +그러므로 이 컴퓨터를 사용하는 모든 사용자에게 동일한 설정을 부여하기 위해서는 경로가 정해져 있는 C:\Windows\System32\WindowsPowershell\v1.0\ 2개의 파일(Microsoft.PowerShell_profile.ps1, Profile.ps1)을 수정하면 된다. 이 중에서 하나만 수정하여 사용해도 된다.
 +
 +Profile 파일 종류들을 확인하려면…
 +<code sh>
 +$PROFILE | Format-List * -Force
 +$profile | select * # 위의 명력과 동일하게 실행됨
 +</code>
 +
 +<code sh>
 +-- 결과 실행 순서별
 +AllUsersAllHosts       : C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
 +AllUsersCurrentHost    : C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1
 +CurrentUserAllHosts    : C:\Users\xxxxx\OneDrive\문서\WindowsPowerShell\profile.ps1
 +CurrentUserCurrentHost : C:\Users\xxxxx\OneDrive\문서\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
 +Length                 : 77
 +</code>
 +
 +무슨실행권한을 관리하는 가?
 +어차피 실행할 수 있게 만들 것이면서
 +<code sh>
 +Get-ExecutionPolicy -List
 +Set-ExecutionPolicy RemoteSigned
 +</code>
 +
 +
 +===== Touch 기능 =====
 +<code sh>
 +Get-ChildItem  D:\testFile1.txt | % {$_.LastWriteTime = '2005-11-01 06:01:36'}
 +Get-ChildItem  D:\testFile1.txt | % {$_.LastWriteTime = (Get-Date)}
 +</code>