PowerShell/Functionの一覧および内容を表示する方法
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#navi(../)
* PowerShellのFunctionの一覧および内容を表示する方法 [#z7...
PowerShellの関数である、Functionの一覧を表示する方法を以...
使用したPowerShellのバージョンは、以下の通りです。
PS C:\> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 0 10586 63
#contents
#htmlinsertpcsp(win-top.html,win-sp.html)
* Functionの一覧および内容を表示する方法 [#tc1f044c]
以下の構文でFunctionの一覧を表示することができます。
Get-ChildItem -path function:
また、以下のように操作しても同様の結果となります。
Set-Location function:
Get-ChildItem
元に戻すときには、Cドライブであれば、c:と入力しEnterキー...
* Functionの内部(定義)を見る方法 [#ve162fa7]
以下のように操作すると、指定したFunctionのスクリプトを見...
** clear-host [#k1a18e4c]
PS C:\Users\Sakura> Get-Item function:clear-host
CommandType Name ...
----------- ---- ...
Function Clear-Host
PS C:\Users\Sakura> (Get-Item function:clear-host).Defin...
$space = New-Object System.Management.Automation.Host.Bu...
$space.Character = ' '
$space.ForegroundColor = $host.ui.rawui.ForegroundColor
$space.BackgroundColor = $host.ui.rawui.BackgroundColor
$rect = New-Object System.Management.Automation.Host.Rec...
$rect.Top = $rect.Bottom = $rect.Right = $rect.Left = -1
$origin = New-Object System.Management.Automation.Host.C...
$Host.UI.RawUI.CursorPosition = $origin
$Host.UI.RawUI.SetBufferContents($rect, $space)
# .Link
# http://go.microsoft.com/fwlink/?LinkID=225747
# .ExternalHelp System.Management.Automation.dll-help.xml
**prompt [#k125b064]
PS C:\Users\Sakura> Get-Item Function:\prompt
CommandType Name ...
----------- ---- ...
Function prompt
PS C:\Users\Sakura> (Get-Item Function:\prompt).Definition
"PS $($executionContext.SessionState.Path.CurrentLocatio...
# .Link
# http://go.microsoft.com/fwlink/?LinkID=225750
# .ExternalHelp System.Management.Automation.dll-help.xml
* 実際にFunctionを作って確認してみる [#o584c180]
以下のようにメッセージを引数として受け取り表示する関数を...
PS C:\Users\Sakura> Function SayHi($msg="") { Write-Outp...
PS C:\Users\Sakura> SayHi Sakura
Hi! Sakura
PS C:\Users\Sakura> Get-ChildItem Function:\SayHi
CommandType Name ...
----------- ---- ...
Function SayHi
PS C:\Users\Sakura> (Get-ChildItem Function:\SayHi).Defi...
param($msg="")
Write-Output "Hi! $msg"
以上、PowerShellのFunction一覧の表示および、Functionのス...
#htmlinsertpcsp(win-btm.html,win-sp.html)
終了行:
#navi(../)
* PowerShellのFunctionの一覧および内容を表示する方法 [#z7...
PowerShellの関数である、Functionの一覧を表示する方法を以...
使用したPowerShellのバージョンは、以下の通りです。
PS C:\> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 0 10586 63
#contents
#htmlinsertpcsp(win-top.html,win-sp.html)
* Functionの一覧および内容を表示する方法 [#tc1f044c]
以下の構文でFunctionの一覧を表示することができます。
Get-ChildItem -path function:
また、以下のように操作しても同様の結果となります。
Set-Location function:
Get-ChildItem
元に戻すときには、Cドライブであれば、c:と入力しEnterキー...
* Functionの内部(定義)を見る方法 [#ve162fa7]
以下のように操作すると、指定したFunctionのスクリプトを見...
** clear-host [#k1a18e4c]
PS C:\Users\Sakura> Get-Item function:clear-host
CommandType Name ...
----------- ---- ...
Function Clear-Host
PS C:\Users\Sakura> (Get-Item function:clear-host).Defin...
$space = New-Object System.Management.Automation.Host.Bu...
$space.Character = ' '
$space.ForegroundColor = $host.ui.rawui.ForegroundColor
$space.BackgroundColor = $host.ui.rawui.BackgroundColor
$rect = New-Object System.Management.Automation.Host.Rec...
$rect.Top = $rect.Bottom = $rect.Right = $rect.Left = -1
$origin = New-Object System.Management.Automation.Host.C...
$Host.UI.RawUI.CursorPosition = $origin
$Host.UI.RawUI.SetBufferContents($rect, $space)
# .Link
# http://go.microsoft.com/fwlink/?LinkID=225747
# .ExternalHelp System.Management.Automation.dll-help.xml
**prompt [#k125b064]
PS C:\Users\Sakura> Get-Item Function:\prompt
CommandType Name ...
----------- ---- ...
Function prompt
PS C:\Users\Sakura> (Get-Item Function:\prompt).Definition
"PS $($executionContext.SessionState.Path.CurrentLocatio...
# .Link
# http://go.microsoft.com/fwlink/?LinkID=225750
# .ExternalHelp System.Management.Automation.dll-help.xml
* 実際にFunctionを作って確認してみる [#o584c180]
以下のようにメッセージを引数として受け取り表示する関数を...
PS C:\Users\Sakura> Function SayHi($msg="") { Write-Outp...
PS C:\Users\Sakura> SayHi Sakura
Hi! Sakura
PS C:\Users\Sakura> Get-ChildItem Function:\SayHi
CommandType Name ...
----------- ---- ...
Function SayHi
PS C:\Users\Sakura> (Get-ChildItem Function:\SayHi).Defi...
param($msg="")
Write-Output "Hi! $msg"
以上、PowerShellのFunction一覧の表示および、Functionのス...
#htmlinsertpcsp(win-btm.html,win-sp.html)
ページ名: