목차

Windows Powershell

기본 개인 profile 파일

Powershell Core

sudo

Color ls

명령창 없이 명령 실행하기

powershell start-process '원하는명령(혹은 .bat)' -WindowStyle Hidden

Consoles

process 목록

ps *foo*
get-process | findstr foo
get-process | where ProcessName -like "*foo*"

환경변수 Environment Variable

#값 읽기
$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:

기본명령

curl

wget

wget http://blog.stackexchange.com/ -OutFile out.html

Powershell script from remote

Invoke-WebRequest -Uri https://raw.githubusercontent.com/thomasmaurer/demo-cloudshell/master/helloworld.ps1 -OutFile .\helloworld.ps1; .\helloworld.ps1 
# Created by Daniel Jean Schmidt
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
 
$Script = Invoke-RestMethod https://api.github.com/repos/Twikki/youtubetest/contents/Download_Files.ps1?access_token=yourtokenhere -Headers @{”Accept”= “application/vnd.github.v3.raw”}
 
Invoke-Expression $Script
# script 주소는 올바르게 변경할 것.
$ScriptFromGitHub = Invoke-WebRequest https://raw.githubusercontent.com/tomarbuthnot/Run-PowerShell-Directly-From-GitHub/master/Run-FromGitHub-SamplePowerShell.ps1
Invoke-Expression $($ScriptFromGitHub.Content)

tail

마지막 1000 줄 보여주면서 계속 출력하기

Get-Content 파일경로 -Wait -Tail 1000

alias

# vi 를 vim.exe 실행하는 것으로 alias 걸기
set-alias -name vi -value vim.exe

Timezone

Set-TimeZone -Id "Korea Standard Time"

언어 변경

# 가능할수도? 테스트 필요.
Get-WindowsCapability -Online | ? Name -like '*ko*' # 한국어 관련 목록 버전을 정확히 확인해야함.

Add-WindowsCapability -Online -Name 'Language.Basic~~~ko-KR~0.0.1.0'
Add-WindowsCapability -Online -Name 'Lnaguage.Fonts.Kore~~~und-KORE~0.0.1.0'
Set-WinUILanguageOverride -Language ko-KR
Set-WinSystemLocale -SystemLocale ko-KR # 재부팅 후 적용

Location 변경

Set-WinHomeLocation -GeoId 0x86

Reboot

Restart-Computer

Linux PowerShell

참조