0
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?

MCM(SCCM)の棚卸し

0
Posted at

Microsoft Configuration Manager(MCM / 旧SCCM)内に長年溜まった配信資産の棚卸し(整理)が必要になる場面が増えています。

特に問題となるのは**「展開(Deployment)自体は有効なまま放置されているが、実際には誰も使っていない・動いていない資産」**です。

本記事では、展開が停止していない「隠れ不要資産」をSQLクエリやPowerShellを使って一括抽出・調査する方法をまとめます。


調査のターゲット

棚卸し時に特定すべき「動いていない資産」は主に以下のパターンです。

  1. 展開は設定されているが、成功数(Success)や対象数が 0 件のアプリ
  2. 展開先コレクションのメンバー(端末)が既に 0 件になっているもの
  3. 「利用可能(Available)」で配信されているが、誰にもインストールされていないもの

方法1:PowerShellスクリプトで一括調査・CSV出力

MCMのPowerShellモジュールを使用し、**「アクティブな展開はあるが、成功数が0件(=実動していない)」**アプリやパッケージを判定してCSVに出力します。

実行コード

$SiteCode をご自身の環境(例: P01)に書き換えて、管理者権限のPowerShellで実行してください。

<#
.SYNOPSIS
    MCM内でアクティブな展開が存在するものの、実績が0件のアプリケーションを抽出します。
#>

# --- 設定 ---
$SiteCode   = "YOUR_SITE_CODE" # サイトコードを指定
$OutputPath = "C:\Temp\MCM_Unused_Deployments.csv"

# --- モジュール読み込みとドライブ移動 ---
$ErrorActionPreference = "Stop"
if (-not (Get-Module -Name ConfigurationManager)) {
    Import-Module "$($ENV:SMS_ADMIN_MODEL_PATH)\..\ConfigurationManager.psd1"
}
if ((Get-Location).Path -ne "$($SiteCode):") {
    Set-Location "$($SiteCode):"
}

Write-Host "=== 未使用展開の調査を開始します ===" -ForegroundColor Cyan
$Results = [System.Collections.Generic.List[PSObject]]::new()

# アプリケーション展開の確認
$Apps = Get-CMApplication
foreach ($App in$Apps) {
    $Deployments = Get-CMApplicationDeployment -Name$App.LocalizedDisplayName
    
    if ($Deployments) {
        # 成功数および進行中数が0の展開を抽出
        $InactiveDeployments =$Deployments | Where-Object { $_.NumberSuccess -eq 0 -and$_.NumberInProgress -eq 0 }
        
        # 設定されている全ての展開が非アクティブな場合
        if ($InactiveDeployments.Count -eq $Deployments.Count) {$Results.Add([PSCustomObject]@{
                ObjectType     = "Application"
                Name           = $App.LocalizedDisplayName
                DeploymentCount= $Deployments.Count
                CollectionName = ($Deployments.CollectionName -join " | ")
                DateCreated    = $App.DateCreated
                Status         = "展開はあるが成功数・進行中数が 0"
            })
        }
    }
}

# --- CSV出力 ---
if ($Results.Count -gt 0) {$Results | Format-Table -AutoSize
    
    $Directory = Split-Path$OutputPath
    if (-not (Test-Path $Directory)) { New-Item -ItemType Directory -Path$Directory | Out-Null }
    
    $Results \vert{} Export-Csv -Path$OutputPath -NoTypeInformation -Encoding UTF8
    Write-Host "抽出完了: $($Results.Count) 件を出力しました -> $OutputPath" -ForegroundColor Green
} else {
    Write-Host "該当する不要な展開は見つかりませんでした。" -ForegroundColor Green
}
0
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
0
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?