毎月発生するPowerShellイベントログ.
このイベントログが毎月発生するのはなぜですか?
心配する必要がありますか?
私のOSはwindows 10
ホーム
PowerShell/操作ログで発生します
タスクカテゴリ:リモートコマンドを実行する
スクリプトブロックテキストの作成(1/1):
#Copyright©2008、MicrosoftCorporation.無断転載を禁じます.
#commonユーティリティ関数
Import-LocalizedData-BindingVariable localeString-FileName CL_LocalizationData
#ユーザーのトラブルシューティング履歴を取得する機能
関数Get-UserTSHistoryPath{
「${env:localappdata}」を返します\diagnostics "
}
#管理者のトラブルシューティング履歴を取得する機能
関数Get-AdminTSHistoryPath{
「${env:localappdata}」を返します\elevateddiagnostics "
}
#ユーザーレポートフォルダのパスを取得する関数
関数Get-UserReportPath{
「${env:localappdata}」を返します\Microsoft\Windows\WER\ReportQueue "
}
#システムレポートフォルダのパスを取得する関数
関数Get-MachineReportPath{
「${env:AllUsersProfile}」を返します\Microsoft\Windows\WER\ReportQueue "
}
#フォルダが古いかどうかを確認するためのしきい値を取得する関数
関数Get-ThresholdForCheckOlderFile{
[int] $ threshold=-1
$thresholdを返す
}
#WERフォルダを削除するためのしきい値を取得する関数
関数Get-ThresholdForFileDeleting(){
[文字列]$repositoryEntryPath= "HKLM:\SOFjpARE\Microsoft\Windows\WindowsError Reporting"
[文字列]$repositoryEntryName= "PurgeThreshholdValueInKB"
[double] $ defaultValue= 10.0
Get-RegistryValue $registryEntryPath $ registerryEntryName $ defaultValue
を返します}
#ディレクトリのサイズをkb単位で取得する関数
function Get-FolderSize([string] $ folder= $(throw "フォルダが指定されていません")){
if([String] :: IsNullOrEmpty($ folder)-or(-not(Test-Path $ folder))){
0を返す
}
if(-$ Global:DirectoryObjectではありません){
$ Global:DirectoryObject= New-Object-comobject "Scripting.FileSystemObject"
}
return($ Global:DirectoryObject.GetFolder($ folder).Size)/1kb
}
#フォルダを削除する機能
function Delete-Folder([string] $ folder= $(throw "フォルダが指定されていません")){
if([String] :: IsNullOrEmpty($ folder)-or(-not(Test-Path $ folder))){
戻る
}
Remove-Item-literalPath $ folder-Recurse-Force
}
#古いフォルダを削除する機能
function Delete-OldFolders($ folder= $(throw "フォルダが指定されていません")){
if(($ folder-eq $ null)-or(-not(Test-Path $ folder))){
戻る
}
[int] $ threshold= Get-ThresholdForCheckOlderFile
$ folder= Get-ChildItem-LiteralPath($ folder.FullName)-Force|Where-Object{$_.PSIsContainer}
if($ folder-ne $ null){
foreach($foldersの$folder){
if((($ folder.CreationTime).compareTo((Get-Date).AddMonths($ threshold)))-lt 0){
Delete-Folder($ folder.FullName)
} それ以外の場合{
Delete-OldFolders(Get-Item($ folder.FullName))
}
}
}
}
#レジストリ値を取得する関数
function Get-RegistryValue([string] $ repositoryEntryPath= $(throw "レジストリエントリパスが指定されていません")、[string] $ repositoryEntryName= $(throw "レジストリエントリ名が指定されていません")、[double] $ defaultValue= 0.0 ){
[double] $ repositoryEntryValue= $ defaultValue
$ repositoryEntry= Get-ItemProperty-Path $ repositoryEntryPath-Name $ repositoryEntryName
if($ repositoryEntry-ne $ null){
$ repositoryEntryValue=$registryEntry.$registryEntryName
}
$registryEntryValueを返す
}
#WERキューが占める可能性のあるパーセンテージを取得する関数
関数Get-Percentage(){
[文字列]$repositoryEntryPath= "HKLM:\SOFjpARE\Microsoft\Windows\WindowsError Reporting"
[文字列]$repositoryEntryName= "MaxQueueSizePercentage"
[double] $ defaultValue= 100.0
Get-RegistryValue $registryEntryPath $ registerryEntryName $ defaultValue
を返します}
#マシンの空きディスク容量を取得する関数
関数Get-FreeSpace{
[double] $ freeSpace= 0.0
[文字列]$wql= "SELECT* FROM Win32_LogicalDisk WHERE MediaType= 12"
$ drives= Get-WmiObject-query $ wql
if($ null-ne $ drives){
foreach($drivesの$drive){
$ freeSpace +=($ drive.freeSpace)
}
}
return($ freeSpace/1KB)
}
#不要なファイルをすべて取得する関数
function Get-UnnecessaryFiles([string] $ folder= $(throw "フォルダが指定されていません")){
if([String] :: IsNullOrEmpty($ folder)-or(-not(Test-Path $ folder))){
$nullを返す
}
[int] $ threshold= Get-ThresholdForCheckOlderFile
return(Get-ChildItem-literalPath $ folder-Recurse-Force|Where-Object {($ _.PSIsContainer)-and((($ _.CreationTime).compareTo((Get-Date).AddMonths($ threshold)))-lt 0)})
}
#ディスクスペースをフォーマットする関数(KB->MB)
function Format-DiskSpaceMB([double] $ space= $(throw "スペースが指定されていません")){
return [string]([Math] :: Round(($ space/1KB)、3))
}
#ディスクスペースをフォーマットする機能(B->GB)
関数形式-DiskSpaceGB([double] $ space= $(throw "スペースが指定されていません")){
return [string]([Math] :: Round(($ space/1GB)、3))
}
#区切り文字「/」でリストにアイテムを添付する関数
function AttachTo-List([string] $ list= $(throw "リストが指定されていません")、[string] $ item= $(throw "アイテムが指定されていません"))
{
if([String] :: IsNullOrEmpty($ list))
{
$itemを返す
}
if([String] :: IsNullOrEmpty($ item))
{
$listを返す
}
$ list + "/" +$itemを返す
}
#区切り文字「/」を使用してリストを解析する関数
function Parse-List([string] $ list= $(throw "リストが指定されていません"))
{
if($ list-eq $ null)
{
$nullを返す
}
$ list.Split( "/"、[StringSplitOptions] :: RemoveEmptyEntries)
を返します}
#リストの長さを取得する関数
function Get-ListLength([string] $ list= $(throw "リストが指定されていません"))
{
if($ list-eq $ null)
{
0を返す
}
$ result= Parse-List $ list
if($ result-is [string])
{
1を返す
}
elseif($ result-is [object []])
{
$ result.count
を返します}
その他
{
0を返す
}
}
#WQLパスに変換する関数
function ConvertTo-WQLPath([string] $ wqlPath= $(throw "WQLパスが指定されていません"))
{
if($ wqlPath-eq $ null)
{
「」を返す
}
$ wqlPath.Replace( "\"、 "\\")
を返します}
#ショートカットが有効かどうかを確認する機能
function Test-ValidLink([Wmi] $ wmiLinkFile= $(throw "WMIリンクファイルが指定されていません"))
{
if(($ wmiLinkFile-eq $ null)-or([String] :: IsNullOrEmpty($ wmiLinkFile.Target)))
{
$falseを返す
}
Test-Path $ wmiLinkFile.Target
を返します}
#ショートカットファイルを削除する権限があるかどうかをチェチする機能
function Test-Delete([Wmi] $ wmiLinkFile= $(throw "WMIリンクファイルが指定されていません"))
{
if($ wmiLinkFile-eq $ null)
{
$falseを返す
}
return($ wmiLinkFile.AccessMask-band 0x10000)-eq 0x10000
}
#デスクトップパスを取得する関数
関数Get-DesktopPath()
{
$ methodDefinition= @ "
public static string GetDesktopPath
{
取得
{
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);を返します.
}
}
"@
$ type= Add-Type-MemberDefinition $ methodDefinition-Name "DesktopPath"-PassThru
$ type::GetDesktopPathを返す
}
#起動パスを取得する関数
関数Get-StartupPath()
{
$ methodDefinition= @ "
public static string GetStartupPath
{
取得
{
Environment.GetFolderPath(Environment.SpecialFolder.Startup);を返します.
}
}
"@
$ type= Add-Type-MemberDefinition $ methodDefinition-Name "StartupPath"-PassThru
$ type::GetStartupPathを返す
}
#リスト内のすべてのファイルを削除する関数
function Remove-FileList([string] $ list= $(throw "リストが指定されていません"))
{
if([String] :: IsNullOrEmpty($ list))
{
戻る
}
試してみてください
{
解析リスト$list| Foreach-Object {
if(-not([String] :: IsNullOrEmpty($ _)))
{
削除-アイテム$_-強制
}
}
}
キャッチ
{
$ _|ConvertTo-
}
}
#アイコンの最終アクセス時間を取得する関数
function Get-LastAccessTime([string] $ filePath= $(throw "ファイルパスが指定されていません"))
{
if([String] :: IsNullOrEmpty($ filePath)-or-not(Test-Path $ filePath))
{
「ファイルパスが見つかりません」をスローします
}
$ typeDefinition= @ "
システムを使用する;
System.Collections.Genericを使用します.
System.Runtime.InteropServicesを使用します.
comType=System.Runtime.InteropServices.comTypesを使用します.
パブリックシールクラスFileInfo
{
プライベートFileInfo()
{
}
[StructLayout(LayoutKind.Sequential、CharSet= CharSet.Unicode)]
構造体UAINFO
{
internal int cbSize;
internal int dwMask;
内部フロートR;
内部uintcLaunches;
内部uintcSwitches;
internal int dwTime;
内部comType.FILETIMEftExecute;
[MarshalAs(UnmanagedType.Bool)]内部ブールfExcludeFromMFU;
内部UAINFO(int dwMask)
{
this.cbSize= Marshal.SizeOf(typeof(UAINFO));
this.dwMask= dwMask;
this.R= 0;
this.cLaunches= 0;
this.cSwitches= 0;
this.dwTime= 0;
this.ftExecute= new comType.FILETIME();
this.fExcludeFromMFU= false;
}
}
internal const int UAIM_FILETIME= 1;
内部静的GUIDUAIID_SHORTCUTS= new Guid( "F4E57C4B-2036-45F0-A9AB-443BCFE33D9F");
[comImport、Guid( "90D75131-43A6-4664-9AF8-DCCEB85A7462")、InterfaceType(comInterfaceType.InterfaceIsIUnknown)]
インターフェイスIShellUserAssist
{
int FireEvent(ref Guid pguidGrp、int eCmd、string pszPath、int dwTimeElapsed);
int QueryEntry(ref Guid pguidGrp、string pszPath、ref UAINFO pui);
int SetEntry(ref Guid pguidGrp、string pszPath、ref UAINFO pui);
int RenameEntry(ref Guid pguidGrp、string pszFrom、string pszTo);
int DeleteEntry(ref Guid pguidGrp、string pszPath);
int Enable(bool fEnable);
}
[comImport、Guid( "DD313E04-FEFF-11d1-8ECD-0000F87A470C")]
内部クラスUserAssist{}
public static DateTime GetLastAccessTime(string filePath)
{
if(String.IsNullOrEmpty(filePath))
{
新しいArgumentException( "ファイルパスがnullまたは空です");をスローします.
}
UAINFO uaInfo= new UAINFO(UAIM_FILETIME);
IShellUserAssist iShellUserAssist= new UserAssist()as IShellUserAssist;
if(iShellUserAssist== null)
{
新しいInvalidOperationException( "iShellUserAssistインターフェイスを取得できません");をスローします.
}
試してみてください
{
Marshal.ThrowExceptionForHR(iShellUserAssist.QueryEntry(ref UAIID_SHORTCUTS、filePath、ref uaInfo));
}
キャッチ
{
新しいInvalidOperationException("についての情報を照会できません"+ filePath);をスローします.
}
long fileTime=(((long)uaInfo.ftExecute.dwHighDateTime)<<32)+ uaInfo.ftExecute.dwLowDateTime;
DateTime.FromFileTime(fileTime);を返します.
}
}
"@
$ type= Add-Type-TypeDefinition $ typeDefinition-PassThru
$ type [0] :: GetLastAccessTime($ filePath)
を返します}
#アイコンがファイルを指しているかどうかを確認する関数
function Test-FileShortcut([Wmi] $ wmiLinkFile= $(throw "Wmiリンクファイルが指定されていません"))
{
if($ wmiLinkFile-eq $ null)
{
$falseを返す
}
[文字列]$target= $ wmiLinkFile.Target
if([String] :: IsNullOrEmpty($ target)-or-not(Test-Path $ target))
{
$falseを返す
}
return-not((Get-Item $ target).PSIsContainer)
}
#インタラクションページで選択肢を作成する機能
function Get-Choice([string] $ name= $(throw "選択肢名が指定されていません")、[string] $ description= $(throw "選択肢の説明が指定されていません")、
[string] $ value= $(throw "選択肢の値が指定されていません")、[
{
@ {"Name"=$name;を返します."説明"=$ description;"値"=$ value;"ExtensionPoint"= $ extension.Inner
}
#現在のマシンがドメインに参加しているかどうかを確認する機能
関数テスト-DomainJoined()
{
return(Get-WmiObject-query "select* from Win32_ntdomain where Status='OK'")-ne $ null
}
#タイムソースを更新する関数
関数の更新-TimeSource([string] $ timeSource= $(throw "時間ソースが指定されていません"))
{
w32tm.exe/config/update/manualpeerlist: "$ timeSource"
}
#システムドライバ情報を取得する機能
関数Get-SystemDriveInfo(){
[文字列]$wql= "SELECT* FROM Win32_LogicalDisk WHERE MediaType= 12 AND Name='" + $ {env:systemdrive} + "'"
Get-WmiObject-query $ wql
を返します}
#タイムサービスステータスを取得する関数
function Get-ServiceStatus([string] $ serviceName= $(throw "サービス名が指定されていません")){
[bool] $ startService= $ true
[WMI] $ timeService= @(Get-WmiObject-Query "Select* From Win32_Service Where Name=` "$ serviceName`" ")[0]
if($ null-ne $ timeService){
[ServiceProcess.ServiceControllerStatus] $ timeServicesStatus=(Get-Service $ serviceName).Status
if(([ServiceProcess.ServiceControllerStatus] :: Stopped-eq $ timeServicesStatus)-or([ServiceProcess.ServiceControllerStatus] :: StopPending-eq $ timeServicesStatus)){
$ startService= $ false
}
}
$ startService
を返します}
#期待されるサービスステータスを待機する機能
function WaitFor-ServiceStatus([string] $ serviceName= $(throw "サービス名が指定されていません")、[ServiceProcess.ServiceControllerStatus] $ serviceStatus= $(throw "サービスステータスが指定されていません")){
[ServiceProcess.ServiceController] $ sc= New-Object "ServiceProcess.ServiceController" $ serviceName
[TimeSpan] $ timeOut= New-Object TimeSpan(0,0,0,5,0)
$ sc.WaitForStatus($ serviceStatus、$ timeOut)
}
ScriptBlock ID:13e9b2e8-1cbb-4279-b694-6ef6c113bd47
パス:C:\WINDOWS\TEMP\SDIAG-8719f62f-f3f5-4383-a522-c77b8213468e\CL_Utility.ps1
返信リスト(回答:2)
こんにちは、
マイクロソフトコミュニティフォーラムにご連絡いただきありがとうございます.
イベントビューアにログが表示されているとのことですが、確かに問題を解決します.
ただし、お知らせください:
コンピューターで問題が発生していますか?
プログラムの実行中にエラーメッセージ/コードが表示されますか?
この問題の前にコンピューターに加えられた変更を知っていますか?
コンピューターにインストールされているwindows 10のBuildversionはどれですか?参照 どのversionのWindowsオペレーティングシステムを実行していますか?
理想的には、PCが正常に動作していて問題が発生していない場合は、エラーメッセージを無視しても問題ありません.
ただし、PCで問題が発生した場合は、詳細をお知らせいただければ、さらにサポートさせていただきます.
よろしく、
Prakhar Khare
Microsoftコミュニティ–モデレーター
応答1# ->にスキップ2 #Uncreat
Windows 10
ホーム、現在問題は発生していません.ラップトップに変更を加えた人はいないと思います.また、プログラムでエラーメッセージを受け取ることもありません.