Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

View Creation Date/Time of a Powershell Variable

I’m trying to figure out a way to view the creation date/time of a variable in Powershell. For example if I create the variable:

PS C:\> $name = 'alice'
PS C:\> $name
alice

When I look at the available properties I only get:

PS C:\> Get-Variable name | Format-List

Name        : name
Description :
Value       : alice
Visibility  : Public
Module      :
ModuleName  :
Options     : None
Attributes  : {}

Is there another method that would show me the creation date/time of a variable?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Short answer: no.

Long answer: no without using workarounds logging the events.
Easiest case scenario would require creating all variables like this:

$ThisIsAVariable = 'But a String' | Add-Member -MemberType NoteProperty -Name Creationtime -Value (Get-date) -PassThru

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading