差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
windows:powershell [2019/08/19 06:57] – ともやん | windows:powershell [2023/10/06 14:49] (現在) – [インストール] ともやん | ||
---|---|---|---|
行 1: | 行 1: | ||
- | < | + | ====== PowerShell(Windows) |
- | < | + | [[linux: |
- | #result pre { | + | \\ |
- | height: 200px; | + | |
- | overflow: scroll; | + | |
- | overflow-x: hidden; | + | |
- | } | + | |
- | </ | + | |
- | </ | + | |
- | ====== PowerShell ====== | + | |
本家: [[https:// | 本家: [[https:// | ||
ソースコード: | ソースコード: | ||
- | \\ | + | < |
- | {{:windows:powershell.png?600|PowerShell}}\\ | + | function curlGet($url) { |
+ | $curl = curl_init(); | ||
+ | |||
+ | curl_setopt($curl, | ||
+ | curl_setopt($curl, | ||
+ | curl_setopt($curl, | ||
+ | curl_setopt($curl, | ||
+ | |||
+ | $response = curl_exec($curl); | ||
+ | curl_close($curl); | ||
+ | |||
+ | return $response; | ||
+ | } | ||
+ | |||
+ | //$url = ' | ||
+ | $url = ' | ||
+ | //$res = curlGet($url); | ||
+ | //$tags = json_decode($res, | ||
+ | //$lines = explode(" | ||
+ | |||
+ | /* | ||
+ | $dom = new DOMDocument; | ||
+ | @$dom-> | ||
+ | $xpath = new DOMXPath($dom); | ||
+ | $xpath = $xpath-> | ||
+ | var_dump($xpath); | ||
+ | $html = array_map( | ||
+ | function ($node) use ($xpath) { | ||
+ | return [ | ||
+ | ' | ||
+ | ]; | ||
+ | }, $xpath-> | ||
+ | var_dump($html); | ||
+ | */ | ||
+ | echo ' | ||
+ | </ | ||
+ | |||
+ | {{windows:powershell_v7.3.6.png?470|PowerShell}}\\ | ||
**PowerShell** (パワーシェル)は、マイクロソフトが開発した拡張可能なコマンドラインインターフェース (CLI) シェルおよびスクリプト言語である。オブジェクト指向に基づいて設計されており、.NET Frameworkと.NET Coreを基盤としている。\\ | **PowerShell** (パワーシェル)は、マイクロソフトが開発した拡張可能なコマンドラインインターフェース (CLI) シェルおよびスクリプト言語である。オブジェクト指向に基づいて設計されており、.NET Frameworkと.NET Coreを基盤としている。\\ | ||
- | \\ | + | |
かつては Microsoft Shell (MSH、コードネーム Monad) と呼ばれていた。\\ | かつては Microsoft Shell (MSH、コードネーム Monad) と呼ばれていた。\\ | ||
- | \\ | + | |
Windows 7 以降のオペレーティングシステム (OS) には標準で搭載されている。\\ | Windows 7 以降のオペレーティングシステム (OS) には標準で搭載されている。\\ | ||
- | \\ | + | |
+ | ===== インストール ===== | ||
+ | [[windows: | ||
+ | |||
+ | dorado バケットを追加する😉\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | PS > <b class=HIY> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | Checking repo... ok | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | **PowerShell** のインストール\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | PS > <b class=HIY> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | Installing ' | ||
+ | PowerShell-7.3.6-win-x64.zip (102.9 MB) [=====================================================================] 100% | ||
+ | Checking hash of <b class=CYN> | ||
+ | Extracting <b class=CYN> | ||
+ | Linking ~\scoop\apps\powershell\current => ~\scoop\apps\powershell\7.3.6 | ||
+ | Creating shim for ' | ||
+ | Creating shortcut for PowerShell (pwsh.exe) | ||
+ | <b class=GRN>' | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | **PowerShell** のグローバルインストール\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | PS > <b class=HIY> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | Installing ' | ||
+ | PowerShell-7.0.0-win-x64.zip (88.7 MB) [======================================================================] 100% | ||
+ | Checking hash of <b class=CYN> | ||
+ | Extracting <b class=CYN> | ||
+ | Linking C: | ||
+ | Creating shim for ' | ||
+ | Creating shortcut for PowerShell (pwsh.exe) | ||
+ | <b class=GRN>' | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | **PowerShell(Preview版)** のインストール\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | PS > <b class=HIY> | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | Installing ' | ||
+ | PowerShell-7.0.0-rc.3-win-x64.zip (88.8 MB) [=================================================================] 100% | ||
+ | Checking hash of <b class=CYN> | ||
+ | Extracting <b class=CYN> | ||
+ | Linking ~\scoop\apps\powershell-preview\current => ~\scoop\apps\powershell-preview\7.0.0-rc.3 | ||
+ | Creating shim for ' | ||
+ | WARN Overwriting shim to pwsh.exe installed from powershell | ||
+ | Creating shortcut for PowerShell Preview (pwsh.exe) | ||
+ | <b class=GRN>' | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== ダウンロード ===== | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | |||
+ | ===== 変数 ===== | ||
+ | [[.powershell: | ||
+ | |||
+ | ===== コマンド ===== | ||
+ | [[.powershell: | ||
+ | [[.powershell: | ||
+ | [[.powershell: | ||
+ | [[.powershell: | ||
+ | [[.powershell: | ||
+ | |||
+ | ===== コマンド履歴 ===== | ||
+ | <code powershell> | ||
+ | $ less (Get-PSReadlineOption).HistorySavePath | ||
+ | </ | ||
+ | |||
+ | <code powershell> | ||
+ | $ cat (Get-PSReadlineOption).HistorySavePath | grep "scoop search" | ||
+ | </ | ||
+ | |||
+ | ===== PowerShellGet ===== | ||
+ | [[https:// | ||
+ | PowerShell ギャラリー | ||
+ | |||
+ | PowerShellGet をインストールするには、以下のコマンドを実行する。\\ | ||
+ | < | ||
+ | $ sudo Install-Module -Name PowerShellGet -Force | ||
+ | </ | ||
+ | PowerShellGet を新しいバージョンに更新するには、以下のコマンドを実行する。\\ | ||
+ | < | ||
+ | $ sudo Update-Module -Name PowerShellGet | ||
+ | </ | ||
+ | |||
+ | **参考文献**\\ | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | |||
+ | ===== Powershell のテーマ設定 ===== | ||
+ | 現在のコンソール設定をバックアップする。\\ | ||
+ | < | ||
+ | $ concfg export console-backup.json | ||
+ | </ | ||
+ | <WRAP prewrap 100% # | ||
+ | < | ||
+ | console settings exported to console-backup.json | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ソラリゼーションカラーテーマを使用する。\\ | ||
+ | < | ||
+ | $ concfg import solarized-dark | ||
+ | </ | ||
+ | <WRAP prewrap 100% # | ||
+ | < | ||
+ | Console settings were imported from ' | ||
+ | Overrides in the registry and shortcut files might interfere with your concfg settings. Would you like to find and remove them? (Y/n): y <- 入力する | ||
+ | Removing ' | ||
+ | Removing ' | ||
+ | Reset console properties of shortcut ' | ||
+ | Reset console properties of shortcut ' | ||
+ | |||
+ | Would you like to open a new console to see the changes? (Y/n): n <- 入力する | ||
+ | </ | ||
+ | |||
+ | 上記の翻訳\\ | ||
+ | < | ||
+ | Overrides in the registry and shortcut files might interfere with your concfg settings. Would you like to find and remove them? | ||
+ | </ | ||
+ | < | ||
+ | レジストリファイルおよびショートカットファイルのオーバーライドは、concfg設定に干渉する可能性があります。それらを見つけて削除しますか? | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | Would you like to open a new console to see the changes? | ||
+ | </ | ||
+ | < | ||
+ | 変更を確認するために新しいコンソールを開きますか? | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ==== 参考文献 ==== | ||
+ | [[https:// | ||
===== PowerShell のバージョン ===== | ===== PowerShell のバージョン ===== | ||
行 25: | 行 212: | ||
Name : ConsoleHost | Name : ConsoleHost | ||
- | Version | + | Version |
- | InstanceId | + | InstanceId |
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface | UI : System.Management.Automation.Internal.Host.InternalHostUserInterface | ||
CurrentCulture | CurrentCulture | ||
行 34: | 行 221: | ||
IsRunspacePushed : False | IsRunspacePushed : False | ||
Runspace | Runspace | ||
+ | |||
+ | PS > Get-Host | Select-Object Version | ||
+ | |||
+ | Version | ||
+ | ------- | ||
+ | 6.2.4 | ||
PS > $PSVersiontable | PS > $PSVersiontable | ||
行 39: | 行 232: | ||
Name Value | Name Value | ||
---- ----- | ---- ----- | ||
- | PSVersion | + | PSVersion |
- | PSEdition | + | PSEdition |
- | PSCompatibleVersions | + | GitCommitId |
- | BuildVersion | + | OS |
- | CLRVersion | + | Platform |
- | WSManStackVersion | + | PSCompatibleVersions |
PSRemotingProtocolVersion | PSRemotingProtocolVersion | ||
SerializationVersion | SerializationVersion | ||
+ | WSManStackVersion | ||
+ | |||
</ | </ | ||
行 52: | 行 247: | ||
<code powershell> | <code powershell> | ||
PS > start-process notepad c: | PS > start-process notepad c: | ||
+ | </ | ||
+ | |||
+ | ===== カレントディレクトリ変更 ===== | ||
+ | <code powershell> | ||
+ | PS C: | ||
+ | PS C: | ||
+ | |||
+ | Path | ||
+ | ---- | ||
+ | C: | ||
</ | </ | ||
行 62: | 行 267: | ||
===== 参考文献 ===== | ===== 参考文献 ===== | ||
[[http:// | [[http:// | ||
- | [[https:// | + | [[git>PowerShell/ |
+ | |||
+ | [[https:// | ||
+ | |||
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | |||
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[git> | ||
+ | [[https:// | ||