![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | ConverttoDateTime Question I am working on writing a simple script to get the last reboot date of certain workstations and servers on my network. I am having issues with the Converttodatetime function. I am doing the following. $machines = get-qadcomputer -searchroot 'Name of OU Here' | for each {$_.name} { $wmi = gwmi -class Win32_operatingSystem -Computername $machines $reboottime = converttodatetime ($wmi.lastbootuptime) } when I run this it tells me that "the term converttodatetime is not recognized as a cmdlet, function, operable program or script file. Verify the term and try again. I have searched the archives here and the blogs out there and all the examples that I have seen do the same type of thing. I have also taken out the first line and hardcoded a machine name in place of $machines to make sure that wasn't the problem. What am I missing? TIA. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: ConverttoDateTime Question I apparently have tried everything, BUT what you just recommended as it obviously worked. Thanks Shay. On May 27, 5:45 pm, Shay Levi <n...@xxxxxx> wrote: Quote: > convertToDateTime is a method of the $wmi object, you need to prepend $wmi: > > $wmi.converttodatetime($wmi.lastbootuptime) > > --- > Shay Levi > $cript Fanatichttp://scriptolog.blogspot.com > Quote: > > I am working on writing a simple script to get the last reboot date of > > certain workstations and servers on my network. I am having issues > > with the Converttodatetime function. I am doing the following. Quote: > > $machines = get-qadcomputer -searchroot 'Name of OU Here' | for each > > {$_.name} > > { > > $wmi = gwmi -class Win32_operatingSystem -Computername $machines > > $reboottime = converttodatetime ($wmi.lastbootuptime) > > } > > when I run this it tells me that "the term converttodatetime is not > > recognized as a cmdlet, function, operable program or script file. > > Verify the term and try again. Quote: > > I have searched the archives here and the blogs out there and all the > > examples that I have seen do the same type of thing. I have also taken > > out the first line and hardcoded a machine name in place of $machines > > to make sure that wasn't the problem. Quote: > > What am I missing? Quote: > > TIA. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: ConverttoDateTime Question Very nice. I don't totally understand all of your select statement right now but my Powershell TFM book should be here in a day or two so I am starting my library and learning! None of the bookstores around me seem to carry anything that I want! (I was close in what I had in that I was just outputting $machines, $reboottime On May 27, 5:58 pm, Shay Levi <n...@xxxxxx> wrote: Quote: > You're welcome ![]() > > BTW, you can generate a table of computerName (CSName) and last reboot time > for all machines like so: > > $machines = get-qadcomputer -searchroot 'Name of OU Here' | foreach {$_.name} > gwmi -class Win32_operatingSystem -computerName $machines | select CSName, > @{n="LastBootUptime";e={ $_.converttodatetime($_.lastbootuptime)}} > > --- > Shay Levi > $cript Fanatichttp://scriptolog.blogspot.com > Quote: > > I apparently have tried everything, BUT what you just recommended as > > it obviously worked. Quote: > > Thanks Shay. Quote: > > On May 27, 5:45 pm, Shay Levi <n...@xxxxxx> wrote: Quote: Quote: > >> convertToDateTime is a method of the $wmi object, you need to prepend > >> $wmi: Quote: Quote: > >> $wmi.converttodatetime($wmi.lastbootuptime) Quote: Quote: > >> --- > >> Shay Levi > >> $cript Fanatichttp://scriptolog.blogspot.com > >>> I am working on writing a simple script to get the last reboot date > >>> of certain workstations and servers on my network. I am having > >>> issues with the Converttodatetime function. I am doing the > >>> following. Quote: Quote: > >>> $machines = get-qadcomputer -searchroot 'Name of OU Here' | for each > >>> {$_.name} > >>> { > >>> $wmi = gwmi -class Win32_operatingSystem -Computername $machines > >>> $reboottime = converttodatetime ($wmi.lastbootuptime) > >>> } > >>> when I run this it tells me that "the term converttodatetime is not > >>> recognized as a cmdlet, function, operable program or script file. > >>> Verify the term and try again. > >>> I have searched the archives here and the blogs out there and all > >>> the examples that I have seen do the same type of thing. I have also > >>> taken out the first line and hardcoded a machine name in place of > >>> $machines to make sure that wasn't the problem. Quote: Quote: > >>> What am I missing? Quote: Quote: > >>> TIA. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: ConverttoDateTime Question convertToDateTime is a method of the $wmi object, you need to prepend $wmi: $wmi.converttodatetime($wmi.lastbootuptime) --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > I am working on writing a simple script to get the last reboot date of > certain workstations and servers on my network. I am having issues > with the Converttodatetime function. I am doing the following. > > $machines = get-qadcomputer -searchroot 'Name of OU Here' | for each > {$_.name} > { > $wmi = gwmi -class Win32_operatingSystem -Computername $machines > $reboottime = converttodatetime ($wmi.lastbootuptime) > } > when I run this it tells me that "the term converttodatetime is not > recognized as a cmdlet, function, operable program or script file. > Verify the term and try again. > > I have searched the archives here and the blogs out there and all the > examples that I have seen do the same type of thing. I have also taken > out the first line and hardcoded a machine name in place of $machines > to make sure that wasn't the problem. > > What am I missing? > > TIA. > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: ConverttoDateTime Question You're welcome ![]() BTW, you can generate a table of computerName (CSName) and last reboot time for all machines like so: $machines = get-qadcomputer -searchroot 'Name of OU Here' | foreach {$_.name} gwmi -class Win32_operatingSystem -computerName $machines | select CSName, @{n="LastBootUptime";e={ $_.converttodatetime($_.lastbootuptime)}} --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > I apparently have tried everything, BUT what you just recommended as > it obviously worked. > > Thanks Shay. > > On May 27, 5:45 pm, Shay Levi <n...@xxxxxx> wrote: > Quote: >> convertToDateTime is a method of the $wmi object, you need to prepend >> $wmi: >> >> $wmi.converttodatetime($wmi.lastbootuptime) >> >> --- >> Shay Levi >> $cript Fanatichttp://scriptolog.blogspot.com Quote: >>> I am working on writing a simple script to get the last reboot date >>> of certain workstations and servers on my network. I am having >>> issues with the Converttodatetime function. I am doing the >>> following. >>> >>> $machines = get-qadcomputer -searchroot 'Name of OU Here' | for each >>> {$_.name} >>> { >>> $wmi = gwmi -class Win32_operatingSystem -Computername $machines >>> $reboottime = converttodatetime ($wmi.lastbootuptime) >>> } >>> when I run this it tells me that "the term converttodatetime is not >>> recognized as a cmdlet, function, operable program or script file. >>> Verify the term and try again. >>> I have searched the archives here and the blogs out there and all >>> the examples that I have seen do the same type of thing. I have also >>> taken out the first line and hardcoded a machine name in place of >>> $machines to make sure that wasn't the problem. >>> >>> What am I missing? >>> >>> TIA. >>> |
My System Specs![]() |
| | #6 (permalink) |
| | Re: ConverttoDateTime Question You can get more info on 'Calculated Properties' here: http://www.microsoft.com/technet/scr...pstip0425.mspx Sapien's Powershell TFM is a great book! You can find more info on this topic in Chapter 6 'Cmdlets to Group, Sort, Format, Export, and More' --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > Very nice. I don't totally understand all of your select statement > right now but my Powershell TFM book should be here in a day or two so > I am starting my library and learning! None of the bookstores around > me seem to carry anything that I want! (> > I was close in what I had in that I was just outputting $machines, > $reboottime > > On May 27, 5:58 pm, Shay Levi <n...@xxxxxx> wrote: > Quote: >> You're welcome ![]() >> >> BTW, you can generate a table of computerName (CSName) and last >> reboot time for all machines like so: >> >> $machines = get-qadcomputer -searchroot 'Name of OU Here' | foreach >> {$_.name} gwmi -class Win32_operatingSystem -computerName $machines | >> select CSName, @{n="LastBootUptime";e={ >> $_.converttodatetime($_.lastbootuptime)}} >> >> --- >> Shay Levi >> $cript Fanatichttp://scriptolog.blogspot.com Quote: >>> I apparently have tried everything, BUT what you just recommended as >>> it obviously worked. >>> >>> Thanks Shay. >>> >>> On May 27, 5:45 pm, Shay Levi <n...@xxxxxx> wrote: >>> >>>> convertToDateTime is a method of the $wmi object, you need to >>>> prepend $wmi: >>>> >>>> $wmi.converttodatetime($wmi.lastbootuptime) >>>> >>>> --- >>>> Shay Levi >>>> $cript Fanatichttp://scriptolog.blogspot.com >>>>> I am working on writing a simple script to get the last reboot >>>>> date of certain workstations and servers on my network. I am >>>>> having issues with the Converttodatetime function. I am doing the >>>>> following. >>>>> >>>>> $machines = get-qadcomputer -searchroot 'Name of OU Here' | for >>>>> each >>>>> {$_.name} >>>>> { >>>>> $wmi = gwmi -class Win32_operatingSystem -Computername $machines >>>>> $reboottime = converttodatetime ($wmi.lastbootuptime) >>>>> } >>>>> when I run this it tells me that "the term converttodatetime is >>>>> not >>>>> recognized as a cmdlet, function, operable program or script file. >>>>> Verify the term and try again. >>>>> I have searched the archives here and the blogs out there and all >>>>> the examples that I have seen do the same type of thing. I have >>>>> also >>>>> taken out the first line and hardcoded a machine name in place of >>>>> $machines to make sure that wasn't the problem. >>>>> What am I missing? >>>>> >>>>> TIA. >>>>> |
My System Specs![]() |
| | #7 (permalink) |
| | Re: ConverttoDateTime Question Now I understand the SELECT statement you used! Thanks again Shay. I appreciate your helpfulness and pointers to the correct info! Tim On May 28, 3:31*am, Shay Levi <n...@xxxxxx> wrote: Quote: > You can get more info on 'Calculated Properties' here:http://www.microsoft..com/technet/sc.../pstips/apr08/... > > Sapien's Powershell TFM is a great book! You can find more info on this topic > in Chapter 6 > 'Cmdlets to Group, Sort, Format, Export, and More' > > --- > Shay Levi > $cript Fanatichttp://scriptolog.blogspot.com > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| set up question | Vista mail | |||
| escape character question - hopefully an easy question | PowerShell | |||
| converttodatetime from wmi class not working | PowerShell | |||
| vista genral question and ultimate question | Vista General | |||
| Dual boot system question and family deal discount question | Vista General | |||