Skip to content

Commit 75f2a42

Browse files
author
kumarstack55
committed
Update docs
1 parent 071b19d commit 75f2a42

File tree

7 files changed

+85
-52
lines changed

7 files changed

+85
-52
lines changed

docs/_sources/powershell/application.md.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# PowerShell 応用
22

3+
## PowerShell のセッションが管理者権限で実行されているか確認する
4+
5+
```powershell
6+
$current = [Security.Principal.WindowsIdentity]::GetCurrent()
7+
$principal = [Security.Principal.WindowsPrincipal] $current
8+
$isAdmin = $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
9+
$isAdmin
10+
```
11+
312
## アセンブリの名前を得る。
413

514
```powershell

docs/_sources/powershell/foundation.md.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ enum e1 {
6363
}
6464
```
6565

66-
- ハッシュテーブルのキーとして、整数、文字列、Enumは区別される。
66+
- ハッシュテーブルのキーとして、整数、文字列、Enum は区別される。
67+
- .Keys で得られるのは Enum が得られる。
6768

6869
```powershell
6970
PS > $h = [hashtable]::new()
@@ -105,6 +106,11 @@ Name Value
105106
label1 12
106107
0 13
107108
label1 11
109+
110+
PS > $h.Keys | % { "{0}, {1}, {2}" -f $_, $h[$_], $_.GetType() }
111+
label1, 12, System.String
112+
0, 13, System.Int32
113+
label1, 11, e1
108114
```
109115

110116
## Enum で日本語を使う。

docs/index.html

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -873,17 +873,18 @@ <h1>Untitled ドキュメント<a class="headerlink" href="#untitled" title="こ
873873
</ul>
874874
</li>
875875
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html">PowerShell 応用</a><ul>
876-
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id1">アセンブリの名前を得る。</a></li>
877-
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id2">コーディングのルール</a></li>
878-
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id3">PowerShell のファイル構造</a></li>
879-
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id4">PowerShell のフォーマット</a></li>
880-
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id5">PowerShell のキーワードや名前の大文字・小文字</a></li>
881-
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id6">PowerShell の空行の位置</a></li>
882-
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id7">PowerShell の省略記法</a></li>
883-
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id8">PowerShell のインデント</a></li>
884-
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id9">PowerShell のコメント</a></li>
876+
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id1">PowerShell のセッションが管理者権限で実行されているか確認する</a></li>
877+
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id2">アセンブリの名前を得る。</a></li>
878+
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id3">コーディングのルール</a></li>
879+
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id4">PowerShell のファイル構造</a></li>
880+
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id5">PowerShell のフォーマット</a></li>
881+
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id6">PowerShell のキーワードや名前の大文字・小文字</a></li>
882+
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id7">PowerShell の空行の位置</a></li>
883+
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id8">PowerShell の省略記法</a></li>
884+
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id9">PowerShell のインデント</a></li>
885+
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id10">PowerShell のコメント</a></li>
885886
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#todo">TODO</a></li>
886-
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id10">プロセスの開始時刻を得る。</a></li>
887+
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#id11">プロセスの開始時刻を得る。</a></li>
887888
<li class="toctree-l3"><a class="reference internal" href="powershell/application.html#python">最も最近に作られた Python プロセスを終了する。</a></li>
888889
</ul>
889890
</li>

docs/powershell.html

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -293,17 +293,18 @@ <h1>PowerShell<a class="headerlink" href="#powershell" title="このヘッドラ
293293
</ul>
294294
</li>
295295
<li class="toctree-l1"><a class="reference internal" href="powershell/application.html">PowerShell 応用</a><ul>
296-
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id1">アセンブリの名前を得る。</a></li>
297-
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id2">コーディングのルール</a></li>
298-
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id3">PowerShell のファイル構造</a></li>
299-
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id4">PowerShell のフォーマット</a></li>
300-
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id5">PowerShell のキーワードや名前の大文字・小文字</a></li>
301-
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id6">PowerShell の空行の位置</a></li>
302-
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id7">PowerShell の省略記法</a></li>
303-
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id8">PowerShell のインデント</a></li>
304-
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id9">PowerShell のコメント</a></li>
296+
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id1">PowerShell のセッションが管理者権限で実行されているか確認する</a></li>
297+
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id2">アセンブリの名前を得る。</a></li>
298+
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id3">コーディングのルール</a></li>
299+
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id4">PowerShell のファイル構造</a></li>
300+
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id5">PowerShell のフォーマット</a></li>
301+
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id6">PowerShell のキーワードや名前の大文字・小文字</a></li>
302+
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id7">PowerShell の空行の位置</a></li>
303+
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id8">PowerShell の省略記法</a></li>
304+
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id9">PowerShell のインデント</a></li>
305+
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id10">PowerShell のコメント</a></li>
305306
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#todo">TODO</a></li>
306-
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id10">プロセスの開始時刻を得る。</a></li>
307+
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#id11">プロセスの開始時刻を得る。</a></li>
307308
<li class="toctree-l2"><a class="reference internal" href="powershell/application.html#python">最も最近に作られた Python プロセスを終了する。</a></li>
308309
</ul>
309310
</li>

docs/powershell/application.html

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -272,20 +272,29 @@
272272
<section class="tex2jax_ignore mathjax_ignore" id="powershell">
273273
<h1>PowerShell 応用<a class="headerlink" href="#powershell" title="このヘッドラインへのパーマリンク"></a></h1>
274274
<section id="id1">
275-
<h2>アセンブリの名前を得る。<a class="headerlink" href="#id1" title="このヘッドラインへのパーマリンク"></a></h2>
275+
<h2>PowerShell のセッションが管理者権限で実行されているか確認する<a class="headerlink" href="#id1" title="このヘッドラインへのパーマリンク"></a></h2>
276+
<div class="highlight-powershell notranslate"><div class="highlight"><pre><span></span><span class="nv">$current</span> <span class="p">=</span> <span class="no">[Security.Principal.WindowsIdentity]</span><span class="p">::</span><span class="n">GetCurrent</span><span class="p">()</span>
277+
<span class="nv">$principal</span> <span class="p">=</span> <span class="no">[Security.Principal.WindowsPrincipal]</span> <span class="nv">$current</span>
278+
<span class="nv">$isAdmin</span> <span class="p">=</span> <span class="nv">$principal</span><span class="p">.</span><span class="n">IsInRole</span><span class="p">(</span><span class="no">[Security.Principal.WindowsBuiltInRole]</span><span class="p">::</span><span class="n">Administrator</span><span class="p">)</span>
279+
<span class="nv">$isAdmin</span>
280+
</pre></div>
281+
</div>
282+
</section>
283+
<section id="id2">
284+
<h2>アセンブリの名前を得る。<a class="headerlink" href="#id2" title="このヘッドラインへのパーマリンク"></a></h2>
276285
<div class="highlight-powershell notranslate"><div class="highlight"><pre><span></span><span class="no">[System.AppDomain]</span><span class="p">::</span><span class="n">CurrentDomain</span><span class="p">.</span><span class="n">GetAssemblies</span><span class="p">()</span> <span class="p">|</span>
277286
<span class="k">ForEach</span><span class="n">-Object</span> <span class="p">{</span>
278287
<span class="nv">$_</span><span class="p">.</span><span class="n">GetName</span><span class="p">().</span><span class="n">Name</span>
279288
<span class="p">}</span>
280289
</pre></div>
281290
</div>
282291
</section>
283-
<section id="id2">
284-
<h2>コーディングのルール<a class="headerlink" href="#id2" title="このヘッドラインへのパーマリンク"></a></h2>
292+
<section id="id3">
293+
<h2>コーディングのルール<a class="headerlink" href="#id3" title="このヘッドラインへのパーマリンク"></a></h2>
285294
<p>こうすると良さそう、というものを書きためておく。</p>
286295
</section>
287-
<section id="id3">
288-
<h2>PowerShell のファイル構造<a class="headerlink" href="#id3" title="このヘッドラインへのパーマリンク"></a></h2>
296+
<section id="id4">
297+
<h2>PowerShell のファイル構造<a class="headerlink" href="#id4" title="このヘッドラインへのパーマリンク"></a></h2>
289298
<ul class="simple">
290299
<li><p>クラスを定義するとき、クラス定義を行うファイルと、クラス定義内で利用する型を別ファイルで定義する。</p>
291300
<ul>
@@ -305,14 +314,14 @@ <h2>PowerShell のファイル構造<a class="headerlink" href="#id3" title="こ
305314
</li>
306315
</ul>
307316
</section>
308-
<section id="id4">
309-
<h2>PowerShell のフォーマット<a class="headerlink" href="#id4" title="このヘッドラインへのパーマリンク"></a></h2>
317+
<section id="id5">
318+
<h2>PowerShell のフォーマット<a class="headerlink" href="#id5" title="このヘッドラインへのパーマリンク"></a></h2>
310319
<ul class="simple">
311320
<li><p>VSCode で PowerShell のフォーマットができる。</p></li>
312321
</ul>
313322
</section>
314-
<section id="id5">
315-
<h2>PowerShell のキーワードや名前の大文字・小文字<a class="headerlink" href="#id5" title="このヘッドラインへのパーマリンク"></a></h2>
323+
<section id="id6">
324+
<h2>PowerShell のキーワードや名前の大文字・小文字<a class="headerlink" href="#id6" title="このヘッドラインへのパーマリンク"></a></h2>
316325
<ul class="simple">
317326
<li><p>予約語</p>
318327
<ul>
@@ -415,8 +424,8 @@ <h2>PowerShell のキーワードや名前の大文字・小文字<a class="head
415424
<li><p><a class="reference external" href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-5.1">about_Functions_Advanced_Parameters</a></p></li>
416425
</ul>
417426
</section>
418-
<section id="id6">
419-
<h2>PowerShell の空行の位置<a class="headerlink" href="#id6" title="このヘッドラインへのパーマリンク"></a></h2>
427+
<section id="id7">
428+
<h2>PowerShell の空行の位置<a class="headerlink" href="#id7" title="このヘッドラインへのパーマリンク"></a></h2>
420429
<ul class="simple">
421430
<li><p>クラスとクラスの間: 1行</p></li>
422431
<li><p>クラス</p>
@@ -436,21 +445,21 @@ <h2>PowerShell の空行の位置<a class="headerlink" href="#id6" title="この
436445
<li><p>ファンクションの <code class="docutils literal notranslate"><span class="pre">param()</span></code> とコードの間: メソッドと同じ。</p></li>
437446
</ul>
438447
</section>
439-
<section id="id7">
440-
<h2>PowerShell の省略記法<a class="headerlink" href="#id7" title="このヘッドラインへのパーマリンク"></a></h2>
448+
<section id="id8">
449+
<h2>PowerShell の省略記法<a class="headerlink" href="#id8" title="このヘッドラインへのパーマリンク"></a></h2>
441450
<ul class="simple">
442451
<li><p>使わない。</p></li>
443452
</ul>
444453
</section>
445-
<section id="id8">
446-
<h2>PowerShell のインデント<a class="headerlink" href="#id8" title="このヘッドラインへのパーマリンク"></a></h2>
454+
<section id="id9">
455+
<h2>PowerShell のインデント<a class="headerlink" href="#id9" title="このヘッドラインへのパーマリンク"></a></h2>
447456
<ul class="simple">
448457
<li><p>半角スペースのみを使う。タブは使用しない。</p></li>
449458
<li><p>インデントは 4 つのスペース。</p></li>
450459
</ul>
451460
</section>
452-
<section id="id9">
453-
<h2>PowerShell のコメント<a class="headerlink" href="#id9" title="このヘッドラインへのパーマリンク"></a></h2>
461+
<section id="id10">
462+
<h2>PowerShell のコメント<a class="headerlink" href="#id10" title="このヘッドラインへのパーマリンク"></a></h2>
454463
<div class="highlight-powershell notranslate"><div class="highlight"><pre><span></span><span class="k">function</span> <span class="nb">Add-Extension</span> <span class="p">{</span>
455464
<span class="cm">&lt;#</span>
456465
<span class="cm"> </span><span class="sd">.SYNOPSIS</span><span class="cm"></span>
@@ -477,8 +486,8 @@ <h2>TODO<a class="headerlink" href="#todo" title="このヘッドラインへの
477486
</li>
478487
</ul>
479488
</section>
480-
<section id="id10">
481-
<h2>プロセスの開始時刻を得る。<a class="headerlink" href="#id10" title="このヘッドラインへのパーマリンク"></a></h2>
489+
<section id="id11">
490+
<h2>プロセスの開始時刻を得る。<a class="headerlink" href="#id11" title="このヘッドラインへのパーマリンク"></a></h2>
482491
<p>WMI で得たオブジェクトは ConvertToDateTime で変換できる。</p>
483492
<div class="highlight-powershell notranslate"><div class="highlight"><pre><span></span><span class="nv">$PsoArray</span> <span class="p">=</span> <span class="nb">Get-WmiObject</span> <span class="n">win32_process</span> <span class="p">|</span>
484493
<span class="k">ForEach</span><span class="n">-Object</span> <span class="p">{</span>
@@ -596,17 +605,18 @@ <h2>最も最近に作られた Python プロセスを終了する。<a class="h
596605
<div class="toc-tree">
597606
<ul>
598607
<li><a class="reference internal" href="#">PowerShell 応用</a><ul>
599-
<li><a class="reference internal" href="#id1">アセンブリの名前を得る。</a></li>
600-
<li><a class="reference internal" href="#id2">コーディングのルール</a></li>
601-
<li><a class="reference internal" href="#id3">PowerShell のファイル構造</a></li>
602-
<li><a class="reference internal" href="#id4">PowerShell のフォーマット</a></li>
603-
<li><a class="reference internal" href="#id5">PowerShell のキーワードや名前の大文字・小文字</a></li>
604-
<li><a class="reference internal" href="#id6">PowerShell の空行の位置</a></li>
605-
<li><a class="reference internal" href="#id7">PowerShell の省略記法</a></li>
606-
<li><a class="reference internal" href="#id8">PowerShell のインデント</a></li>
607-
<li><a class="reference internal" href="#id9">PowerShell のコメント</a></li>
608+
<li><a class="reference internal" href="#id1">PowerShell のセッションが管理者権限で実行されているか確認する</a></li>
609+
<li><a class="reference internal" href="#id2">アセンブリの名前を得る。</a></li>
610+
<li><a class="reference internal" href="#id3">コーディングのルール</a></li>
611+
<li><a class="reference internal" href="#id4">PowerShell のファイル構造</a></li>
612+
<li><a class="reference internal" href="#id5">PowerShell のフォーマット</a></li>
613+
<li><a class="reference internal" href="#id6">PowerShell のキーワードや名前の大文字・小文字</a></li>
614+
<li><a class="reference internal" href="#id7">PowerShell の空行の位置</a></li>
615+
<li><a class="reference internal" href="#id8">PowerShell の省略記法</a></li>
616+
<li><a class="reference internal" href="#id9">PowerShell のインデント</a></li>
617+
<li><a class="reference internal" href="#id10">PowerShell のコメント</a></li>
608618
<li><a class="reference internal" href="#todo">TODO</a></li>
609-
<li><a class="reference internal" href="#id10">プロセスの開始時刻を得る。</a></li>
619+
<li><a class="reference internal" href="#id11">プロセスの開始時刻を得る。</a></li>
610620
<li><a class="reference internal" href="#python">最も最近に作られた Python プロセスを終了する。</a></li>
611621
</ul>
612622
</li>

docs/powershell/foundation.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ <h2>Enum をハッシュテーブルのキーに登録する。<a class="headerl
334334
</pre></div>
335335
</div>
336336
<ul class="simple">
337-
<li><p>ハッシュテーブルのキーとして、整数、文字列、Enumは区別される。</p></li>
337+
<li><p>ハッシュテーブルのキーとして、整数、文字列、Enum は区別される。</p></li>
338+
<li><p>.Keys で得られるのは Enum が得られる。</p></li>
338339
</ul>
339340
<div class="highlight-powershell notranslate"><div class="highlight"><pre><span></span><span class="nb">PS </span><span class="p">&gt;</span> <span class="nv">$h</span> <span class="p">=</span> <span class="no">[hashtable]</span><span class="p">::</span><span class="n">new</span><span class="p">()</span>
340341

@@ -375,6 +376,11 @@ <h2>Enum をハッシュテーブルのキーに登録する。<a class="headerl
375376
<span class="n">label1</span> <span class="n">12</span>
376377
<span class="n">0</span> <span class="n">13</span>
377378
<span class="n">label1</span> <span class="n">11</span>
379+
380+
<span class="nb">PS </span><span class="p">&gt;</span> <span class="nv">$h</span><span class="p">.</span><span class="n">Keys</span> <span class="p">|</span> <span class="p">%</span> <span class="p">{</span> <span class="s2">"{0}, {1}, {2}"</span> <span class="o">-f</span> <span class="nv">$_</span><span class="p">,</span> <span class="nv">$h</span><span class="p">[</span><span class="nv">$_</span><span class="p">],</span> <span class="nv">$_</span><span class="p">.</span><span class="n">GetType</span><span class="p">()</span> <span class="p">}</span>
381+
<span class="n">label1</span><span class="p">,</span> <span class="n">12</span><span class="p">,</span> <span class="n">System</span><span class="p">.</span><span class="n">String</span>
382+
<span class="n">0</span><span class="p">,</span> <span class="n">13</span><span class="p">,</span> <span class="n">System</span><span class="p">.</span><span class="n">Int32</span>
383+
<span class="n">label1</span><span class="p">,</span> <span class="n">11</span><span class="p">,</span> <span class="n">e1</span>
378384
</pre></div>
379385
</div>
380386
</section>

docs/searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)