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 | 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. Just list all the computers you want in a text file and add that to the PowerShell command: restart-computer (get-content c:workcomputers. So this is actually quite easy to do, and PowerShell is a great place to do it. shutdown /m yourcomputername /c 'The IT department has initiated a remote restart on your computer' Below is the pop up on the remote computer with the custom message. That data should then be stored in a csv file. This is slow and somewhat tedious, not to mention difficult to track progress on when dealing with a reasonably large list. 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. As it is, the script performs these steps: Copy the. 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 |