いろいろやってみるにっき

てきとーに生きている奴の日記

古いエントリのサムネイル画像がリンク切れになってたりするけど、チマチマ修正中


Windows10にプリインストールされているが不要なソフトウェアをアンインストールするpowershell その1

こんなツイートが流れてきた。

 

開いてみる。

github.com

 

タイトルのすぐ下を訳してみた。

スクリプト/ユーティリティ/アプリケーション Windows 10 の拡張、Windows のプレインストールされた不要なアプリケーションの削除、一部のテレメトリ機能の停止、Cortana の検索インデックスとしての使用の停止、不要なスケジュールされたタスクの無効化など...

 

Donate a cup of coffeeとDisclaimer(免責事項)セクションの下にWindows10Debloater.ps1 および Windows10DebloaterGUI.ps1 ファイルを実行する方法というセクションがある。

最初の方法

  1. GitHub のメイン ページで .zip ファイルをダウンロードし、.zip ファイルを任意の場所に展開します。
  2. 抽出したら、PowerShell (または PowerShell ISE) を管理者として開きます。
  3. PowerShell の実行を有効にする Set-ExecutionPolicy Unrestricted -Force
  4. プロンプトで、ファイルを抽出したディレクトリに移動します。 - cd c:\temp
  5. 次に、いずれかのスクリプトを実行するには、次のように入力します。 - .\Windows10DebloaterGUI.ps1

 

ダウンロードは個別のPS1ファイルごとにしたので、#1は省略。[Win]+[x]でメニューを開く。

起動した。

直でダウンロードしたのでDownloadsフォルダに行き確認する。

PS C:\Users\shigeo-t> cd .\Downloads\
PS C:\Users\shigeo-t\Downloads> ls win*.ps1


    ディレクトリ: C:\Users\shigeo-t\Downloads


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        2022/08/15      8:45         502579 Windows10Debloater.ps1
-a----        2022/08/15      8:45         717321 Windows10DebloaterGUI.ps1
-a----        2022/08/15      8:45         249479 Windows10SysPrepDebloater.ps1

 

#3を実行する。なんかメッセージ出てる。

PS C:\Users\shigeo-t\Downloads> Set-ExecutionPolicy Unrestricted -Force
Set-ExecutionPolicy : Windows PowerShell により実行ポリシーは正常に更新されましたが、設定は範囲がより明確に定義されたポ
リシーで上書きされました。この上書きにより、シェルで現在有効な実行ポリシー RemoteSigned が保持されます。実行ポリシーの
設定を表示するには、「Get-ExecutionPolicy -List」と入力してください。詳細については、"Get-Help Set-ExecutionPolicy" を
参照してください。
発生場所 行:1 文字:1
+ Set-ExecutionPolicy Unrestricted -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (:) [Set-ExecutionPolicy], SecurityException
    + FullyQualifiedErrorId : ExecutionPolicyOverride,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand
PS C:\Users\shigeo-t\Downloads>

メッセージにしたがってGet-Help Set-ExecutionPolicyを実行してみた。ローカルマシンは無制限になってる。

PS C:\Users\shigeo-t\Downloads> Get-ExecutionPolicy -List

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser    RemoteSigned
 LocalMachine    Unrestricted

とりあえず#4は済んでいるので#5を実行してみる。エラーである。

PS C:\Users\shigeo-t\Downloads> .\Windows10DebloaterGUI.ps1
.\Windows10DebloaterGUI.ps1 : ファイル C:\Users\shigeo-t\Downloads\Windows10DebloaterGUI.ps1 を読み込めません。ファイル
 C:\Users\shigeo-t\Downloads\Windows10DebloaterGUI.ps1 はデジタル署名されていません。このスクリプトは現在のシステムでは
実行できません。スクリプトの実行および実行ポリシーの設定の詳細については、「about_Execution_Policies」(https://go.micro
soft.com/fwlink/?LinkID=135170) を参照してください。
発生場所 行:1 文字:1
+ .\Windows10DebloaterGUI.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : セキュリティ エラー: (: ) []、PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

 

ということで何かがおかしいと思ったので、ターミナルを管理者で起動する。デフォルトはPowerShellである。PowerShellのバージョンが違う。

一気に#4まで実行。エラーメッセージ無しで進む。

PowerShell 7.2.5
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

   A new PowerShell stable release is available: v7.2.6
   Upgrade now, or check out the release page at:
     https://aka.ms/PowerShell-Release?tag=v7.2.6

PS C:\Users\shigeo-t> Set-ExecutionPolicy Unrestricted -Force
PS C:\Users\shigeo-t> cd .\Downloads\
PS C:\Users\shigeo-t\Downloads> ls Win*.ps1

    Directory: C:\Users\shigeo-t\Downloads

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          2022/08/15     8:45         502579 Windows10Debloater.ps1
-a---          2022/08/15     8:45         717321 Windows10DebloaterGUI.ps1
-a---          2022/08/15     8:45         249479 Windows10SysPrepDebloater.ps1

PS C:\Users\shigeo-t\Downloads>

#5を実行する。スクリプト動いた。

PS C:\Users\shigeo-t\Downloads> .\Windows10DebloaterGUI.ps1

Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your
computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message. Do you want to run C:\Users\shigeo-t\Downloads\Windows10DebloaterGUI.ps1?
[D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"):

エラーになった。

ParserError: C:\Users\shigeo-t\Downloads\Windows10DebloaterGUI.ps1:198
Line |
 198 |etails-target btn-link d-lg-none mt-1 color-fg-inherit">    <svg aria …
     |                                                                ~
     | The '<' operator is reserved for future use.

とりあえずもうひとつのWindows10Debloater.ps1も実行。

PS C:\Users\shigeo-t\Downloads> .\Windows10Debloater.ps1

Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your
computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message. Do you want to run C:\Users\shigeo-t\Downloads\Windows10Debloater.ps1?
[D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"): R
ParserError: C:\Users\shigeo-t\Downloads\Windows10Debloater.ps1:198
Line |
 198 |etails-target btn-link d-lg-none mt-1 color-fg-inherit">    <svg aria …
     |                                                                ~
     | The '<' operator is reserved for future use.

やはり同じエラーである。

 

上記エラーは必要なスクリプト群が足りなかったためである。オレが悪かった。説明通りZIPファイルをダウンロードし、エクスプローラー上で解凍し、解凍したフォルダに行き起動。

PS C:\Users\shigeo-t\Downloads>> cd C:\Users\shigeo-t\Downloads\Windows10Debloater-master\Windows10Debloater-master
PS C:\Users\shigeo-t\Downloads\Windows10Debloater-master\Windows10Debloater-master>> .\Windows10DebloaterGUI.ps1

Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your
computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message. Do you want to run
C:\Users\shigeo-t\Downloads\Windows10Debloater-master\Windows10Debloater-master\Windows10DebloaterGUI.ps1?
[D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"): R
The folder C:\Temp\Windows10Debloater doesn't exist. This folder will be used for storing logs created after the script runs. Creating now.

    Directory: C:\Temp

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          2022/08/15     9:39                Windows10Debloater
The folder C:\Temp\Windows10Debloater was successfully created.
Transcript started, output file is C:\Temp\Windows10Debloater\PowerShell_transcript.EAGLEII.Gel3bX4g.20220815093931.txt
Creating System Restore Point if one does not already exist. If one does, then you will receive a warning. Please wait..

GUI起動できた。

一番上の[CUSTOMISE BLOCKLIST]をクリックしてみる。なるほど、こうなっているわけね。

 

とりあえずもうひとつのWindows10Debloater.ps1を起動してみる。

PS C:\Users\shigeo-t\Downloads\Windows10Debloater-master> cd .\Windows10Debloater-master\
PS C:\Users\shigeo-t\Downloads\Windows10Debloater-master\Windows10Debloater-master> ls

    Directory: C:\Users\shigeo-t\Downloads\Windows10Debloater-master\Windows10Debloater-master

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          2022/08/15     9:38                Individual Scripts
-a---          2022/08/15     9:38           1071 LICENSE
-a---          2022/08/15     9:38           9866 README.md
-a---          2022/08/15     9:38          46087 Windows10Debloater.ps1
-a---          2022/08/15     9:38          76621 Windows10DebloaterGUI.ps1
-a---          2022/08/15     9:38          13812 Windows10SysPrepDebloater.ps1

PS C:\Users\shigeo-t\Downloads\Windows10Debloater-master\Windows10Debloater-master> .\Windows10Debloater.ps1

Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your
computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message. Do you want to run
C:\Users\shigeo-t\Downloads\Windows10Debloater-master\Windows10Debloater-master\Windows10Debloater.ps1?
[D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"): R
C:\Temp\Windows10Debloater exists. Skipping.
Transcript started, output file is C:\Temp\Windows10Debloater\PowerShell_transcript.EAGLEII.G4j_Aplk.20220815095723.txt

ダイアログ出た。[はい(Y)]を選ぶ。

またダイアログ。Select Yes to remove everythingって書いてある。怖いなこっちは。

 

ということで長くなったので一旦ここで切る。

お時間あったら、他のエントリもクリックして頂ければ幸いです。