1
我想用下面的屬性添加一個自定義對象到powershell數組中。我已經嘗試了各種選項,但無法獲得這種對象添加到數組的適當語法。 Iam使用Powershell V2。請幫忙。將自定義對象添加到Powershell中的數組
PS C:\Windows\system32> $executemultiplerequest | Get-member
TypeName: Microsoft.Xrm.Sdk.Messages.ExecuteMultipleRequest
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Item ParameterizedProperty System.Object Item(string parameterName) {get;set;}
ExtensionData Property System.Runtime.Serialization.ExtensionDataObject ExtensionData {get;set;}
Parameters Property Microsoft.Xrm.Sdk.ParameterCollection Parameters {get;set;}
RequestId Property System.Nullable`1[[System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, Publ...
RequestName Property System.String RequestName {get;set;}
Requests Property Microsoft.Xrm.Sdk.OrganizationRequestCollection Requests {get;set;}
Settings Property Microsoft.Xrm.Sdk.ExecuteMultipleSettings Settings {get;set;}
添加選項我曾嘗試:
這裏是我有嘗試過的樣品:
$item = New-Object System.Object
$item | Add-Member -MemberType Method -Name Equals $executemultiplerequest.Equals -MemberType Property $executemultiplerequest.ExtensionData
$array += item
我收到我之前也去到商店到一個數組的錯誤。收到的Add-構件排列的錯誤爲:
Add-Member : Cannot add a member with type "Method". Specify a different type for the MemberTypes parameter.
_I_ _have_ _tried_ _various_ _options_ - >你嘗試了什麼?你能告訴我們一些代碼嗎? –
下面是我試過的示例:\t \t $ item = New-Object System.Object $ item |添加成員-MemberType方法-Name等於$ executemultiplerequest.Equals $ array + = item $ item = New-Object System.Object $ item |添加成員-MemberType屬性$ executemultiplerequest.ExtensionData $ array + = item –
你能編輯你的問題並添加它們嗎?在評論中很難閱讀;) –