忍者ブログ

◆当blogは、Linuxサーバ構築する際の実際の設定手順を個人的メモとして記載しております。LinuC試験の役に立つ情報があるかも…?

LinuC(Linux技術者認定資格)&リナックスサーバ構築設定事例

   

【PowerShell】バッチから実行

■以下のようにバッチファイルに記述するとバッチからPowerShellが実行出来る
@echo off
PowerShell -command "Write-Output '--- --- --- --- --- --- --- --- --- --- --- --- --- ---'"
PowerShell -command "Write-Output '★★★ 開始 ★★★'"
PowerShell -command "Write-Output '--- --- --- --- --- --- --- --- --- --- --- --- --- ---'"
PowerShell -command "Write-Output ' '"
PowerShell -command "Write-Output '▲▼▲▼▲▼ ホスト名 ▲▼▲▼▲▼'"
PowerShell -command "hostname"
PowerShell -command "Write-Output '--- --- --- --- --- --- --- --- --- --- --- --- --- ---'"
PowerShell -command "Write-Output '▲▼▲▼▲▼ 日時 ▲▼▲▼▲▼'"
PowerShell -command "Get-Date -Format 'yyyy/MM/dd HH:mm'"
PowerShell -command "Write-Output '--- --- --- --- --- --- --- --- --- --- --- --- --- ---'"
PowerShell -command "Write-Output '▲▼▲▼▲▼ パッチ情報(降順) ▲▼▲▼▲▼'"
PowerShell -command "Get-HotFix | Where-Object HotFixID -match "KB" | Sort-Object -Descending InstalledOn"
PowerShell -command "Write-Output '--- --- --- --- --- --- --- --- --- --- --- --- --- ---'"
PowerShell -command "Write-Output '▲▼▲▼▲▼ 最近のOS起動の日時 ▲▼▲▼▲▼'"
PowerShell -command "Get-EventLog System | Where-Object {$_.InstanceId -eq "12" } | Select-Object -First 1"
PowerShell -command "Write-Output '--- --- --- --- --- --- --- --- --- --- --- --- --- ---'"
PowerShell -command "Write-Output '▲▼▲▼▲▼ システムイベント(エラー) ▲▼▲▼▲▼'"
PowerShell -command "Get-EventLog System | Where-Object {$_.EntryType -eq 'Error'} | Select-Object -First 50"
PowerShell -command "Write-Output '--- --- --- --- --- --- --- --- --- --- --- --- --- ---'"
pause
PowerShell -command "Write-Output '▲▼▲▼▲▼ システムイベント(警告) ▲▼▲▼▲▼'"
PowerShell -command "Get-EventLog System | Where-Object {$_.EntryType -eq 'Warning'} | Select-Object -First 50"
PowerShell -command "Write-Output '--- --- --- --- --- --- --- --- --- --- --- --- --- ---'"
pause
rem PowerShell -command "Write-Output '▲▼▲▼▲▼ アプリケーションイベント(エラー) ▲▼▲▼▲▼'"
rem PowerShell -command "Get-EventLog Application | Where-Object {$_.EntryType  -Like 'Error'} | Select-Object -First 30"
rem PowerShell -command "Write-Output '--- --- --- --- --- --- --- --- --- --- --- --- --- ---'"
rem pause
rem PowerShell -command "Write-Output '▲▼▲▼▲▼ アプリケーションイベント(警告) ▲▼▲▼▲▼'"
rem PowerShell -command "Get-EventLog Application | Where-Object {$_.EntryType  -Like 'Warning'} | Select-Object -First 30"
rem PowerShell -command "Write-Output '--- --- --- --- --- --- --- --- --- --- --- --- --- ---'"
rem pause
PowerShell -command "Write-Output ' '"
PowerShell -command "Write-Output '--- --- --- --- --- --- --- --- --- --- --- --- --- ---'"
PowerShell -command "Write-Output '★★★ 終了 ★★★'"
PowerShell -command "Write-Output '--- --- --- --- --- --- --- --- --- --- --- --- --- ---'"
pause
PR

更新日付

03 2025/04 05
S M T W T F S
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30

RECOMMEND

プロフィール

HN:
Account
HP:
性別:
非公開
職業:
--- NODATA ---
趣味:
--- NODATA ---
自己紹介:
◆当blogは、Linuxサーバ構築する際の実際の設定手順を個人的メモとして記載しております。LinuC試験の役に立つ情報があるかも…?

リンク

<<【Windows】使用頻度高め  | HOME |  【Windows】パッチ適用・サービス状態・イベントログの確認方法>>
Copyright ©  -- LinuC(Linux技術者認定資格)&リナックスサーバ構築設定事例 --  All Rights Reserved
Design by CriCri / Photo by Melonenmann / powered by NINJA TOOLS / 忍者ブログ / [PR]