Microsoft Virtualization Discussions

Converting the dates from DataOnTap results?

GINOLARD99
3,809 Views

has anyone had any success parsing the dates returned from some DataOnTap cmdlets?

In particular, the LastOperationEnd date value returned from Get-NAVolSis which, annoyingly, returns a string value containing the Timezone info (e.g. CEST 2014) which .NET/Powerhsell doesn't handle at all well

edit: I notice some other cmdlets (get-NaSnapshot for example, return a proper datetime value).  Why doesn't Get-NaSISVol do the same?  This seems like a glaring inconsistency to me.

7 REPLIES 7

JGPSHNTAP
3,809 Views

Matt -

Interesting... you can always created a custom object and redo it if you want, but why would we do that 🙂

What exactly do you need the system.datetime for in this cmdlet?

GINOLARD99
3,809 Views

I'm writing a script to monitor certain things on our filers.  One of the requirements is to check that the dedupe ran within the last 24 hours.

I've since found that I can use Get-NASis <volname> and that returns a DT formatted value (LastOperationEndTimestampDT).  That's a proper datetime value which gives me what I want.  It just seems strange that Get-NaSISVol (which, as far as I can tell does much the same thing as Get-NASis) returns a string value instead of datetime value.

JGPSHNTAP
3,809 Views

Yes, interesting find, I never had the need to do that..  

Once your done, if you don't mind sharing with the community

GINOLARD99
3,809 Views

Sure.  It's a bit rough but it does the job

        $Volumes=Get-NaVol
        ForEach ($volume in $Volumes)
        {
            $VolumeName=$volume.name
            $ASISInfo=Get-NASIS "/vol/$Volumename" -erroraction silentlycontinue

            If ($ASISInfo)
            {
                If ($AsisInfo.LastOperationState -ne "success")
                {
                    [string]$ASISError=$ASISInfo.LastOperationError
                    "ASIS last operation failed ($ASISError)"
                }

                $LastASISDate=$ASISInfo.LastOperationEndTimestampDT
               
                If ($LastASISDate)
                {
                    If ($LastASISDate -lt (Get-Date).AddHours(-24))
                    {
                        "lastasisdate is bad"
                    }
                }
            }   
        }

JGPSHNTAP
3,809 Views

Cool. are you dumping the information to a log and emailing you?

GINOLARD99
3,809 Views

No it's being used in a script that sends information to our monitoring server.  It'll flag the particular alert as red if the Dedupe didn't run in the last 24 hours.

JGPSHNTAP
3,809 Views

Cool

Public