PowerShell script exchange
Post Reply
Daniel N.
Enthusiast
Posts: 52
Liked: 5 times
Joined: Feb 15, 2015 7:03 am
Contact:

Please Remove Labels From Types.ps1xml

Post by Daniel N. »

Hi Veeam,

I like to propose to you, to remove all labels from Types.ps1xml files. You are re-labeling essential properties, which makes it hard to write scripts.

Take the Backup Sessions, for example. It's great that if someone writes an object to the Information Stream, they have the most important values displayed as a formatted table or list.
What is not great is that you also re-label the object's properties in the Types.ps1xml. If someone used to PowerShell sees this ...

Code: Select all

PS C:\> $bs[0]

Job Name             State      Start Time             End Time               Result
--------             -----      ----------             --------               ------
minio-job (Increm... Stopped    11.09.2021 02:00:14    11.09.2021 02:02:45    Success
... they would naturally think that they can get the start time via

Code: Select all

$bs[0].StartTime
But this returns $null, because what is displayed as "Start Time" does not exist. It is actually a property with the name of "CreationTime". If one does not know about Types.ps1xml, they will probably now know what's going on.

Some other examples are:

Veeam.Backup.Core.CBackup / Name -> Job Name
Veeam.Backup.Core.CRestoreSession / JobType -> Restore Type
Veeam.Backup.Core.CRestoreSession / JobName-> VM Name


When you compare formatted objects with all cmdlets that are shipped with Windows, you notice that this kind of re-labelling is not standard. Just one example, this ...

Code: Select all

PS C:\> get-item C:

    Directory:

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d--hs-        13.04.2022     08:15                C:\
... returns "LastWriteTime", not "Last Write Time". The property name is passed unchanged and you will know that you can this will work, without having to guess:

Code: Select all

PS C:\> get-item C: | select LastWriteTime
chris.arceneaux
VeeaMVP
Posts: 695
Liked: 374 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Georgia, USA
Contact:

Re: Please Remove Labels From Types.ps1xml

Post by chris.arceneaux »

Hi Daniel,

Thanks for the feedback! In the meantime, if you'd like to find out names of all properties available (instead of guessing), you can use the Get-Member cmdlet.

Here's an example:

Image

Image
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Please Remove Labels From Types.ps1xml

Post by oleg.feoktistov »

Hi Daniel,

I agree that it looks confusing, noted for further internal discussions.
Thanks for your feedback!


Best regards,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests