PowerShell์ Format-Table
๋ช
๋ น์ Microsoft Excel ์คํ๋ ๋์ํธ์ ๊ทผ๋ณธ์ ์ผ๋ก ์ ์ฌํ ๋ฐฉ์์ผ๋ก ๊ฐ์ฒด๋ฅผ ํ์ํฉ๋๋ค. Microsoft Excel์ ์คํ๋ ๋์ํธ ๋น๋๊ฐ ์
๋ด์ฉ์ ๊ฐ์ ๋ฐ๋ผ ์
์ ํ์ ํ์์ ๋ณ๊ฒฝํ ์ ์๋๋ก ํ๋ ์กฐ๊ฑด๋ถ ์์ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค.
PowerShell ์ฌ์ฉ์๊ฐ Format-Table
๋ช
๋ น์ ์ฌ์ฉํ์ฌ ๊ฐ์ฒด ์์ฑ์ ์กฐ๊ฑด๋ถ ์์ ๊ท์น์ ์ถ๊ฐํ ์ ์๋ค๋ฉด ์ ๋ง ์ข์ ๊ฒ์
๋๋ค. ๊ทธ๋ฐ ์์ผ๋ก Status
์์ฑ์ ๊ฐ์ง ๊ฐ์ฒด๊ฐ ์๋ค๊ณ ๊ฐ์ ํด ๋ณด๊ฒ ์ต๋๋ค. ๊ทธ ์์ฑ์ ๋ค์๊ณผ ๊ฐ์ด ๋ฐฉ์ถ ๋ ์๋ Green
๊ฐ์ด๋ฉด Success
๋๋ Red
์์ฑ ๊ฐ์ธ ๊ฒฝ์ฐ Failed
.
Name Status
---- ------
Step 1 Failed (Red)
Step 2 Success (Green)
์๋ฅผ ๋ค์ด ๋ค์๊ณผ ๊ฐ์ด Format-Table
๋ช
๋ น์ ์ฌ์ฉ์ ์ง์ ์์ฑ ์ง์ ์๋ฅผ ์ถ๊ฐํ ์ ์์ต๋๋ค.
Get-SomeObjects | Format-Table -Property Name, @{ Name = 'Status'; Color = 'Green'; Value = '^Success$' }
์ค๋๋ PowerShell์๋ "๊ณ์ฐ๋ ์์ฑ"์ ๋น๋ํ๊ธฐ ์ํ ์ ์ฌํ ๊ตฌ๋ฌธ์ด ์ด๋ฏธ ์์ต๋๋ค. ์ ์ฌํ ๊ตฌ๋ฌธ์ ํ์ฉํ์ฌ ๋ฐ์ดํฐ ํ ์ด๋ธ์ ์์์ด ์ง์ ๋ ํํ์์ ์์ฑํ ์ ์์ต๋๋ค. ์ด ๊ธฐ๋ฅ์ PowerShell ๊ธฐ๋ฐ ๋์๋ณด๋๋ฅผ ๊ตฌ์ถํ๊ณ ์ฝ์์์ ๋ณด๋ค ์ ์ฉํ ๋ฐฉ์์ผ๋ก ๋ฐ์ดํฐ๋ฅผ ํ์ํ๋ ๋ฐ ์ ์ฉํฉ๋๋ค.
๊ฑด๋ฐฐ,
ํธ๋ ๋ฒ ์ค๋ฆฌ๋ฐ
ํ์คํ ๋ฏธ๋์ ๊ฐ์ ์ฌํญ์ด์ง๋ง ์ด๊ฒ์ด ๊ต์ฅํ ๊ฒ์ด๋ผ๋ ๋ฐ ๋์ํฉ๋๋ค.
Format-Custom
, Format-List
๋ฐ Format-Wide
์ค๋ ์ด๊ฒ์ ์ํ๋ ์ฌ๋์ ์ํด Ahmad Adel Gad๋ TechNet์ Script Center์์ Write-PSObject
์๋ฃจ์
์ ์ ๊ณตํ์ต๋๋ค. https://gallery.technet.microsoft.com/scriptcenter/Format-Table-Colors-in-e0a4beac
์กฐ๊ฑด๋ถ ์์์ ์์ 16B.01์ ์ฐธ์กฐํ์ญ์์ค. Write-PSObject $servers -MatchMethod Exact -Column * -Value $false -ValueForeColor Red;
์ด CmdLet์์ ์ฌ์ฉํ ์ ์๋ ์ต์ ์ ๋ํด ์ ๋ง ์ข์ ์๊ฐ์ด ์์ผ๋ฏ๋ก ์ด ๊ฐ์ ์์ฒญ์๋ ์ข์ ์๊ฐ์ ์ค ์ ์์ต๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
Format-Custom
,Format-List
๋ฐFormat-Wide