ab’s blog

インフラの呟きです。

2024-03-20から1日間の記事一覧

Windows11 テキストの内容をイベントログに登録

はじめに powershellでイベントログに書き込むサンプル。(実行にはadministrator権限(管理者)が必要で、無いとイベントログ書き込みがエラーになります) powershellサンプル sample.ps1 try { #テキストファイルを読み込み $file_data = Get-Content .\tex…

Windows11 batファイルからpowershellスクリプトを呼び出して実行する

powershellスクリプト「aaa.ps1」をバッチファイルから呼び出して実行したいときは以下のように書きます。「ExecutionPolicy 」を一時的に変更しないとpowershellが実行エラーとなります。 sample.bat @echo off powershell -ExecutionPolicy RemoteSigned .…