Another day, another PowerShell script.. this time to get DHCP settings, leases and reservations from all DHCP Servers in current domain. Pre-requisite is all DHCP Servers should be Windows 2012 based and WinRM should be enabled on all of them.Continue reading “PowerShell Script for DHCP settings, leases and reservations inventory”
In line with the last post on File Server inventory, here comes the another script to perform patching for Domain Servers from a remote machine.
PowerShell already has methods to perform patching on any server, where we can list what all patches are available and create a downloader to download and install them all, but a limitation to the capability is, the same can not be done remotely. As a workaround for that, we would be creating schedule task on the remote machine via the script and performing the patching via triggering that schedule task.
It would involve two scripts InstallPatches.ps1 and PatchServer.ps1, whose code I would be listing below. It would make use of c:\temp directory and would be keeping logs and scripts in the same location. Also we would need any shared location, where we would keep a copy of InstallPatches.ps1, which then would be copied dynamically over the servers during patching. I have kept script source path as “\\ABCXYZ\sources\installpatches.ps1” while it can be changed as per your environment.
Managing a large infra never happens to be easy without right kind of tools and tools usually come with cost. In past Unix users used to taunt Windows users on this point as they used to enjoy many open source products and scripts which Windows users weren’t privy of. Things changed a lot since PowerShell.
Presenting you a script to have a size and permission inventory of all your shares on all file servers. Below would be the pre-requisites:
1. Names of all file servers.
2. All the file servers should have WinRM enabled (Windows 2012 servers have it on by default and for Windows 2008, winrm quickconfig may do the trick).
3. Obviously Local Administrator permissions on all File Servers, which should have permissions on shares as well.
After that just change the variable $RemoteComputers value with the name of file servers in place of dummy values placed in form of array right now. That’s it.
This script lists names of all servers (provided by you), shares on them, NTFS permissions, Size in MB, Last modified date and Last accessed date.
Munnar was the only location, where we were scheduled to stay for two nights means full one day for the place as the day next, we were to leave as early as possible to reach Bangalore in time.
When we woke up, it was raining but nevertheless, we got ready and then by 7.30 AM, we would have been on nearby restaurant for a heavy breakfast. After which we started driving after 8.30 AM. This time we had hired a guide to drive with us and show us around @ 500Rs.
It continued to rain though we had hopes that it would settle till the time we reach to the viewpoints and luckily it happened that way.
We all waited for morning to have more fun on beach, elders and kids alike. The first job in morning to get ready after bath etc and head to beach with sand castle tools.
We must have reached the beach by 7 AM. The lighthouse wasn’t gonna open before 10AM which means it wouldn’t cut into our schedule. It was all about the time on beach now and mild showers were worrying us.
What better feeling than to watch the sunrise at the last end of your country with 360 degree of sea view around and that too under a cloudy and less warm weather. Would admit we wouldn’t have preferred cloudy but a clear sky but every weather has its own texture and should be taken as such.
Morning started with mild showers and we had to take umbrellas from the hotel. The excitement to walk towards the end of the country boundary was just something else.
Changing colors with each passing minute, the place is worth spending the entire day just sitting on that stone bridge.
The view, the showers, people trying to sell sea shells and even tea vendors doing ferry on that small but not that crowded place, if it wasn’t about rains and specially kids, then we would have stayed much more longer there but then guarding kids on that place where both side it was heavy waves, our mind was asking us to move from there.
Finally this was the day for which kids been waiting for. Sand castles on sea beach, but they had to wait little more as elders needed to visit Rameshwaram temple. No photos as cameras were not allowed in temples. We woke up early, taken bath, did Manidarshan, but going for “22 Kund snan” was kind of tough with kids around so we chosen the short route. By some 8.15 AM, we would have been free to drive again after checking out from hotel.
We reached Danushkodi by 9 AM where we were stopped some 5-6 kms before by a check-post in name of “Road construction” which meant we weren’t allowed to go further at this weather at least. An impromptu parking spot it was from where pvt ferries used to take people to a certain point (Not the last end) on a cost from off-road route. It might look like just a line in maps, but including the shores, its around 500 mtr wide place which stretches around 7kms from north to south. It shares ONLY land border between Sri Lanka and India which is one of the smallest in world at 45 mtrs in length. (of course we didn’t made it to that point).
This place is actually called as “Ghost Town” due to a tragedy back on 22 December, 1964 which wiped out roughly 1800 people including those 115 passengers on Pamban-Dhanushkodi passenger train. After that railways station was wiped out and the train never began its operations. A commission looked into possibility of new rail in 2010 and last year a road was constructed till this point.
Anyway… we went into history of the place… let’s come back to travelogue…