![]() Just remove the -WhatIf to create the file. Select-Object PSComputerName, LABEL='LastBootUpTime' EXPRESSION=Įxport-Csv -Path 'D:\Temp\SystemRebootReport.csv' -Append -NoTypeInformation -WhatIf Get-WmiObject Win32_OperatingSystem -ComputerName pyex06 | Note that to write a custom comment a reason code will need to be. This code will force (/f) a shut down and reboot (/r) of a given PC and write to the event log with a custom comment (/c). Shutdown /r /f /m ComputerName /d P:0:1 /c 'Your comment'. $OutputCsv = ("C:\Temp\" + $Today.ToString( "yyyy-MM-dd" ) + ".csv" ) Here is the PowerShell code that I used to solve this problem as suggested by the user C.B. Set goals and meet those goals.Ī start might be something like: $Today = Get-Date However, you have to "develop" on top of what you've already discovered. So this is actually quite easy to do, and PowerShell is a great place to do it. That data should then be stored in a csv file. If I'm interpreting your question correctly you want to check the last boot up time daily and report machines that haven't rebooted in the last 7 days. This is not a full answer, but should help you toward your goal. To be fair, all I need is to see the last time the computers were restarted, and that's all, so if you know of an easier way - I'm ready to read about other ideas. If not - well, it may take forever to google for it all, but in the end, I may be able to find it all myself. I understand there's very little hope, but if you can help me - great. Of course leaving the old one (or all others, starting day 2.) for the review. At the end of the day, the *.ps1 would create a new *.txt or *.csv file and start it all over.Export the list into either *.txt or (even better) *.csv.and I don't want to be deleting a whole bunch of computers and making sure only 1 copy is left and deleting all other every day. Instead of copying all computers each time, I want to append new computers to the list, because otherwise, the list would be very, very long.Create the *.ps1 file (I can do that) and make it run it 24/7. ![]() Also, it may be useful not only to me, but to others as well. I do not know anything about PowerShell, so I'm asking for your help. (I'm not sure if sharing the links is a good idea here, but I just googled for "check when remote computer was last restarted" and clicked on a link on enterprisedaddy) Here's the command I found online: Get-WmiObject Win32_OperatingSystem -ComputerName : select cname, EXPRESSION=($_.ConverttoDateTime($_.lastbootuptime))) What I want is to make it a bit more advanced. I need to make sure all computers are being restarted at least once a week, and I've been googling on it, and I found something, but it's. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |