PowerShell has been adopted by many companies already including VMware and Cisco with its Unified Computing System (UCS).
Tag Archives: automation
PowerShell – Slipstream Office 2003 Updates
In yesterday’s post I described how you could extract Office 2003 updates. When they are extracted however, they still need to be slipstreamed into the package. I also created this script to automate the slipstreaming.
Basically for each extracted patch (.msp) file, it runs msiexec with the correct parameters. So if you have other msi packages that need multiple patch (.msp) files applied to it, you could use this script as a foundation as well.
PowerShell – Extract Office 2003 Updates
Not so long ago I had to create a new Office 2003 Administrative Installation Point.
There were 2 choices:
- Use the default ISO and have WSUS handle patching after each install.
- Slipstream all available patches in the Office 2003 Administrative Installation Point.
Ofcourse option 2 is the best choice, because then the package will be the most secure from the moment the software is deployed. Also it saves bandwidth and time.
To slipstream updates into Office 2003, there are basically 4 steps:
- Extract the original Office 2003 files.
- Download the updates you want to slipstream.
- Extract the updates you want to slipstream.
- Slipstream the updates into the extracted Office 2003 files.
You can imagine that the older the source files are, the more updates there are to be slipstreamed. So it is best to use an ISO/CD of Office 2003 with the latest Service Pack.
Still if you have the latest Service Pack, you need to slipstream more than 20 updates. I personally don’t like these kind of manual tasks, so I created this script to do the extraction of the updates for me.
Ofcourse this script can be used to extract other kinds of updates as well..
PowerShell – Determine which Active Directory objects are protected from accidental deletion
In yesterday’s post I showed some commands to protect all or specific Active Directory objects from accidental deletion.
In some situations (by example preparing for a change) you might want to know which objects are protected from accidental deletion and which are not. Also when multiple people make changes in an Active Directory it might prove difficult to keep track of the changes.
To determine the protection status of AD objects, I use a script that checks the ACL of the AD Object. When Everyone is explicitly Denied access, it is protected from accidental deletion.
PowerShell – Protect Active Directory objects from accidental deletion
In a previous blog post I explained how to enable the Active Directory Recycle Bin which allows you to restore deleted active directory object.
But even though it’s great to be able to restore objects, it is even better to prevent accidental deletion. What accidental deletion basically does, is modify the permissions on an AD object to Deny Everyone so you won’t be able to delete it by accident.
More information about protection from accidental deletion can be found in “Preventing Unwanted/Accidental deletions and Restore deleted objects in Active Directory” and “Windows Server 2008 Protection from Accidental Deletion“.
In Windows Server 2012 with all the new cmdlets, it has become much easier to enable protection from accidental deletion.
By example, you could use these commands:
#Get-ADobject class names
get-adobject -filter * | select objectclass | group objectclass
#Protect specific AD object classes from accidental deletion
get-adobject -filter * | where{($_.ObjectClass -eq “container”) -or ($_.ObjectClass -eq “organizationalunit”) -or ($_.ObjectClass -eq “user”) -or ($_.ObjectClass -eq “group”) -or ($_.ObjectClass -eq “computer”)} | Set-ADObject -ProtectedFromAccidentalDeletion $true
#Protect all AD organizational units from accidental deletion
Get-ADOrganizationalUnit -filter * | Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion $true
#Protect all AD objects from accidental deletion
Get-ADobject -filter * | Set-ADObject -ProtectedFromAccidentalDeletion $true
PowerShell – Add websites to the Flash whitelist for Internet Explorer 10 (Metro – Modern UI)
[EDIT] 09-04-2013 : As described in my blog post, this script has become unnecessary for most people. This is because Microsoft to allow almost every Flash site by default. [EDIT]
[EDIT] 13-01-2013 : Apparently for Windows RT, the script doesn’t seem to be working yet. Unfortunately I have no Windows RT to troubleshoot and resolve the issue. [EDIT]
Windows 8 and Windows RT include support for Flash in Internet Explorer 10.
In Windows 8 there are however two version of Internet Explorer 10 that handle flash websites differently. First there’s Internet Explorer 10 Desktop, which is similar as the Internet Explorer you’ve been used to with previous versions of Windows. Then there’s also Internet Explorer 10 (non Desktop), which is the Internet Explorer in the new modern/Windows interface (Metro) that is full screen.
Internet Explorer 10 Desktop allows Flash for all websites. Internet Explorer 10 (Metro) only allows Flash for websites that have been whitelisted.
Especially for Windows tablets, Flash support can be a selling point because most other tablets don’t have Flash support. It is however confusing for regular consumers that not all their websites will work. By example a friend of mine who’s a hairdresser, uses http://www.kapperssite.nl to show her customers hair models and their haircuts. The site is however completely in Flash and that it is not working by default is very annoying.
The websites that have been whitelisted are defined in your local appdate folder. By example: “C:\Users\Bjorn\AppData\Local\Microsoft\Internet Explorer\IECompatData\iecompatdata.xml”. This file also contains information about websites and which compatibility mode should be used for each. The segment between <flash> and </flash> contains the websites that have been whitelisted for flash. You can manually modify this file as described here: http://forum.xda-developers.com/showthread.php?t=1961793
- Modifying the iecompatdata.xml to add the websites you want to whitelist for Flash. Wildcards don’t work unfortunately.
- Open Internet Explorer 10 Desktop, press ALT, Tools, “Compatibility View setting”. Then Disable “Download updated compatibility lists from Microsoft”. This way Microsoft won’t overwrite the updates you’ve made in step 1.
- Delete the IE10 browser history. The disadvantage of this method however is, that you won’t be taking advantage of future compatibility updates because you’ve disabled the update functionality. Leaving it enabled however means that you you would have to keep re-adding sites you want to whitelist for Flash.
As a workaround, I’ve created this script that will automatically perform these tasks:
- Disable “Download updated compatibility lists from Microsoft”
- Close all internet explorer processes.
- Download the latest iecompatdata.xml to the appropriate folder. Currently the latest version is: https://iecvlist.microsoft.com/ie10/201206/iecompatviewlist.xml
The script however will dynamically look for the latest versions by modifying the date in the url. - Combine the data from the latest iecompatdata.xml with websites you want to whitelist for Flash (specified in “C:\Users\Bjorn\AppData\Local\Microsoft\Internet Explorer\IECompatData\flashsitestoadd.txt).
- Backup the original iecompatdata.xml and store the modified iecompatdata.xml
- Clear the Internet Explorer browsing history.
Because automatic downloading of updated compatibility lists has been disabled, I advise to schedule the script to run on a regular basis (by example monthly). For instructions read this blog post: http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script.aspx Keep in mind that this will clear your Internet Explorer browsing history though.
Easily rename downloaded movies using powershell
Context
As most people, I often complain about not having sufficient time. It also doesn’t help that I have a lot of hobbies and interests. Because of this I decided to combine my hobbies and interests in such a way it would eventually save me time.
Basically I decided to learn powershell scripting by automating the task of renaming downloaded movies. These need to be in a specific format for reliable use with the movie jukebox called Yet Another Movie Jukebox (YAMJ). As a result this will save me a lot of time in the future.
Concept for the script
The file names of most movies I download are mostly in the following format:
The.Devils.Advocate.1997.UNRATED.DC.720p.BluRay.X264-AMIABLE.mkv
<movie.name>.<movie release year>.<metadata>.<metadata>…..<last.metadata>.<file extension>
What is important for YAMJ to work correctly is basically the movie name and the year (just in case there are movies with the same name, but released in a different year). So basically my preferred output would be:
The Devils Advocate 1997.mkv
To realise this, conceptually the following will be done for all files in a specific folder:
- Determine the current file extension and save it to a variable.
- Remove all dots “.” from the file name.
- Determine if there is a year notation in the file name (by example 1997).
- If there is no year notation found, don’t do anything else (file does not meet the expected format).
- If the year notation is found, remove everything from the file name after the year notation and re-add the file extension.
The script itself
The script itself can be found on my sharepoint list :
http://bjornhouben-web.sharepoint.com/Lists/Scripts/
Closing thoughts
I hope this will help home users to see the advantages of scripts, use them and benefit from it. For ICT professionals I also hope that it will help them get a better understanding of Powershell. Because in my opinion Powershell is getting increasingly important both for Microsoft and non Microsoft products (by example VMware).
I’d love to get feedback about this post and hope to receive some replies.

