sheronyanさん、
sgk.stuc.90pc90さん、こんばんは。
お二人がご認識のように、Windowsにとってpowershell.exeは重要なエッセンシャルであり、コマンドプロセッサーと類似の動作(書式さえ知っていればコマンドプロセッサー以上の動作を約束されています)。
◆PowerShell.exeについて
https://docs.microsoft.com/ja-jp/powershell/module/Microsoft.PowerShell.Core/About/about_PowerShell_...画像:マイクロ社より引用
◆PowerShell.exeはPowerShellセッションを開始します。Cmd.exeおよびPowerShell で使用できます 。
※コマンドプロンプトからPowerShellを呼び出した場合;1
https://blog.shibata.tech/entry/2016/03/29/193153文字列
【powershell.exe -Command "$word='PowerShell'; Write-Output ""Windows $word"""】
使いたいコマンド::
DISM.exe /Online /Cleanup-image /Restorehealth
sfc /scannow
※コマンドプロンプトからPowerShellを呼び出した場合;2
https://qiita.com/ww24/items/7d52df13fef5bc54e149画像::Qiitaサイトより以下引用
文字列
1)powershell -Command "ls"
2)set dir=path/to
powershell -Command "ls %dir%"
3)set data=hello
set script=Invoke-RestMethod -Uri "
http://example.com"; -Method POST -Body "%data%"
4)set script=%script:"=\"%
5)powershell -Command "%script%"
以下別紙~コマンドラインを全てコピペ(実績)成功か否かは皆様でご判断ください。
=============================================================
◆システムファイルの更新:Windows PowerShell:DISM.exe:の使い方
Microsoft Windows [Version 10.0.17763.914]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\WINDOWS\system32>powershell.exe -Command "$word='PowerShell'; Write-Output ""Windows $word"""
Windows PowerShell
C:\WINDOWS\system32>sfc /scannow
システム スキャンを開始しています。これにはしばらく時間がかかります。
システム スキャンの検証フェーズを開始しています。
検証 100% が 完 了 し ま し た 。
Windows リソース保護により、破損したファイルが見つかりましたが、それらの一部は修復できませんでした。
オンライン修復の場合、詳細は次の場所にある CBS ログ ファイルに含まれています
windir\ Logs\CBS\CBS.log (たとえば C:\Windows\Logs\CBS\CBS.log)。オフライン修復の場合、
詳細は /OFFLOGFILE フラグによって指定したログ ファイルに含まれています。
C:\WINDOWS\system32>DISM.exe /Online /Cleanup-image /Restorehealth
展開イメージのサービスと管理ツール
バージョン: 10.0.17763.771
イメージのバージョン: 10.0.17763.914
[==========================100.0%==========================] 復元操作は正常に完了しました。
操作は正常に完了しました。
C:\WINDOWS\system32>powershell -Command "ls"
※解説;コマンドは以下のようになりますが、矢印の部分はコマンドが長文の為割愛しました。
ディレクトリ: C:\WINDOWS\system32
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2020/01/23 18:50 %Report%
d----- 2019/06/20 14:22 0401
d----- 2019/06/20 14:22 0404
d----- 2019/06/20 14:22 0405
d----- 2019/06/20 14:22 0406
d----- 2019/06/20 14:22 0407
d----- 2019/06/20 14:22 0408
d----- 2019/06/20 14:22 0409
d----- 2019/06/20 14:22 040A
d----- 2019/06/20 14:22 040B
d----- 2019/06/20 14:22 040C
d----- 2019/06/20 14:22 040D
d----- 2019/06/20 14:22 040E
d----- 2019/06/20 14:22 0410
d----- 2019/06/30 15:07 0411
d----- 2019/06/20 14:22 0412
d----- 2019/06/20 14:22 0413
d----- 2019/06/20 14:22 0414
d----- 2019/06/20 14:22 0415
d----- 2019/06/20 14:22 0416
d----- 2019/06/20 14:22 0419
d----- 2019/06/20 14:22 041B
d----- 2019/06/20 14:22 041D
d----- 2019/06/20 14:22 041E
d----- 2019/06/20 14:22 041F
d----- 2019/06/20 14:22 0424
d----- 2019/06/20 14:22 0804
d----- 2019/06/20 14:22 0816
d----- 2019/06/20 14:22 0C04
d----- 2019/06/20 14:22 0C0A
d----- 2019/06/20 14:22 2C0A
d----- 2018/09/15 16:34 AdvancedInstallers
d----- 2017/12/14 10:36 af-ZA
d----- 2018/09/15 16:34 am-et
d----- 2018/09/15 16:33 AppLocker
d----- 2020/01/17 17:35 appraiser
d---s- 2018/09/16 1:56 AppV
↑ ↓ ↑ ↓ ↑ ↓ ↑ ↓ ↑ ↓ ↑ ↓ ↑ ↓ ↑ ↓
↑ ↓ ↑ ↓ ↑ ↓ ↑ ↓ ↑ ↓ ↑ ↓ ↑ ↓ ↑ ↓
-a---- 2018/09/15 16:29 47616 xcopy.exe
-a---- 2018/09/15 16:29 44032 XInput1_4.dll
-a---- 2018/09/15 16:29 10752 XInput9_1_0.dll
-a---- 2018/09/15 16:28 48640 XInputUap.dll
-a---- 2018/09/15 16:28 68096 xmlfilter.dll
-a---- 2020/01/17 17:32 230848 xmllite.dll
-a---- 2018/09/15 16:28 22016 xmlprovi.dll
-a---- 2018/09/15 16:29 64000 xolehlp.dll
-a---- 2018/09/15 16:28 352768 XpsDocumentTargetPrint.dll
-a---- 2019/06/04 8:25 922112 XpsFilt.dll
-a---- 2018/09/15 16:28 471040 XpsGdiConverter.dll
-a---- 2019/06/03 14:34 1671680 XpsPrint.dll
-a---- 2018/09/15 16:28 582656 XpsRasterService.dll
-a---- 2020/01/17 17:33 4488192 xpsrchvw.exe
-a---- 2019/06/04 8:25 76060 xpsrchvw.xml
-a---- 2020/01/17 17:32 2879488 xpsservices.dll
-a---- 2019/06/04 8:25 99328 XPSSHHDR.dll
-a---- 2018/09/15 16:29 4014 xwizard.dtd
-a---- 2018/09/15 16:29 62464 xwizard.exe
-a---- 2018/09/15 16:29 448000 xwizards.dll
-a---- 2018/09/15 16:29 118272 xwreg.dll
-a---- 2018/09/15 16:29 257536 xwtpdui.dll
-a---- 2018/09/15 16:29 143360 xwtpw32.dll
-a---- 2016/12/05 10:43 2190984 YamahaAE.dll
-a---- 2016/12/05 10:43 3299816 YamahaAE2.dll
-a---- 2018/09/15 16:28 79872 zipcontainer.dll
-a---- 2018/10/30 7:58 429568 zipfldr.dll
-a---- 2018/09/15 16:28 30720 ztrace_maps.dll
-a---- 2019/05/29 16:41 144 {A6D608F0-0BDE-491A-97AE-5C4B05D86E01}.bat
-a---- 2019/06/16 7:05 451 {F33C3B9B-72AF-418A-B3FD-560646F7CDA2}.bat
C:\WINDOWS\system32>set dir=path/to
C:\WINDOWS\system32>powershell -Command "ls %dir%"
ls : パス 'C:\WINDOWS\system32\path\to' が存在しないため検出できません。
発生場所 行:1 文字:1
+ ls path/to
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\WINDOWS\system32\path\to:String) [Get-ChildItem], ItemNotFoundExc
eption
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
C:\WINDOWS\system32>set dir=path/to
C:\WINDOWS\system32>powershell -Command "ls %dir%"
ls : パス 'C:\WINDOWS\system32\path\to' が存在しないため検出できません。
発生場所 行:1 文字:1
+ ls path/to
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\WINDOWS\system32\path\to:String) [Get-ChildItem], ItemNotFoundExc
eption
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
C:\WINDOWS\system32>set data=hello
C:\WINDOWS\system32>set script=Invoke-RestMethod -Uri "
http://example.com"; -Method POST -Body "%data%"
C:\WINDOWS\system32>
C:\WINDOWS\system32>set script=%script:"=\"%
C:\WINDOWS\system32>powershell -Command "%script%"
Example Domain Example Domain
This domain is for use in illustrative examples in documents. You may use this
domain in literature without prior coordination or asking for permission.
https://www.iana.org/domains/example">More information...
C:\WINDOWS\system32>sfc /scannow
システム スキャンを開始しています。これにはしばらく時間がかかります。
システム スキャンの検証フェーズを開始しています。
検証 100% が 完 了 し ま し た 。
Windows リソース保護により、破損したファイルが見つかりましたが、それらは正常に修復されました。
オンライン修復の場合、詳細は次の場所にある CBS ログ ファイルに含まれています
windir\ Logs\CBS\CBS.log (たとえば C:\Windows\Logs\CBS\CBS.log)。オフライン修復の場合、
詳細は /OFFLOGFILE フラグによって指定したログ ファイルに含まれています。
C:\WINDOWS\system32>chkdsk /scannow
無効なパラメーターです - /scannow
C:\WINDOWS\system32>chkdsk /scan
ファイル システムの種類は NTFS です。
ステージ 1: 基本のファイル システム構造を検査しています ...
614912 個のファイル レコードが処理されました。
ファイルの検査を完了しました。
34987 個の大きなファイル レコードが処理されました。
0 個の問題のあるファイル レコードが処理されました。
ステージ 2: ファイル名リンケージを検査しています ...
36262 個の再解析レコードが処理されました。
820502 個のインデックス エントリが処理されました。
インデックスの検査を完了しました。
0 個のインデックスなしファイルがスキャンされました。
0 個のインデックスのないファイルが lost and found に回復されました。
36262 個の再解析レコードが処理されました。
ステージ 3: セキュリティ記述子を検査しています ...
セキュリティ記述子の検査を完了しました。
102796 個のデータ ファイルが処理されました。
CHKDSK は Usn ジャーナルを確認しています...
34276232 バイトの USN が処理されました。
Usn ジャーナルの確認を完了しました。
Windows でファイル システムのスキャンが終了しました。
問題は見つかりませんでした。
これ以上の操作は必要ありません。
318544892 KB : 全ディスク領域
120883760 KB : 350715 個のファイル
220488 KB : 102797 個のインデックス
0 KB : 不良セクター
766064 KB : システムで使用中
65536 KB : ログ ファイルが使用
196674580 KB : 使用可能領域
4096 バイト : アロケーション ユニット サイズ
79636223 個 : 全アロケーション ユニット
49168645 個 : 利用可能アロケーション ユニット
C:\WINDOWS\system32>defrag c/h /a
Microsoft ドライブ最適化ツール
Copyright (c) Microsoft Corp.
指定したボリューム パスは無効です。 (0x89000001)
説明:
システムのパフォーマンスを向上させるため、ローカル ボリューム上の
ファイルを最適化します。
構文:
defrag <ボリューム> | /C | /E <ボリューム> [<タスク>] [/H] [/M [n] | [/U] [/V]] [/I n]
ここで、<タスク> は省略 (従来の最適化) または次のようにします:
/A | [/D] [/K] [/L] | /O | /X
ボリューム上で既に進行中の操作を追跡するには:
defrag <ボリューム> /T
パラメーター:
値 説明
/A 指定したボリュームの分析を実行します。
/C すべてのボリュームに操作を実行します。
/D 従来のデフラグを実行します (これは既定値です)。ただし、階層型ボリュームでは、
従来のデフラグはキャパシティ層でのみ実行されます。