LoginSignup
0
0

More than 5 years have passed since last update.

全てのCIM Classを取得して出力

Posted at

一部の名前空間は管理者としてアクセスする必要があるようです。

# 全名前空間の再帰出力
function getAllNameSpace() {
Param([string]$ns = "root");
$r = @($ns);
(Get-CimInstance __NAMESPACE -Namespace $ns -ErrorAction Continue).Name|
?{$_}|
%{getAllNameSpace("$ns/$_")|%{$r += $_}};
return $r;
}
# 全名前空間の取得
getAllNameSpace|
# 各名前空間でのクラス情報を取得
%{(Get-CimInstance meta_class -Namespace $_ -ErrorAction Continue)}|
# テーブル型に整形出力
Format-Table CimClass -AutoSize -HideTableHeaders|
# "名前空間:クラス名" 形式の行ごとの文字列に書き出し
Out-String -Stream|
# 前後の空白文字を除去
%{$_.Trim()}|
# 空行を除去
?{$_}|
# 名前順にソート
Sort-Object
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