Powershell with SCCM 2012 r2

This topic contains 7 replies, has 3 voices, and was last updated by Profile photo of Doug Morrison Doug Morrison 2 years ago.

  • Author
    Posts
  • #20983
    Profile photo of Doug Morrison
    Doug Morrison
    Participant

    Hi Guys,

    Really stupid question, but having a bit of trouble with selecting properties for display as below:

    get-cmdevice -Name DeviceName | Select Name,Username,LastActiveTime

    All I get returned is the headers Name, Username, LastActiveTime. What am I missing, I know it's something simple...

    THanks

  • #20985
    Profile photo of Tim Pringle
    Tim Pringle
    Participant

    What output do you get if you just enter :

    get-cmdevice -Name DeviceName 

    ?

  • #20986
    Profile photo of Doug Morrison
    Doug Morrison
    Participant

    I get a return of all the attributes of the dvice, including Name, username and LastActiveTime

  • #20987
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Those are probably not the actual property names, they're probably just table headers.

    Get-CmDevice -Name DeviceName | Get-Member
    

    To verify the actual property names, which is what you must use with Select-Object.

  • #20988
    Profile photo of Doug Morrison
    Doug Morrison
    Participant

    Thanks for the reply, Don. I tried that already, but I don't see an alternative name from the output below. Any ideas?

    LastActiveTime                           Property              Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlResultObject LastActiveTime {get;set;}                                                    
    LastClientCheckTime                      Property              Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlResultObject LastClientCheckTime {get;set;}                                               
    LastDDR                                  Property              Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlResultObject LastDDR {get;set;}                                                           
    LastHardwareScan                         Property              Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlResultObject LastHardwareScan {get;set;}                                                  
    LastInstallationError                    Property              Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlResultObject LastInstallationError {get;set;}                                             
    LastMPServerName                         Property              Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlResultObject LastMPServerName {get;set;}                                                  
    LastPolicyRequest                        Property              Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlResultObject LastPolicyRequest {get;set;}                                                 
    LastSoftwareScan                         Property              Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlResultObject LastSoftwareScan {get;set;}                                                  
    LastStatusMessage                        Property              Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlResultObject LastStatusMessage {get;set;}                                                 
    LastSuccessSyncTimeUTC                   Property              Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlResultObject LastSuccessSyncTimeUTC {get;set;}                                            
    LatestProcessingAttempt                  Property              Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlResultObject LatestProcessingAttempt {get;set;}                                           
    Name                                     Property              Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlResultObject Name {get;set;}                        
  • #20989
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Well, I don't see UserName there, but assuming that was truncated output. Name and LastActiveTime should work.

    If you can pipe the output to Select *, then you should be able to pipe it to Select with a list of valid property names. If it doesn't, then sitting here I've no idea why that would be the case.

  • #20990
    Profile photo of Doug Morrison
    Doug Morrison
    Participant

    Sorry should have mentioned that I truncated the output from gm as there are about 50 returned items. This is the output when pipe to select *

    get-cmdevice -name DeviceName | select *
    ADLastLogonTime                          : 
    ADSiteName                               : 
    AMTFullVersion                           : 
    AMTStatus                                : 
    ClientActiveStatus                       : 1
    ClientCertType                           : 1
    ClientCheckPass                          : 1
    ClientEdition                            : 0
    ClientRemediationSuccess                 : 1
    ClientType                               : 1
    ClientVersion                            : 5.00.7958.1000
    DeviceAccessState                        : 
    DeviceOS                                 : Microsoft Windows NT Workstation 6.3
    DeviceOwner                              : 1
    DeviceType                               : 
    Domain                                   : 
    EASDeviceID                              : 
    EnrollmentStatus                         : 
    EPAntispywareEnabled                     : True
    EPAntispywareSignatureLastUpdateDateTime : 08/12/2014 02:13:03
    EPAntispywareSignatureLastVersion        : 1.189.1596.0
    EPAntivirusEnabled                       : True
    EPAntivirusSignatureLastUpdateDateTime   : 08/12/2014 02:13:03
    EPAntivirusSignatureLastVersion          : 1.189.1596.0
    EPClientVersion                          : 4.6.305.0
    EPDeploymentDescription                  : 
    EPDeploymentErrorCode                    : 0
    EPDeploymentState                        : 3
    EPEnabled                                : True
    EPEngineVersion                          : 1.1.11202.0
    EPInfectionStatus                        : 2
    EPLastFullScanDateTimeEnd                : 21/11/2014 18:20:27
    EPLastFullScanDateTimeStart              : 08/12/2014 10:34:46
    EPLastInfectionTime                      : 
    EPLastQuickScanDateTimeEnd               : 21/11/2014 11:09:39
    EPLastQuickScanDateTimeStart             : 08/12/2014 08:49:49
    EPLastThreatName                         : 
    EPPendingFullScan                        : False
    EPPendingManualSteps                     : False
    EPPendingOfflineScan                     : False
    EPPendingReboot                          : False
    EPPolicyApplicationDescription           : 
    EPPolicyApplicationErrorCode             : 0
    EPPolicyApplicationState                 : 1
    EPProductStatus                          : 0
    ExchangeOrganization                     : 
    ExchangeServer                           : 
    IsActive                                 : True
    IsAlwaysInternet                         : False
    IsAOACCapable                            : False
    IsApproved                               : 1
    IsBlocked                                : False
    IsClient                                 : True
    IsInternetEnabled                        : False
    IsObsolete                               : False
    IsVirtualMachine                         : False
    LastActiveTime                           : 08/12/2014 13:12:41
    LastClientCheckTime                      : 22/11/2014 19:59:14
    LastDDR                                  : 05/12/2014 15:10:57
    LastHardwareScan                         : 05/12/2014 15:24:30
    LastInstallationError                    : 
    LastMPServerName                         : 
    LastPolicyRequest                        : 08/12/2014 13:12:41
    LastSoftwareScan                         : 
    LastStatusMessage                        : 
    LastSuccessSyncTimeUTC                   : 
    LatestProcessingAttempt                  : 
    Name                                     : 
    PhoneNumber                              : 
    PolicyApplicationStatus                  : 
    ResourceID                               : 16777548
    ResourceType                             : 5
    RetireStatus                             : 
    SiteCode                                 : CCM
    SMSID                                    : GUID:9DD63644-849D-432C-91B1-FB8A89908AB5
    Status                                   : 
    SuppressAutoProvision                    : 
    Unknown                                  : False
    UserDomainName                           : CAN
    UserName                                 : MyUserName
    WipeStatus                               : 
    ManagedObject                            : \\CANSCCM01\root\sms\site_CCM:SMS_CombinedDeviceResources.ResourceID=16777548
    EmbeddedProperties                       : {}
    EmbeddedPropertyLists                    : {}
    OverridingObjectClass                    : SMS_CombinedDeviceResources
    RegMultiStringLists                      : {}
    SecurityVerbs                            : 1342176935
    GenericsArray                            : 
    Generics                                 : 
    Count                                    : 1
    DisplayString                            : 
    DisplayDescription                       : 
    HelpTopic                                : 
    ObjectClass                              : SMS_CombinedDeviceResources
    Properties                               : [SecurityVerbs(1342176935)]
                                               instance of SMS_CombinedDeviceResources
                                               {
                                                   ADSiteName = "";
                                                   ClientActiveStatus = 1;
                                                   ClientCertType = 1;
                                                   ClientCheckPass = 1;
                                                   ClientEdition = 0;
                                                   ClientRemediationSuccess = 1;
                                                   ClientType = 1;
                                                   ClientVersion = "5.00.7958.1000";
                                                   DeviceOS = "Microsoft Windows NT Workstation 6.3";
                                                   DeviceOwner = 1;
                                                   Domain = "";
                                                   EPAntispywareEnabled = TRUE;
                                                   EPAntispywareSignatureLastUpdateDateTime = "20141208021303.000000+***";
                                                   EPAntispywareSignatureLastVersion = "1.189.1596.0";
                                                   EPAntivirusEnabled = TRUE;
                                                   EPAntivirusSignatureLastUpdateDateTime = "20141208021303.000000+***";
                                                   EPAntivirusSignatureLastVersion = "1.189.1596.0";
                                                   EPClientVersion = "4.6.305.0";
                                                   EPDeploymentDescription = "";
                                                   EPDeploymentErrorCode = 0;
                                                   EPDeploymentState = 3;
                                                   EPEnabled = TRUE;
                                                   EPEngineVersion = "1.1.11202.0";
                                                   EPInfectionStatus = 2;
                                                   EPLastFullScanDateTimeEnd = "20141121182027.803000+***";
                                                   EPLastFullScanDateTimeStart = "20141208103446.917000+***";
                                                   EPLastQuickScanDateTimeEnd = "20141121110939.470000+***";
                                                   EPLastQuickScanDateTimeStart = "20141208084949.460000+***";
                                                   EPPendingFullScan = FALSE;
                                                   EPPendingManualSteps = FALSE;
                                                   EPPendingOfflineScan = FALSE;
                                                   EPPendingReboot = FALSE;
                                                   EPPolicyApplicationDescription = "";
                                                   EPPolicyApplicationErrorCode = 0;
                                                   EPPolicyApplicationState = 1;
                                                   EPProductStatus = 0;
                                                   IsActive = TRUE;
                                                   IsAlwaysInternet = FALSE;
                                                   IsAOACCapable = FALSE;
                                                   IsApproved = 1;
                                                   IsBlocked = FALSE;
                                                   IsClient = TRUE;
                                                   IsInternetEnabled = FALSE;
                                                   IsObsolete = FALSE;
                                                   IsVirtualMachine = FALSE;
                                                   LastActiveTime = "20141208131241.000000+***";
                                                   LastClientCheckTime = "20141122195914.937000+***";
                                                   LastDDR = "20141205151057.000000+***";
                                                   LastHardwareScan = "20141205152430.000000+***";
                                                   LastMPServerName = "";
                                                   LastPolicyRequest = "20141208131241.000000+***";
                                                   Name = "";
                                                   ResourceID = 16777548;
                                                   ResourceType = 5;
                                                   SiteCode = "CCM";
                                                   SMSID = "GUID:9DD63644-849D-432C-91B1-FB8A89908AB5";
                                                   Unknown = FALSE;
                                                   UserDomainName = "";
                                                   UserName = "";
                                               };
                                               
    PropertyNames                            : {ADLastLogonTime, ADSiteName, AMTFullVersion, AMTStatus...}
    MethodNames                              : 
    MethodList                               : {}
    PropertyList                             : {[ADLastLogonTime, ], [ADSiteName, ], [AMTFullVersion, ], [AMTStatus, ]...}
    UniqueIdentifier                         : f3bf93d6-a4f2-490b-9155-61c69336ee04
    ParentResultObject                       : 
    GlobalDisplayString                      : 
    AutoCommit                               : False
    AutoRefresh                              : False
    UserDataObject                           : 
    ConnectionManager                        : Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlConnectionManager
    TraceProperties                          : True
    NamedValueDictionary                     : {[ProviderLocation, \\\ROOT\sms:SMS_ProviderLocation.Machine="",SiteCode="CCM"], [ProviderMachineName, ], 
                                               [AllProviderLocations, System.Collections.Generic.List`1[System.Management.ManagementObject]], [Connection, \\\root\sms\site_CCM]...}
    AsyncOperationData                       : 
    RetainObjectLock                         : False
    

    I removed some of my personal info. Strange one...

    This is what I get from the original select

     PS CCM:\> get-cmdevice -Name MyDevice | Select-object name,username,lastactivetime
    
    name                                                                       username                                                                   lastactivetime                                                            
    ----                                                                       --------                                                                   --------------                                                            
                                                                                                                                                                                                                                    
    
    
    
    PS CCM:\> 
  • #20991
    Profile photo of Doug Morrison
    Doug Morrison
    Participant

    Argh. It's case sensitive. When selecting properties, you need to mind your capitalisation!

    Kudos to Dexter:

    http://www.dexterposh.com/2014/04/powershell-sccm-2012-r2-get-client-info.html

    Thanks for your input guys

You must be logged in to reply to this topic.