Skip to main content

Posts

Showing posts from October, 2014

Getting the Last Modification Time of a GPO

Ideas are rolling in my 6293: Troubleshooting and Supporting Windows® 7 in the Enterprise class here in Yokosuka, Japan.  Although PowerShell is not part of this class, the only answer to many questions is with PowerShell.  OK, the best answer is with PowerShell. The problem that the client was facing is that a problem may mysteriously pop up.  The question, is there a way to determine if Group Policy has recently been modified?  The GPO object contains both a creation, and the last modification time stamp.  The code below will let you either gather the modification time stamps for all GPOs, or those that have be modified within a specific time period. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50     Function Get-GPOModifications {     Param (         [ INT ] $Hours = 0 ,         [ INT ] $Days = 0     )         # The IF

Use PowerShell to Add and Update to an Image

Yesterday I posted about a question that I received in a Windows 7 class here in Yokosuka, Japan.   It was how to add an update while servicing an image.   Well, because of the technology used, we used the DOS program called DISM.   PowerShell V3 running on Windows 8 and up has the DISM module.   So to bring things into the modern era, here is how to do the same thing with PowerShell. First we mount the image. PS E:\> Get-WindowsImage -ImagePath install.wim | Mount-WindowsImage -Path img -Index 1   The Get-WindowsImage cmdlet will get the Install.wim object.   We can then pipe that to Mount-WindowsImage .   We need to provide the –Path to the directory that will hold the mounted image and the index number of the image that we want to work with. Now we can add the package to the image: PS E:\> Add-WindowsPackage -Path Img -PackagePath Windows6.1-KB976264-v2-x86.msu   Now we can dismount the image and Commit the changes. PS E:\> Dismount-WindowsImage -Path IMG -Save

Use DISM to add a Windows Update to an Image

Today in my Windows 7 class here in Japan, I was asked if it is possible to apply an update to windows while servicing an image. That little voice in my mind said yes, but I had to look it up. So, I set up a VM with Windows 7 and downloaded KB976264 for Windows 7. This is a file with a .MSU file extension. Here you can see the Install.wim fir Windows 7 and the KB article. Next, I mount the image. I then add the update to the image. Next I commit the updates. In the image below, I used the Discard switch. If I wanted to keep the changes, I would have used the Commit switch.   Not to bad.  Tomorrow I will do the same process, but this time with PowerShell.

How to set PowerShell to Always Open in Version 2

One of the things that I love most about being an MCT is that I get to meet a lot of people who look at things differently.  For example, in my PowerShell class this afternoon, I had one individual ask if it was possible set PowerShell to open in V2 by default. They were in a mixed environment between V2, 3, and 4. My first instinct was to add this line to their PowerShell profile.  PowerShell -Version 2 Then I thought about it.  I would much rather have version 5 as my default and just create a different icon for version 2.  So this is what I did. Right click your desktop and select New –> Shortcut . In the Type the location of the Item: box, enter PowerShell.exe –Version 2 and click Next In the Type a name for this shortcut box, I gave the name PowerShell V2 and clicked Finish . I then opened the icon that it created. When you type Get-Host the Version property should show that you are using V2.  If you want to switch to V5 in this windows, just type PowerShell –

How to Extract the Username of the ManagedBy property of an Organizational Unit

This morning in my PowerShell class, we looked at creating calculated properties.  Fortunately for us, I found one of our fellow IT professionals on PowerShell.com that needed a little bit of help that involved calculated properties.  This individual was attempting to enumerate all of the Organizational Units in their Active Directory domain and extract the username in the MangedBy property.  The thing is, the ManagedBy property gives you the distinguished name of the user, not the user name. Get-ADOrganizationalUnit -filter * | Select-Object -Property Name , ManagedBy   Groups                                                                                           Printers                                                                                         Printers                                          CN=James,CN=Users,DC=Adatum,DC=com              Printers                                                                            By using calculated properties

Set PowerShell as Your Default Instead of the Command Prompt

As most of you know who have been in my classes, I generally do everything in PowerShell.  Yes, the Command Prompt is still there. But most of the time I just work in the PowerShell console.  For you Windows 8.1 users, give this a try. Press Windows Key + X   Notice that the Command Prompt is listed.  Well, that does not help us PowerShell users out.  We can change this behavior in Windows 8.1. From the Desktop, right click the Taskbar and click Properties Click the Navigation tab. Now check Replace Command Prompt with Windows PowerShell in the menu when I right-click the lower-left corner or press Windows Key + X .   Click OK Now press Windows Key + X and see what pops up. This is just a short cut to getting you on the right path.