時々思い出したようにPowerShell の記事を書いてみます。 スクリプトでよくあるのが、sudo で実行時に権限があるスクリプトの許可をしたいというケースです。 Windows は組み込みsudo がないので面倒でしたが、現状なら scoop で sudo をインストールするといいと思います。 https://scoop.sh/scoop.sh scoop install sudo これで sudo ./your_script.ps1 とできるので特権が必要なときに、必要な権限を渡すことができます。 さて今回の記事は、Windows において実行中のスクリプトや関数が特権が必要な場合に、sudo を使わずにUACダイアログを出して昇格したPowerShellで同関数を実行し直してほしいというケースです。 通常の特権昇格フロー + Windows Diffender操作のため利用には注意