一時的なメモ置き場 Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* , HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Where-Object { $_.DisplayName -ne $null } | Sort-Object DisplayName | Export-Csv -Path "C:\Temp\InstalledPrograms.csv" -NoTypeInformation -Encoding UTF8 Get-AppxPackage | Select-Object Name, Version, Publisher | Export-Csv -Path "C:\Temp\StoreApps.csv" -NoTypeInformation -Encoding UTF8 Get-WindowsOptionalFeature -Online | Where-Object {$_.State -eq "Enabled"} | Select-Object FeatureName, State | Export-Csv -Path "C:\Temp\WindowsFeatures.csv" -NoTypeInformation -Encoding UTF8 Get-ChildItem "C:\Program Files", "C:\Program Files (x86)", "C:\Users\*\AppData\Local\Programs" -Directory | Select-Object FullName | Export-Csv -Path "C:\Temp\FolderApps.csv" -NoTypeInformation -Encoding UTF8 # merge-hosts.ps1 $hostsPath = "$env:SystemRoot\System32\drivers\etc\hosts" # ネットワーク上の共有フォルダ(UNCパス) $userName = $env:USERNAME $userAddFile = "\\fileserver\share\hosts\$userName\hosts_addition.txt" # 追加ファイルが存在しない場合は終了 if (-not (Test-Path $userAddFile)) { exit } # 追加ファイルを1行ずつ読み込む Get-Content $userAddFile | ForEach-Object { $entry = $_.Trim() if ($entry -ne "") { if (-not (Select-String -Path $hostsPath -Pattern [regex]::Escape($entry))) { Add-Content -Path $hostsPath -Value $entry } } } # Windowsのhostsファイルのパス $hostsPath = "$env:SystemRoot\System32\drivers\etc\hosts" # ログイン中のユーザー名 $userName = $env:USERNAME # ネットワーク共有上の追加定義ファイル $userAddFile = "\\fileserver\share\hosts\$userName\hosts_addition.txt" # 追加ファイルが存在しなければ終了 if (-not (Test-Path $userAddFile)) { Write-Output "追加ファイルが見つかりません: $userAddFile" exit } # hosts の現在内容(Trimして余分な空白を無視) $hostsCurrent = Get-Content $hostsPath | ForEach-Object { $_.Trim() } # 追加ファイルを1行ずつ処理 Get-Content $userAddFile | ForEach-Object { $entry = $_.Trim() if ($entry -ne "") { if ($hostsCurrent -notcontains $entry) { Add-Content -Path $hostsPath -Value $entry Write-Output "追記しました: $entry" } } } Write-Output "処理完了" Get-CimInstance Win32_Service | ForEach-Object { $regPath = "HKLM:\SYSTEM\CurrentControlSet\Services\$($_.Name)" $props = Get-ItemProperty -Path $regPath -ErrorAction SilentlyContinue $delayed = if ($props.DelayedAutostart -eq 1) {"Automatic (Delayed Start)"} else {""} $trigger = if (Test-Path "$regPath\TriggerInfo") {"Manual (Trigger Start)"} else {""} [PSCustomObject]@{ DisplayName = $_.DisplayName Name = $_.Name State = $_.State StartMode = $_.StartMode StartupType = if ($delayed) {$delayed} elseif ($trigger) {$trigger} else {$_.StartMode} } } | Format-Table -AutoSize Get-CimInstance Win32_Service | ForEach-Object { $regPath = "HKLM:\SYSTEM\CurrentControlSet\Services\$($_.Name)" $props = Get-ItemProperty -Path $regPath -ErrorAction SilentlyContinue $delayed = $props.DelayedAutostart $hasTrigger = Test-Path "$regPath\TriggerInfo" $startupType = switch ($_.StartMode) { "Disabled" { "Disabled" } "Auto" { if ($delayed -eq 1) { "Automatic (Delayed Start)" } elseif ($hasTrigger) { "Automatic (Trigger Start)" } else { "Automatic" } } "Manual" { if ($hasTrigger) { "Manual (Trigger Start)" } else { "Manual" } } } [PSCustomObject]@{ DisplayName = $_.DisplayName Name = $_.Name State = $_.State StartupType = $startupType } } | Format-Table -AutoSize バッチファイルを C:\ProgramData\Microsoft\Windows\Start Menu に作成します。 mount.bat net use Z: \\192.168.10.2\shared /persistent:yes これにより、どのユーザーがログインしてもZドライブとして共有フォルダが利用できるようになります。