사용자 도구

사이트 도구


windows:powershell

PowerShell

파워쉘을 실행하기 위해서는 권한을 부여하여 주어야 한다. 기본적으로 script실행을 OS에서 비활성화 시켜 놓았다.(이것떄문에 많은 시간을 소비하였음)

Profile

Profile이 존재하는지 확인

Test-Path $profile
  1. True : 존재
  2. False : 미존재

프로파일을 생성하려면

New-Item -Path $profile -type file -Force

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 파일 종류들을 확인하려면…

$PROFILE | Format-List * -Force
$profile | select * # 위의 명력과 동일하게 실행됨
-- 결과 실행 순서별
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

무슨실행권한을 관리하는 가? 어차피 실행할 수 있게 만들 것이면서

Get-ExecutionPolicy -List
Set-ExecutionPolicy RemoteSigned

Touch 기능

Get-ChildItem  D:\testFile1.txt | % {$_.LastWriteTime = '2005-11-01 06:01:36'}
Get-ChildItem  D:\testFile1.txt | % {$_.LastWriteTime = (Get-Date)}
windows/powershell.txt · 마지막으로 수정됨: 2025/04/15 10:05 저자 127.0.0.1