I was asked for a PowerShell script to remove unresolvable SID’s because of a migration. User accounts didn’t exist on the target machine and the customer wanted to open up the security tab without any wait time and see a cleaned up and ordered ACL list. Since I adopted PSreadline every maintenance task is scripted …
Category Archive: One-Liner
Jun 09
PS One-Liner: #5 Create multithreaded processes
This one is a golden oldie and used for migrating data using robocopy. Let’s start with a simple example.
1 |
@('notepad','notepad') | % {while ((gps $_ -ea 0).count -ge 1){sleep 5};start $_} |
First we begin with an array ”@(notepad…)’ where we define the processes to start. Then we use foreach ‘%’ which fetches each item in the array as a pipeline item ‘$_’ and then checks how many …
May 13
PS One-Liner: #4 Recycle and schedule Appools periodic restart
This will come in handy if you want to recycle specific or all AppPools which are consuming too much memory on the server. Of course you also want to avoid the memory problems in the future and don’t want to click every AppPool and set the periodic restart schedule. PowerShell to the rescue with just …
Sep 25
PS One-Liner: #3 PowerShell filewatcher
I was asked if I had something to watch a web.config file and if that file changed fire off good old robocopy. That’s a easy one, you ask I roll. Filewatcher coming up.
1 2 |
while (!(sleep 5)) {if ((gci "web.config").lastwritetime -ge (get-date).addseconds(-5)){$true}} |
The while loop is just used for infinite looping purposes only and executed every five seconds, ‘sleep’ is the alias for ‘start-sleep‘. …
Sep 21
PS One-Liner: #2 Query all Events from all Event Logs between a specific time frame!
UPDATE: I made a GUI around it and published it on Technet, download it here! Did you ever found yourself in a situation where you couldn’t pinpoint the exact cause of a particular problem or you just need to know what exactly happened on your machine but can’t find the culprit? Unfortunately these things are quite …
Sep 05
PS One-Liner: #1 Lowercase your text and paste it to the clipboard, batch style!
Because we had to comply with a naming convention in a system not managed by yours truly, I had to manually set each uppercase FQDN server name to lowercase in a GUI. Beware, I litterally HATE manual tasks which should and could be automated somehow even if took more time to script, there is always …