파워쉘을 실행하기 위해서는 권한을 부여하여 주어야 한다. 기본적으로 script실행을 OS에서 비활성화 시켜 놓았다.(이것떄문에 많은 시간을 소비하였음)
Test-Path $profile
New-Item -Path $profile -type file -Force
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
Get-ChildItem D:\testFile1.txt | % {$_.LastWriteTime = '2005-11-01 06:01:36'}
Get-ChildItem D:\testFile1.txt | % {$_.LastWriteTime = (Get-Date)}