I was researching a bug in a script of mine, where most files would be moved, exept some. The behaviour seemed irregular, until I noticed that the files not being moved had 1 thing in common. They all had brackets [ ] in their file name. It appears that if you use Move-item -Path <filename> … Continue reading Move-item and files with [ and ] in its filename
Author: Powershell Administrator
Net stop/start W3SVC and Stop/Start-Service W3SVC vs IISRESET STOP/START
I encountered a problem where I wanted to stop and start IIS by using either the command line or powershell versions of stopping and starting IIS. NET STOP W3SVC NET START W3SVC or Stop-Service W3SVC Start-Service W3SVC Both of those stopped and started the World Wide Publishing service correctly. But both appeared to not stop/recycle … Continue reading Net stop/start W3SVC and Stop/Start-Service W3SVC vs IISRESET STOP/START
Powershell application – Get information from a webpage, parse it and show the results
Today I created a nice little 'application' in Powershell. In The Netherlands we have a site called Marktplaats (www.marktplaats.nl) which is some sort of combination between e-bay and craiglist. This is one of the biggest sites in The Netherlands, but I was missing some search options on this site and thought they started to show … Continue reading Powershell application – Get information from a webpage, parse it and show the results
How simple some things can be – Powershell indent
In the past few years, I've been using tools to indent my code... Today by accident found out that in Powershell ISE, if you select multiple lines and press tab it'll indent all selected lines... and of course shift+tab will do the reverse. Amazing how simple some things can be without any tool... And how … Continue reading How simple some things can be – Powershell indent
Nice piece of automation
Today I stumbled upon a very nice script by David O'Brien, which documents your entire System Center Configuration Manager environment. It generates a very nice report and all created automatically. Very nice piece of automation. http://www.david-obrien.net/2014/01/30/update-inventory-script-makes-configmgr-life-easier/
Analyze Robocopy log files and mail the result
A long, long time ago (back in 2008) I created a VBS script which would analyze a folder filled with Robocopy logs and once done analyzing and creating a summary, it would mail the result to me. A couple of days ago I decided it was time to update this script to Powershell. Once I … Continue reading Analyze Robocopy log files and mail the result
Get all (non-default) scheduled tasks
I tried querying the scheduled tasks to give me a list of all (non-default) scheduled tasks. I also wanted to have its schedule information, which appeared to be a pretty hard task in the get-service command. After several unsuccessful attempts, I tried something else with great and immediate results. It appeared that the schtasks did … Continue reading Get all (non-default) scheduled tasks
Get all non-default Windows services
Getting a list of all services isn't that hard. This can be achieved with Get-Service or with Get-WmiObject win32_service. It seems that Get-Service doesn't leave me with enough properties to query and/or filter out, and this time the Get-WmiObject queries work quick enough; thus I'll use this for my code. I wanted a list of all … Continue reading Get all non-default Windows services
Offline servicing of a VHD or WIM file
I came across a nifty PowerShell module today. The Module can be found here: http://windowsitpro.com/windows/add-updates-offline-vhd-or-wim-file It's an automation of the offline servicing of a VHD(X) or WIM file. If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { $Arguments = "& '" + $myinvocation.mycommand.definition + "'" Start-Process powershell -Verb runAs -ArgumentList $Arguments Break } Import-Module C:\Install-Patch.psm1 Install-Patch <Path/share to vhdx … Continue reading Offline servicing of a VHD or WIM file
Weird get-process behaviour
Today I encountered some weird behaviour by the get-process command. I was working on a tool to get a list of open programs on a remote computer when I encountered some strange behaviour/inconsistencies, even within the host itself (without remotely connecting and querying). Once I use the get-process -name command to get the session ID for … Continue reading Weird get-process behaviour