windows:powershell

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
windows:powershell [2019/08/19 06:57] ともやんwindows:powershell [2023/10/06 14:49] (現在) – [インストール] ともやん
行 1: 行 1:
-<html> +====== PowerShell(Windows) ====== 
-  <style> +[[linux:powershell|PowerShell - Linux]]\\ 
-    #result pre { +\\
-      height: 200px; +
-      overflow: scroll; +
-      overflow-x: hidden; +
-    } +
-  </style> +
-</html> +
-====== PowerShell ======+
 本家: [[https://docs.microsoft.com/ja-jp/powershell/|PowerShell Documentation | Microsoft Docs]]\\ 本家: [[https://docs.microsoft.com/ja-jp/powershell/|PowerShell Documentation | Microsoft Docs]]\\
 ソースコード: [[https://github.com/PowerShell/PowerShell|GitHub - PowerShell/PowerShell: PowerShell for every system!]]\\ ソースコード: [[https://github.com/PowerShell/PowerShell|GitHub - PowerShell/PowerShell: PowerShell for every system!]]\\
-\\ +<php> 
-{{:windows:powershell.png?600|PowerShell}}\\+function curlGet($url) { 
 +  $curl = curl_init(); 
 +   
 +  curl_setopt($curl, CURLOPT_URL, $url); 
 +  curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET'); 
 +  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 証明書の検証を行わない 
 +  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);  // curl_execの結果を文字列で返す 
 +   
 +  $response = curl_exec($curl); 
 +  curl_close($curl); 
 +   
 +  return $response; 
 +
 + 
 +//$url = 'https://api.github.com/repos/PowerShell/PowerShell/tags'; 
 +$url = 'https://github.com/PowerShell/PowerShell/releases'; 
 +//$res = curlGet($url); 
 +//$tags = json_decode($res, $assoc=TRUE); 
 +//$lines = explode("\n", $res); 
 + 
 +/* 
 +$dom = new DOMDocument; 
 +@$dom->loadHTMLFile($url); 
 +$xpath = new DOMXPath($dom); 
 +$xpath = $xpath->query('//div[contains(@class, "release-entry")]'); 
 +var_dump($xpath); 
 +$html = array_map( 
 +    function ($node) use ($xpath) { 
 +        return [ 
 +            'html' => $xpath->saveHTML($node) 
 +        ]; 
 +    }, $xpath->query('//span[@class="css-truncate-target"]')); 
 +var_dump($html); 
 +*/ 
 +echo '最新バージョン: v7.3.6'.$lines[0]; 
 +</php>\\ 
 + 
 +{{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:scoop|Scoop]] によるインストール\\ 
 + 
 +dorado バケットを追加する😉\\ 
 +<WRAP color_term> 
 +<WRAP color_command><html><pre> 
 +PS > <b class=HIY>scoop</b> bucket add dorado https://github.com/chawyehsu/dorado 
 +</pre></html></WRAP> 
 +<WRAP color_result><html><pre> 
 +Checking repo... ok 
 +<b class=GRN>The dorado bucket was added successfully.</b> 
 +</pre></html></WRAP> 
 +</WRAP> 
 + 
 +**PowerShell** のインストール\\ 
 +<WRAP color_term> 
 +<WRAP color_command><html><pre> 
 +PS > <b class=HIY>scoop</b> install powershell 
 +</pre></html></WRAP> 
 +<WRAP color_result><html><pre> 
 +Installing 'powershell' (7.3.6) [64bit] 
 +PowerShell-7.3.6-win-x64.zip (102.9 MB) [=====================================================================] 100% 
 +Checking hash of <b class=CYN>PowerShell-7.3.6-win-x64.zip</b> ... <b class=GRN>ok.</b> 
 +Extracting <b class=CYN>PowerShell-7.3.6-win-x64.zip</b> ... <b class=GRN>done.</b> 
 +Linking ~\scoop\apps\powershell\current => ~\scoop\apps\powershell\7.3.6 
 +Creating shim for 'pwsh'
 +Creating shortcut for PowerShell (pwsh.exe) 
 +<b class=GRN>'powershell' (7.3.6) was installed successfully!</b> 
 +</pre></html></WRAP> 
 +</WRAP> 
 + 
 +**PowerShell** のグローバルインストール\\ 
 +<WRAP color_term> 
 +<WRAP color_command><html><pre> 
 +PS > <b class=HIY>sudo</b> scoop install -g powershell 
 +</pre></html></WRAP> 
 +<WRAP color_result><html><pre> 
 +Installing 'powershell' (7.0.0) [64bit] 
 +PowerShell-7.0.0-win-x64.zip (88.7 MB) [======================================================================] 100% 
 +Checking hash of <b class=CYN>PowerShell-7.0.0-win-x64.zip</b> ... <b class=GRN>ok.</b> 
 +Extracting <b class=CYN>PowerShell-7.0.0-win-x64.zip</b> ... <b class=GRN>done.</b> 
 +Linking C:\ProgramData\scoop\apps\powershell\current => C:\ProgramData\scoop\apps\powershell\7.0.0 
 +Creating shim for 'pwsh'
 +Creating shortcut for PowerShell (pwsh.exe) 
 +<b class=GRN>'powershell' (7.0.0) was installed successfully!</b> 
 +</pre></html></WRAP> 
 +</WRAP> 
 + 
 +**PowerShell(Preview版)** のインストール\\ 
 +<WRAP color_term> 
 +<WRAP color_command><html><pre> 
 +PS > <b class=HIY>scoop</b> install powershell-preview 
 +</code> 
 +</pre></html></WRAP> 
 +<WRAP color_result><html><pre> 
 +Installing 'powershell-preview' (7.0.0-rc.3) [64bit] 
 +PowerShell-7.0.0-rc.3-win-x64.zip (88.8 MB) [=================================================================] 100% 
 +Checking hash of <b class=CYN>PowerShell-7.0.0-rc.3-win-x64.zip</b> ... <b class=GRN>ok.</b> 
 +Extracting <b class=CYN>PowerShell-7.0.0-rc.3-win-x64.zip</b> ... <b class=GRN>done.</b> 
 +Linking ~\scoop\apps\powershell-preview\current => ~\scoop\apps\powershell-preview\7.0.0-rc.3 
 +Creating shim for 'pwsh'
 +WARN  Overwriting shim to pwsh.exe installed from powershell 
 +Creating shortcut for PowerShell Preview (pwsh.exe) 
 +<b class=GRN>'powershell-preview' (7.0.0-rc.3) was installed successfully!</b> 
 +</pre></html></WRAP> 
 +</WRAP> 
 + 
 +===== ダウンロード ===== 
 +[[https://github.com/PowerShell/PowerShell/releases|Releases · PowerShell/PowerShell]]\\ 
 +[[https://aka.ms/pscore6|]]\\ 
 +[[https://aka.ms/pscore6-docs|]]\\ 
 +[[https://aka.ms/PowerShell-Release?tag=v7.0.0|]]\\ 
 +[[https://github.com/PowerShell/PowerShell/releases/tag/v7.0.0-rc.1|Releases · PowerShell/PowerShell - Release Candidate 1]]\\ 
 +[[https://github.com/PowerShell/PowerShell/releases/tag/v7.0.0-rc.2|Releases · PowerShell/PowerShell - Release Candidate 2]]\\ 
 +[[https://github.com/PowerShell/PowerShell/releases/tag/v7.0.0-rc.3|Releases · PowerShell/PowerShell - Release Candidate 3]]\\ 
 + 
 +===== 変数 ===== 
 +[[.powershell:variable|環境変数/自動変数/ユーザ定義変数]]\\ 
 + 
 +===== コマンド ===== 
 +[[.powershell:commands|PowerShell コマンド]]\\ 
 +[[.powershell:remote-commands|PowerShell リモートコマンド実行]]\\ 
 +[[.powershell:commands:get-alias|PowerShell エイリアス Get-Alias (alias: gal)]]\\ 
 +[[.powershell:commands:get-command|PowerShell コマンド情報取得[where/which] Get-Command (alias: gcm)]]\\ 
 +[[.powershell:call_command_prompt_interpreter_command|PowerShell からコマンドプロンプトのインタープリタコマンドの呼び出し]]\\ 
 + 
 +===== コマンド履歴 ===== 
 +<code powershell> 
 +$ less (Get-PSReadlineOption).HistorySavePath 
 +</code> 
 + 
 +<code powershell> 
 +$ cat (Get-PSReadlineOption).HistorySavePath | grep "scoop search" 
 +</code> 
 + 
 +===== PowerShellGet ===== 
 +[[https://www.powershellgallery.com/|PowerShell Gallery | Home]]\\ 
 +PowerShell ギャラリー 
 + 
 +PowerShellGet をインストールするには、以下のコマンドを実行する。\\ 
 +<code> 
 +$ sudo Install-Module -Name PowerShellGet -Force 
 +</code> 
 +PowerShellGet を新しいバージョンに更新するには、以下のコマンドを実行する。\\ 
 +<code> 
 +$ sudo Update-Module -Name PowerShellGet 
 +</code> 
 + 
 +**参考文献**\\ 
 +[[https://docs.microsoft.com/ja-jp/powershell/scripting/gallery/overview|PowerShell ギャラリー - PowerShell | Microsoft Docs]]\\ 
 +[[https://docs.microsoft.com/ja-jp/powershell/scripting/gallery/installing-psget|PowerShellGet のインストール - PowerShell | Microsoft Docs]]\\ 
 + 
 +===== Powershell のテーマ設定 ===== 
 +現在のコンソール設定をバックアップする。\\ 
 +<code> 
 +$ concfg export console-backup.json 
 +</code> 
 +<WRAP prewrap 100% #result> 
 +<code> 
 +console settings exported to console-backup.json 
 +</code> 
 +</WRAP> 
 + 
 +ソラリゼーションカラーテーマを使用する。\\ 
 +<code> 
 +$ concfg import solarized-dark 
 +</code> 
 +<WRAP prewrap 100% #result> 
 +<code> 
 +Console settings were imported from 'solarized-dark' 
 +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 'Registry::HKEY_CURRENT_USER\Console\%SystemRoot%_System32_WindowsPowerShell_v1.0_powershell.exe' 
 +Removing 'Registry::HKEY_CURRENT_USER\Console\%SystemRoot%_SysWOW64_WindowsPowerShell_v1.0_powershell.exe' 
 +Reset console properties of shortcut 'C:\Users\tomoyan\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Windows PowerShell\Windows PowerShell (x86).lnk' 
 +Reset console properties of shortcut 'C:\Users\tomoyan\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Windows PowerShell\Windows PowerShell.lnk' 
 + 
 +Would you like to open a new console to see the changes? (Y/n): n <- 入力する 
 +</code> 
 + 
 +上記の翻訳\\ 
 +<code> 
 +Overrides in the registry and shortcut files might interfere with your concfg settings. Would you like to find and remove them? 
 +</code> 
 +<code> 
 +レジストリファイルおよびショートカットファイルのオーバーライドは、concfg設定に干渉する可能性があります。それらを見つけて削除しますか? 
 +</code> 
 + 
 +<code> 
 +Would you like to open a new console to see the changes? 
 +</code> 
 +<code> 
 +変更を確認するために新しいコンソールを開きますか? 
 +</code> 
 +</WRAP> 
 + 
 +==== 参考文献 ==== 
 +[[https://github.com/lukesampson/scoop/wiki/Theming-Powershell|Theming Powershell · lukesampson/scoop Wiki · GitHub]]\\
  
 ===== PowerShell のバージョン ===== ===== PowerShell のバージョン =====
行 25: 行 212:
  
 Name             : ConsoleHost Name             : ConsoleHost
-Version          : 5.1.18362.145 +Version          : 6.2.4 
-InstanceId       : e2c61d93-3cfd-48be-9ab0-78013d5da518+InstanceId       : 3a2ed9d0-2c0b-42d5-976a-459d8e3f07af
 UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
 CurrentCulture   : ja-JP CurrentCulture   : ja-JP
行 34: 行 221:
 IsRunspacePushed : False IsRunspacePushed : False
 Runspace         : System.Management.Automation.Runspaces.LocalRunspace Runspace         : System.Management.Automation.Runspaces.LocalRunspace
 +
 +PS > Get-Host | Select-Object Version
 +
 +Version
 +-------
 +6.2.4
  
 PS > $PSVersiontable PS > $PSVersiontable
行 39: 行 232:
 Name                           Value Name                           Value
 ----                           ----- ----                           -----
-PSVersion                      5.1.18362.145 +PSVersion                      6.2.4 
-PSEdition                      Desktop +PSEdition                      Core 
-PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...} +GitCommitId                    6.2.4 
-BuildVersion                   10.0.18362.145 +OS                             Microsoft Windows 10.0.19559 
-CLRVersion                     4.0.30319.42000 +Platform                       Win32NT 
-WSManStackVersion              3.0+PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
 PSRemotingProtocolVersion      2.3 PSRemotingProtocolVersion      2.3
 SerializationVersion           1.1.0.1 SerializationVersion           1.1.0.1
 +WSManStackVersion              3.0
 +
 </code> </code>
  
行 52: 行 247:
 <code powershell> <code powershell>
 PS > start-process notepad c:\windows\system32\drivers\etc\hosts -verb runas PS > start-process notepad c:\windows\system32\drivers\etc\hosts -verb runas
 +</code>
 +
 +===== カレントディレクトリ変更 =====
 +<code powershell>
 +PS C:\Windows\System32> cd ~
 +PS C:\Users\tomoyan> pwd
 +
 +Path
 +----
 +C:\Users\tomoyan
 </code> </code>
  
行 62: 行 267:
 ===== 参考文献 ===== ===== 参考文献 =====
 [[http://www.vwnet.jp/windows/etc.asp#PowerShell|PowerShell - vwnet.jp]]\\ [[http://www.vwnet.jp/windows/etc.asp#PowerShell|PowerShell - vwnet.jp]]\\
-[[https://github.com/PowerShell/Win32-OpenSSH/releases|Releases · PowerShell/Win32-OpenSSH · GitHub]]\\+[[git>PowerShell/Win32-OpenSSH/releases|Releases · PowerShell/Win32-OpenSSH · GitHub]]\\ 
 + 
 +[[https://binary-pulsar.hatenablog.jp/entry/2018/09/01/000000|]]\\ 
 + 
 +[[https://stackoverflow.com/questions/2124753/how-can-i-use-powershell-with-the-visual-studio-command-prompt|How can I use PowerShell with the Visual Studio Command Prompt? - Stack Overflow]]\\ 
 +[[https://archive.codeplex.com/?p=pscx|PowerShell Community Extensions - CodePlex Archive]]\\ 
 +[[https://rkeithhill.wordpress.com/2014/10/24/pscx-3-2-0-available/|PSCX 3.2.0 Available | Keith Hill's Blog]]\\ 
 +[[https://rkeithhill.wordpress.com/|Keith Hill's Blog | Just another WordPress.com site]]\\ 
 +[[https://www.powershellgallery.com/|PowerShell Gallery | Home]]\\ 
 + 
 +[[https://www.vwnet.jp/Windows/w10/PSHistry.htm|PowerShell の入力履歴]]\\ 
 +[[https://help.appveyor.com/discussions/questions/18777-how-to-use-vcvars64bat-from-powershell|How to use vcvars64.bat from Powershell? / Questions / Discussion Area - AppVeyor Support]]\\ 
 +[[git>microsoft/vcpkg/blob/2020.11/scripts/bootstrap.ps1#L68|vcpkg/bootstrap.ps1 at 2020.11 · microsoft/vcpkg]]\\ 
 +[[https://stackoverflow.com/questions/26998968/passing-variables-between-powershell-commands-in-a-python-script|Passing variables between Powershell commands in a python script]]\\
  
  • windows/powershell.1566165461.txt.gz
  • 最終更新: 2019/08/19 06:57
  • by ともやん