CREATED-ON field for a user appears empty using ISHRemote

Hi,

I am trying to find out the created date for user objects but they appear to be empty.

I presume there is something wrong with my script as every object should have a created date.

Can someone review my script and see if I am missing something?

Thanks in advance,

Ann

# Connect to Tridion

#set requestedMetadata
$requestedMetadata = Set-IshRequestedMetadataField -IshSession $ishSession -Name 'USERNAME' -Level 'none' | `
Set-IshRequestedMetadataField -IshSession $ishSession -Name 'CREATED-ON' -Level "none"


$ishUsers = Find-IshUser -IshSession $ishSession -MetadataFilter (Set-IshMetadataFilterField -Name FISHLASTLOGINON -Level None -FilterOperator EMPTY | Set-IshMetadataFilterField -Name CREATED-ON -Level None -FilterOperator NOTEMPTY) -RequestedMetadata $requestedMetadata


Write-Host "Number of users found -" $ishUsers.count

foreach($ishUser in $ishUsers)
{
$user = Get-IshUser -IshSession $ishSession -IshObject $ishUser

$username = ($user.IshField | where Name -eq USERNAME).value
$lastlogon = ($user.IshField | where Name -eq FISHLASTLOGINON).value
$createdon = ($user.IshField | where Name -eq CREATED-ON).value

Write-Host $username "Last logon:" $lastlogon " Created On:" $createdon

}

emoji
Parents
  • Hi Ann,

    Not really sure if this is a layout thing or your actual code but the below is a rewrite avoiding the backtick (`) and longer lines. Allow me to reformat that line of code and explain

    # requestedMetadata, so what fields to retrieve, using implicit IshSession, no quotes and no backtick on line continuation
    $requestedMetadata = Set-IshRequestedMetadataField -Level None -Name USERNAME  |
                         Set-IshRequestedMetadataField -Level None -Name CREATED-ON
    $filterMetadata = Set-IshMetadataFilterField -Level None -Name FISHLASTLOGINON -FilterOperator EMPTY |
                      Set-IshMetadataFilterField -Level None -Name CREATED-ON -FilterOperator NOTEMPTY
    
    $ishUsers = Find-IshUser -MetadataFilter $filterMetadata -RequestedMetadata $requestedMetadata
    Write-Host "Number of users found -" $ishUsers.count
    
    # Before you did superfluous Get-IshUser calls (extra API calls) that already happened on Find-IshUsers ... there was actually no difference between $ishUser from your loop parameter and the re-retrieved $user
    # There is already extra requested metadata retrieved and made available as readonly properties
    foreach($ishUser in $ishUsers)
    {
        Write-Host "Username: " $ishUser.username "Last logon:" $ishUser.fishlastloginon " Created On:" $ishUser.createdon
    }

    Those read-only properties and which fields are retrieved on top of your requested $requestedMetadata is explained in the Release Notes of ISHRemote v0.7, see  https://github.com/RWS/ISHRemote/releases/tag/v0.7 ... a duplication for convenience

    • The -RequestedMetadata parameter is still optional, but got more sensible defaults when not specified. So which fields will it use? This is controlled by $ishSession.DefaultRequestedMetadata which defaults to Basic.
      • When using Basic you get the fields for the used object types (ISHType) identified as Basic, typically these are the human readable fields like FTITLE, FSTATUS, etc. See the column marked with B in Get-IshTypeFieldDefinition.
      • When using Descriptive, you get back the v0.6 version behavior. This is the most performant option avoiding the overhead of PSNoteProperty generation on the client. The Descriptive fields are considered the primary keys of the objects. See the column marked with D in Get-IshTypeFieldDefinition.
      • When using All, you don't care about performance. You will get all fields for the used object types (ISHType), this includes Descriptive, Basic and System as visible in Get-IshTypeFieldDefinition.
    • More explicit derived types of IshObject like IshDocumentObj, IshPublicationOutput together with PSNoteProperty generation for all requested <ishfields> allows nicer rendering and better interactivity. This is controlled by $ishSession.PipelineObjectPreference which defaults to PSObjectNoteProperty or can be turned Off if desired for performance reasons but then PowerShell might not be the right answer anyway.
      • PSNoteProperty are read-only, you cannot assign new values to them, for that you still need Set-IshMetadataField
      • PSNoteProperty naming convention is the field name lowercased first stripping hyphens, then separator underscore, then lowercased level, then separator underscore, and then lowercased value type. Two shortcuts are omitting the leading level like Task, None, Progress or Language and the most used value type Value.
        • ISHDocumentObj examples: logical-level FTITLE value will be ftitle_logical_value, language-level FSTATUS value will be fstatus but language-level FSTATUS element will be fstatus_lng_element. DOC-LANGUAGE gets stripped of the hyphen, otherwise you get $ishObject.'doc-language' and now you get the more readable $ishObject.doclanguage
        • ISHBaseline examples: none-level FISHDOCUMENTRELEASE value will be fishdocumentrelease and none-level FISHDOCUMENTRELEASE element will be fishdocumentrelease_none_element
      • So by default Basic fields everywhere, which in turn allows much nicer *.format.ps1xml rendering and easier Where-Object filtering
      • Where possible PSNoteProperty hold a sortable date (format s) so for example 2005-08-09T15:29:31 already converting the hardcoded dd/MM/yyyy HH:mm:ss for you. Note that these are all still WebApp-server-time-zone times, no automatic time zone adjustments.

    Best wishes,
    Dave

    emoji
Reply
  • Hi Ann,

    Not really sure if this is a layout thing or your actual code but the below is a rewrite avoiding the backtick (`) and longer lines. Allow me to reformat that line of code and explain

    # requestedMetadata, so what fields to retrieve, using implicit IshSession, no quotes and no backtick on line continuation
    $requestedMetadata = Set-IshRequestedMetadataField -Level None -Name USERNAME  |
                         Set-IshRequestedMetadataField -Level None -Name CREATED-ON
    $filterMetadata = Set-IshMetadataFilterField -Level None -Name FISHLASTLOGINON -FilterOperator EMPTY |
                      Set-IshMetadataFilterField -Level None -Name CREATED-ON -FilterOperator NOTEMPTY
    
    $ishUsers = Find-IshUser -MetadataFilter $filterMetadata -RequestedMetadata $requestedMetadata
    Write-Host "Number of users found -" $ishUsers.count
    
    # Before you did superfluous Get-IshUser calls (extra API calls) that already happened on Find-IshUsers ... there was actually no difference between $ishUser from your loop parameter and the re-retrieved $user
    # There is already extra requested metadata retrieved and made available as readonly properties
    foreach($ishUser in $ishUsers)
    {
        Write-Host "Username: " $ishUser.username "Last logon:" $ishUser.fishlastloginon " Created On:" $ishUser.createdon
    }

    Those read-only properties and which fields are retrieved on top of your requested $requestedMetadata is explained in the Release Notes of ISHRemote v0.7, see  https://github.com/RWS/ISHRemote/releases/tag/v0.7 ... a duplication for convenience

    • The -RequestedMetadata parameter is still optional, but got more sensible defaults when not specified. So which fields will it use? This is controlled by $ishSession.DefaultRequestedMetadata which defaults to Basic.
      • When using Basic you get the fields for the used object types (ISHType) identified as Basic, typically these are the human readable fields like FTITLE, FSTATUS, etc. See the column marked with B in Get-IshTypeFieldDefinition.
      • When using Descriptive, you get back the v0.6 version behavior. This is the most performant option avoiding the overhead of PSNoteProperty generation on the client. The Descriptive fields are considered the primary keys of the objects. See the column marked with D in Get-IshTypeFieldDefinition.
      • When using All, you don't care about performance. You will get all fields for the used object types (ISHType), this includes Descriptive, Basic and System as visible in Get-IshTypeFieldDefinition.
    • More explicit derived types of IshObject like IshDocumentObj, IshPublicationOutput together with PSNoteProperty generation for all requested <ishfields> allows nicer rendering and better interactivity. This is controlled by $ishSession.PipelineObjectPreference which defaults to PSObjectNoteProperty or can be turned Off if desired for performance reasons but then PowerShell might not be the right answer anyway.
      • PSNoteProperty are read-only, you cannot assign new values to them, for that you still need Set-IshMetadataField
      • PSNoteProperty naming convention is the field name lowercased first stripping hyphens, then separator underscore, then lowercased level, then separator underscore, and then lowercased value type. Two shortcuts are omitting the leading level like Task, None, Progress or Language and the most used value type Value.
        • ISHDocumentObj examples: logical-level FTITLE value will be ftitle_logical_value, language-level FSTATUS value will be fstatus but language-level FSTATUS element will be fstatus_lng_element. DOC-LANGUAGE gets stripped of the hyphen, otherwise you get $ishObject.'doc-language' and now you get the more readable $ishObject.doclanguage
        • ISHBaseline examples: none-level FISHDOCUMENTRELEASE value will be fishdocumentrelease and none-level FISHDOCUMENTRELEASE element will be fishdocumentrelease_none_element
      • So by default Basic fields everywhere, which in turn allows much nicer *.format.ps1xml rendering and easier Where-Object filtering
      • Where possible PSNoteProperty hold a sortable date (format s) so for example 2005-08-09T15:29:31 already converting the hardcoded dd/MM/yyyy HH:mm:ss for you. Note that these are all still WebApp-server-time-zone times, no automatic time zone adjustments.

    Best wishes,
    Dave

    emoji
Children
No Data