0
[pscustomObject]@{...}
を使用して作成されたオブジェクト($var
)。私の開発用PC(Win7のx64の、PS 4.0)上のすべてのは、カスタムオブジェクト結構です:PS 4.0 Windows 7/Windows 2012 R2同じスクリプトの異なる結果
PS C:\Windows\system32> $var | gm
TypeName: Deserialized.System.Management.Automation.**PSCustomObject**
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
AddinExists NoteProperty AddinExists=null
AddinName NoteProperty Deserialized.System.Management.Automation.PSCustomObject AddinName=
ComputerName NoteProperty System.String ComputerName=xxxxxx
Description NoteProperty Description=null
FriendlyName NoteProperty FriendlyName=null
PSComputerName NoteProperty System.String PSComputerName=xxxxxx
PSPath NoteProperty PSPath=null
PSShowComputerName NoteProperty System.Boolean PSShowComputerName=True
RunspaceId NoteProperty System.Guid RunspaceId=xxxx4-015f-xxxx-a5a0-6a1861d0f164
SearchScope NoteProperty System.String SearchScope=HKU:\S-1-5-21-13434734552-3593029396-1545345-1234513\SOFTWARE\Microsoft\Office\...
UserLoggedOn NoteProperty System.Boolean UserLoggedOn=True
UserName NoteProperty System.String UserName=John
しかし2012 R2サーバー(PS 4.0)にそれがhastableとして、それを "見る":
PS C:\Windows\system32> $var | gm
TypeName: Deserialized.System.Collections.**Hashtable**
Name MemberType Definition
---- ---------- ----------
Add Method void Add(System.Object key, System.Object value), void IDictionary.Add(System.Object key, System.Object value)
Clear Method void Clear(), void IDictionary.Clear()
Clone Method System.Object Clone(), System.Object ICloneable.Clone()
Contains Method bool Contains(System.Object key), bool IDictionary.Contains(System.Object key)
ContainsKey Method bool ContainsKey(System.Object key)
ContainsValue Method bool ContainsValue(System.Object value)
CopyTo Method void CopyTo(array array, int arrayIndex), void ICollection.CopyTo(array array, int index)
Equals Method bool Equals(System.Object obj)
GetEnumerator Method System.Collections.IDictionaryEnumerator GetEnumerator(), System.Collections.IDictionaryEnumerator IDictionary.GetEnumerator(), System.Collections...
GetHashCode Method int GetHashCode()
GetObjectData Method void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context), void ISerializable...
GetType Method type GetType()
OnDeserialization Method void OnDeserialization(System.Object sender), void IDeserializationCallback.OnDeserialization(System.Object sender)
Remove Method void Remove(System.Object key), void IDictionary.Remove(System.Object key)
ToString Method string ToString()
PSComputerName NoteProperty System.String PSComputerName=LDNXD6002520
PSShowComputerName NoteProperty System.Boolean PSShowComputerName=True
RunspaceId NoteProperty System.Guid RunspaceId=basaaf35e-cdbb-4b5c-97bc-c9asdcaf8
Item ParameterizedProperty System.Object Item(System.Object key) {get;set;}
Count Property int Count {get;}
IsFixedSize Property bool IsFixedSize {get;}
IsReadOnly Property bool IsReadOnly {get;}
IsSynchronized Property bool IsSynchronized {get;}
Keys Property System.Collections.ICollection Keys {get;}
SyncRoot Property System.Object SyncRoot {get;}
Values Property System.Collections.ICollection Values {get;}
誰かが何か異常を引き起こしているアイデアはありますか?どのように修正することができますか?それは私のナッツを運転し、私のExport-Csv
をねじ込んでいます。まあ
$var = [PSCustomObject]@{
ComputerName = $ComputerName
UserName = $UserName
AddinName = $(if($v1){Split-Path $v1.PSPath -leaf})
FriendlyName = $v1.FriendlyName
Description = $v1.Description
PSPath = $v1.PSPath
UserLoggedOn = $False
PathExists = $v2
SearchScope = $searchScopes[$i]
}