I’ve got a script that gathers information for a server from a couple of different places. The cmdlets for each location return objects, and I attach those as properties for my main output object. Like this:
PS C:\scripts> $output
DNSARecord : @{_ref=record:a/ZG5zLmJpbmRfYSQuX2RlZmF1bHQuY29tLmVwcm9kLHRzY
mxkaW5mMDFjb3JwLDEwLjk2LjEwOS4xMzc:servername.domain.com/d
efault; ipv4addr=10.10.10.10;
Credential=System.Management.Automation.PSCredential;
GridServer=DNSServer.domain.com}
DNSPTRRecord : @{_ref=record:ptr/ZG5zLmJpbmRfcHRyJC5fZGVmYXVsdC5hcnBhLmluLWF
kZHIuMTAuOTYuMTA5LjEzNy50c2JsZGluZjAxY29ycC5lcHJvZC5jb20:10.
10.10.10.in-addr.arpa/default; ipv4addr=10.10.10.10;
Credential=System.Management.Automation.PSCredential;
GridServer=DNSServer.domain.com}
LandeskAccount : {Microsoft.PowerShell.Commands.NewWebserviceProxy.Autogenerat
edTypes.WebServiceProxy1_mbsdkservice_msgsdk_asmx_wsdl.Device
, Microsoft.PowerShell.Commands.NewWebserviceProxy.Autogenera
tedTypes.WebServiceProxy1_mbsdkservice_msgsdk_asmx_wsdl.Devic
e}
DNSCNameRecord :
ComputerAccount : CN=SERVERNAME,OU=SMS,OU=Test,OU=Servers,DC=eprod,DC=com
Each of the output properties are objects themselves:
PS C:\scripts> $output.dnsarecord _ref ipv4addr Credential GridServer ---- -------- ---------- ---------- record:a/ZG5zLmJ... 10.10.10.10 System.Managemen... DNSServer.domain.com
PS C:\scripts> $output.DNSPTRRecord _ref ipv4addr Credential GridServer ---- -------- ---------- ---------- record:ptr/ZG5zL... 10.10.10.10 System.Managemen... DNSServer.domain.com
PS C:\scripts> $output.LandeskAccount
DisplayName : SERVERNAME
MaintenanceWindow :
LastVulnerabilityScanTime : 6/26/2014 2:58:50 AM
LastStartUpTime : 6/24/2014 9:20:13 AM
Type : Server
OperatingSystem : Microsoft Windows Server 2012 R2 Server Standard
Edition (full installation), 64-bit
OperatingSystemServicePack : 0
LastHardwareScanTime : 6/26/2014 1:04:13 AM
Model : ProLiant BL460c G7
SerialNumber : MXQ0420X8K
AgentConfigurationName : ServerOps
AgentVersion : 9.50.3.1
GUID : {2688A755-9424-EA4F-BC46-9259A378D005}
DeviceName : SERVERNAME
DomainName : domain.com
LastLogin :
IPAddress : 010.096.109.137
SubNetMask : 255.255.255.000
MACAddress : 68B599B1DD10
OSName : Microsoft Windows Server 2012 R2 Server Standard
Edition (full installation), 64-bit
PS C:\scripts> $output.ComputerAccount DistinguishedName : CN=SERVERNAME,OU=SMS,OU=Test,OU=Servers,DC=eprod,DC=com DNSHostName : SERVERNAME.domain.com Enabled : True Name : SERVERNAME ObjectClass : computer ObjectGUID : 7eb9f8e7-2034-4649-a310-40725d9cbacf SamAccountName : SERVERNAME$ SID : S-1-5-21-1327060583-1562144247-1555438652-151332 UserPrincipalName :
Is there a way to have the output expand out all the properties for easier viewing? Maybe with a ps1xml file or something? Kind of want it to look like this:
PS c:\scripts> $output DNSARecord :_ref :record:a/blahblah :ipv4addr :10.10.10.10 :credential :blah :gridserver :dnsserver.domain.com ComputerAccount :DistinguishedName :blah :dnshostname :servername.domain :SID :blah
Edit: ok the above is kind of wonky in the editor, but basically just want to expand out the objects in the properties and have it all in one screen. kind of like a select-object -expandproperty * or something.