1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【PowerShell】既定のプログラムの状態をログに出力する

Posted at
# ファイル名: Export-DefaultPrograms.ps1

$pcName = $env:COMPUTERNAME
$logPath = "$pcName`_default.log"
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
Add-Content $logPath "`n[$timestamp] 既定のプログラム一覧の出力開始"

# レジストリキーを取得
$extsPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts'
$exts = Get-ChildItem $extsPath

foreach ($ext in $exts) {
    $userChoicePath = "$extsPath\$($ext.PSChildName)\UserChoice"
    if (Test-Path $userChoicePath) {
        $progId = (Get-ItemProperty $userChoicePath).ProgId
        Add-Content $logPath "$($ext.PSChildName) => $progId"
    }
}

$timestampEnd = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
Add-Content $logPath "[$timestampEnd] 出力完了"
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?