PSTファイルの容量情報のレポーティング
クライアントが保持している特定のファイル形式の一覧と容量を調査したい…というニーズは結構あると思います。 ここではたとえば「ユーザーがローカルで保持しているPSTファイルの一覧と容量を調査する」という例でその実装方法を紹介したいと思います。 ### クライアント設定(ソフトウェアインベントリ) まずクライアント設定を作成します。規定のクライアント設定を変更しても良いですが、別の設定を作成したほうが柔軟に対応できるかなと思います。 この例では*.pstファイルの情報を収集するように設定しています。 作成した設定を展開していきます。 ここではもちろん任意のコレクションを選択することが出来ます。 単に待っていると下手をすると1週間とか待たなくてはいけないので「コンピューター ポリシーの取得および評価サイクル」と「ソフトウェア インベントリ サイクル」を「直ちに実行」しておきます。 これでもしばらく待つことになりますが、クライアント側のC:\Windows\CCM\LogsInventoryAgent.logを見るとソフトウェアインベントリが行われている状況が確認できます。 Inventory: *********************** Start of message processing. *********************** InventoryAgent 2015/07/08 12:25:06 10944 (0x2AC0) Inventory: Message type is InventoryAction InventoryAgent 2015/07/08 12:25:06 10944 (0x2AC0) Inventory: Temp directory = C:\Windows\CCM\Inventory\Temp\ InventoryAgent 2015/07/08 12:25:06 10944 (0x2AC0) Inventory: Clearing old collected files. InventoryAgent 2015/07/08 12:25:06 10944 (0x2AC0) Inventory: Opening store for action {00000000-0000-0000-0000-000000000002} … InventoryAgent 2015/07/08 12:25:06 10944 (0x2AC0) InventoryVersionNumber for ‘{00000000-0000-0000-0000-000000000002}’ not found. InventoryAgent 2015/07/08 12:25:06 10944 (0x2AC0) CInvState::VerifyInventoryVersionNumber: Couldn’t get version number for ‘{00000000-0000-0000-0000-000000000002}’: 80070490 InventoryAgent 2015/07/08 12:25:06 10944 (0x2AC0) Inventory: Delta report without a previous Full report; will do a Full report. InventoryAgent 2015/07/08 12:25:06 10944 (0x2AC0) Inventory: Action=Software, ReportType=Full, MajorVersion=1, MinorVersion=0 InventoryAgent 2015/07/08 12:25:06 10944 (0x2AC0) Inventory: Initialization completed in 0.046 seconds InventoryAgent 2015/07/08 12:25:06 10944 (0x2AC0) Inventory: Message [Type=InventoryAction, ActionID={00000000-0000-0000-0000-000000000002}, Report=Delta] already in queue. Message ignored. InventoryAgent 2015/07/08 12:34:38 11588 (0x2D44) CThrottler::Throttle()[{C0ED66AD-8194-49FD-9826-D0DD38AB7DAA}] - soft timeout exceeded. Throttling is now disabled for the current iteration of this task. InventoryAgent 2015/07/08 14:25:08 5980 (0x175C) Collection: Input context, scan rate in milliseconds = 2 InventoryAgent 2015/07/08 14:25:08 5980 (0x175C) Collection: Input context, skip file name = skpswi.dat InventoryAgent 2015/07/08 14:25:08 5980 (0x175C) Collection: Namespace = \.\root\ccm\invagt; Query = SELECT Name, Path, LastWriteDate, Size, CompanyName, ProductName, ProductVersion, ProductLanguage, FileVersion, FileDescription FROM FileSystemFile WHERE Name = ‘.pst’ AND Path = ‘\*’ AND SkipWindirFolders = TRUE AND IsCompressed = FALSE AND IsEncrypted = FALSE; Timeout = 14400 secs. InventoryAgent 2015/07/08 14:25:08 5980 (0x175C) Inventory: Collection Task completed in 7824.094 seconds InventoryAgent 2015/07/08 14:35:31 13364 (0x3434) Inventory: Temp report = C:\Windows\CCM\Inventory\Temp\148a9b9e-6ffc-4966-b228-bc89d47643a2.xml InventoryAgent 2015/07/08 14:35:31 13364 (0x3434) Collection: 1/1 inventory data items successfully inventoried. InventoryAgent 2015/07/08 14:35:31 13364 (0x3434) Inventory: Starting reporting task. InventoryAgent 2015/07/08 14:35:31 14508 (0x38AC) Reporting: 1 report entries created. InventoryAgent 2015/07/08 14:35:31 14508 (0x38AC) Inventory: Reporting Task completed in 0.031 seconds InventoryAgent 2015/07/08 14:35:31 14508 (0x38AC) Inventory: Successfully sent report. Destination:mp:MP_SinvEndpoint, ID: {79FE0043-18F1-4463-AB89-CF55DE7B8D14}, Timeout: 80640 minutes MsgMode: Signed, Not Encrypted InventoryAgent 2015/07/08 14:35:31 14508 (0x38AC) Inventory: Cycle completed in 7824.562 seconds InventoryAgent 2015/07/08 14:35:31 14508 (0x38AC) Inventory: Action completed. InventoryAgent 2015/07/08 14:35:31 14508 (0x38AC) Inventory: ************************ End of message processing. ************************ InventoryAgent 2015/07/08 14:35:31 14508 (0x38AC) 結果、ソフトウェアインベントリでファイルの情報を確認することができました。 削除してゴミ箱に入っているデータもレポートに含まれていますね。 ### レポートの利用 1台ずつリソースエクスプローラーで確認するのも大変なので、レポートで一括で確認してみます。 標準のレポートとしては以下のあたりがソフトウェアインベントリで収集したファイルを確認できるレポートです。 残念ながら、規定で用意されているサポートだと特定のコンピューターを指定する、特定のファイル名を指定する…ということをしないと情報が出力出来ず用途によってはちょっと不便ですね。 ここはカスタマイズしたレポートを作成する、あるいは直接SQL DBの中を覗く…という対応が良さそうです。 ### SCCMのDBスキーマ SCCMのSQL DBのスキーマはきちんと公開されています。 - SQL Server Views in System Center 2012 Configuration Manager 直接テーブルを参照するのではなく、ビューを通して参照することはサポートされています。 今回はソフトウェアインベントリの結果を参照したいので、以下が該当します。 - Software Inventory Views in Configuration Manager v_GS_SoftwareFile Lists the files and associated product IDs on each Configuration Manager client. The view can be joined to other views by using the ResourceID column. このビューの中身を見てみます。 きちんと収集されている情報が見られますね。 ### 既存のレポートの参照 コンピューター名の情報などは普通に欲しくなると思いますので、ResourceIDをキーにして紐付けばよい…のですが、自分で全部一から調べるよりも既存のレポートがどのように情報を生成しているのかを調べたほうが楽ですね。 > Select SYS.Netbios_Name0, SYS.Resource_Domain_OR_Workgr0, SF.FileName, SF.FileDescription, SF.FileVersion, SF.FileSize, SF.FileModifiedDate, SF.FilePath from fn_rbac_GS_SoftwareFile(@UserSIDs) SF join fn_rbac_R_System(@UserSIDs) SYS on SF.ResourceID = SYS.ResourceID WHERE SYS.Netbios_Name0 Like @variable Order by SF.FileName レポートは権限にもとづいて必要なもののみが表示されるように実装されているので、@UserSIDsなどがつかわれていて若干難しいですね。詳細は以下が参考になります。 - How to create an RBA capable report for ConfigMgr R2 - The Config Ninja Blog - Site Home - TechNet Blogs とりあえず、権限のコントロールは無視し、コンピューター名で絞らずに全部出すようにします。 > Select SYS.Netbios_Name0, SYS.Resource_Domain_OR_Workgr0, SF.FileName, SF.FileDescription, SF.FileVersion, SF.FileSize, SF.FileModifiedDate, SF.FilePath from v_GS_SoftwareFile SF join v_R_System SYS on SF.ResourceID = SYS.ResourceID Order by SF.FileName ...