我正在使用SMLets
(与 System Center 一起使用的 cmdlet 集合)PowerShell
来创建类的对象。我知道我不应该创建抽象类的对象,但我不确定我可以选择什么其他类。我正在尝试在 中创建一个组System Center Service Manager
,据我所知,配置项组的类是我要输入的类...
我的代码是:
#Get the name of the class I want to create an object of and store it in a variable
$groupClass = Get-SCSMClass -Name "Microsoft.SystemCenter.ConfigItemGroup$"
#Return the variable stored to ensure this part is working (Debug purposes)
$groupClass
#Get the active status of an object and store it in a variable
$objStatus = Get-SCSMEnumeration -Name System.ConfigItem.ObjectStatusEnum.Active
#Return the variable stored to ensure this part is working (Debug purposes)
$objStatus
#Create the object stored in my class variable and modify the DisplayName and ObjectStatus properties.
New-SCSMObject -Class $groupClass -PropertyHashtable (@{DisplayName = "Test"; ObjectStatus = $objStatus;}) -Debug -Verbose
一旦我得到这个代码,我的想法是从一个包含所有组列表的 csv 文件中读取并循环创建过程。但是,我不断收到错误消息:“无法创建抽象类的对象”
我是否使用不正确的类来创建组?如果是这样,选择的正确班级是什么?有没有更有效的方法来做到这一点?任何想法都请分享,提前谢谢你:)