Use powershell to unzip files without specifiying zip file name

So One year passed by, my son turns one year old the 11th of February so it’s back to work for me! And what better way to start then to start a fight with Powershell. I gotta tell you, scripting with Powershell is like playing MUD (command-line based role playing). Very addictive and time just passes in a flash!

I was searching for a script to unzip a file but I only found scripts where you had to specify a static path to the filename OR the script was seven pages long OR you needed to run it with parameters… So after some hacking and constructing it came down to this:

# Change the Path & Destination variable

$path = “C:\Whereisthezip”

$destination = “C:\Wheredoyouwanttounzip”

 $shell_app= New-Object -com shell.application

$files = Get-ChildItem -Path $path -filter *.zip -recurse

foreach($file in $files) {

  $zip_file = $shell_app.namespace($file.FullName)

  $copyHere = $shell_app.namespace($destination)

  $copyHere.Copyhere($zip_file.items())

}

Thanks to Niklas Goude I didn’t have to spend one more day with it 😉

Advertisements

Good-to-know troubleshooting in Outlook *shrug*

Have you ever heard of Kurgan? The evil Highlander Immortal of the movie Highlander? I don’t know why but troubleshooting certain… applications… makes me think of him, maybe it’s the thought of splitting the laptop open with a giant sword.
I like troubleshooting when the process is automated with Powershell or graphic tools with charts (like WSUS reporting or other stuff) that lets me take a quick overview of what could be wrong… So I thought a good-to-know-tool for Helpdesk is OCT Outlook Configuration Analyzer Tool 2.0 which scans your profile and checks for issues regarding everything from configuration errors to missing hotfixes (or service pack for that matter)

So downloading, installing and running OCT will give you this start page

msocat

And then you select Start a Scan and enter a scan label (name the scan) and if necessary enter the credentials if you need to run the scan for another account than the one you are logged on with.

ocatstartascan

Then it takes around 2 minutes (said 9 minutes but for me it took 2 minutes 🙂 for the scan to complete and then you can click View a report of this configuration scan

ocatscanningreportviewchanged

Good-to-know recovery in Windows 8

If you haven’t started to play around in the snow yet (in Sweden at least) and you’re stuck inside because you’re sick (like me) you can always do things like back-ups (and no I’m not talking about the exercise), and other file cleaning things…. and in Windows 8, why not create a recove Wim-file with recimg?

If you run cmd as administrator and execute

recimg /?
Configures the recovery image Windows uses to refresh your PC.
RECIMG.EXE <command> <arguments>
The recimg.exe command line tool lets you configure a custom recovery image for Windows to use when you refresh your PC.
When you create a custom recovery image, it will contain the desktop apps you've installed, and the Windows system files in their current state. 
Recovery images do not contain your documents, personal settings, user profiles, or apps from Windows Store, because that information is preserved at the time you refresh your PC.
When you create a custom recovery image, recimg will store it in the specified directory, and set it as the active recovery image. 
If a custom recovery image is set as the active recovery image, Windows will use it when you refresh your PC. 
You can use the /setcurrent and /deregister options to select which recovery image Windows will use. 
All recovery images have the filename CustomRefresh.wim. If no CustomRefresh.wim file is found in the active recovery image directory, 
Windows will fall back to the default image (or to installation media) when you refresh your PC.
Note that you cannot reset your PC using a custom recovery image. Custom recovery images can only be used to refresh your PC.
The following commands can be specified:
/createimage <directory>         Captures a new custom recovery image in the location specified by         <directory>, and sets it as the active recovery image.
/setcurrent <directory>         Sets the active recovery image to the CustomRefresh.wim file in the         location specified by <directory>. Windows will use this image when you
refresh your PC, even if a recovery image provided by your PC's         manufacturer is present.
/deregister         Deregisters the current custom recovery image. If a recovery image         provided by your PC's manufacturer is present, Windows will use that         
image when you refresh your PC. Otherwise, Windows will use your         installation media when you refresh your PC.
/showcurrent         Displays the path to the directory in which the current active recovery         image is stored.
/help, /?         Displays this help text.

So! Away we go, and might I suggest you place the recovery wim file on a different drive than your windows drive 🙂

recimg /createimage e:\recimg

If you navigate to that folder you will see that windows will create a CustomRefresh.wim file.

When it is complete execute recimg /showcurrent to view the settings.

AND if you got a little bit over excited as I did with the cleaning up files and what not’s and you tried to refresh your Windows 8 machine with Windows Recovery by pressing Shift and F8 while booting…
but all you got was “The drive where Windows is installed is locked. Unlock the drive and try again”
Refresh your PC

Well have no fear you probably just messed upp BCD so press cancel, go back to Windows Recovery, select Troubleshoot, Advanced Options and then Command Prompt and execute

diskpart

and then

list volume

And note which volume letter (Ltr) that has the operating system files for Windows 8 – you better know the size of the partition 😉

then execute the following where you replace D: with the drive letter of your Windows 8 partition.

bcdboot d:\windows /s d:\

And if THAT fails you need to find out the GUID {identifier} for your installation and use that information with bcdboot to repair it.

bcdeditwin8

And then use that information instead (with the driveletter of your volume as explained in the previous steps):

bcdboot d:\windows /m {2980d3a5-1dfc-11e2-a3bb-2c768ae43499}

Good to know’s – Remote Desktop (Terminal Services)

So I got the Halo 4 collectors edition…

Got an awesome Halo 4 necklace and everything – but I couldn’t play at all because of some crazy ants in my wrists…. 😦

So

Remote Desktop previously Terminal Server?
I like big changes and small features. If you want to know about the big changes you can always find everything you need to know about What’s new in Windows Server 2012 by visiting Technet.

Small things need to know that has been around for some time is Remote Desktop (Terminal Services) Protocol 8.0 that is available for Windows 7 SP1 (and Windows 8 of course)
And again, there are a number of great pages where you can read more, I suggest you visist the remote desktop services blog and read more about the Windows 7 update.

Image

 

 

 

 

 

 

 

 

 

 

 

 

When you connect using the desktop version of remote desktop Connection (mstsc.exe) in Windows 8 or Windows Server 2012, you can right-click at the top bar and click Smart sizing to automatically expand the remote desktop session window so you won’t need to (elder) scroll to navigate.
Though it seems that mstsc for Windows 7 SP1 with the 8.0 update doesn’t show the option Smart sizing in the navigation pane for some reason…? And if that is the case you can configure smart sizing by running mstsc, click Show Options, select Save As, navigate to your saved .rdp file, select open with notepad, and add smart sizing:i:1 at the end of the file and save it.

 

Image

And then there’s the Windows 8 Remote Desktop application!

Image

It’s a nice little application (WWAhost.exe) if you want to log on to two or three more servers remotely (… if you need to manage more than three servers, say 42, you should use Server Manager in Windows Server 2012 instead.) But if you are using vdi, remoteapp etc and you are using a tablet-surface-Windows 8-touch-device it’s great.

Image

PLUS (and trust me, with all that short-cut-keying and app switching between fullscreens) you can use the new Remote desktop application in snap mode so that you can run either more Windows 8 applications or desktop applications with your sessions listed on the right side of the screen:

Windows 8 Remote Desktop

 

 

 

 

 

 

 

 

 

 

 

 

 

And in Remote Desktop, if you right-click a Recent machine and select edit

Image

you can view the settings for each machine if you switch the setting to apply for all machines to off.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

There’s so much to see… and purchase

I guess you figured out by now that I’m not that much for shoe-shopping but I can however get stuck when it comes to other types of hardware.
And it feels like 2013 really is the Year of Hardware or YOH.
New hardware. So, please stop upgrading and modifying old… kinda crap stuff… and bring us shiny new ones.
I want full support for UEFI (all of UEFI an not just bits and pieces), USB 3.0, cheap SSD’s, disgustingly much RAM and not a device that weighs more than I do.

About a year ago I wanted to buy a new XBOX but as my better half stated “Why would you need two of them??!”… I didn’t buy one…
But it was a Halo special edition XBOX!! But hey, I’m not complaining, I did get to buy this giant plastic mountain that came with an even bigger box 😀

… And now there’s Halo 4… and my birthday is in March…So in case someone reads this 🙂

But hey, I’m not egoistic! I did buy my better half a Samsung Galaxy tab 8.9 over a year ago because I wanted a small touch tablet which didn’t weigh a ton or cost a fortune and I… I mean HE likes it a lot 🙂

But 2013 is coming and I need to prioritze what device to purchase and with Surface and Windows 8 Pro, well… I don’t know about you but I really, really, really want one.

Print Management in Windows Server 2012 and Windows 8

It was an early sunny Saturday, when I sat down in the basement and configured a Windows Server 2012 print server!
A print server, the root of all evil, the misunderstood configuration medusa that makes every IT admin/user shed a tear of hatred/joy/sadness/anger every…. year? Week? Day? Second?

Why is this? Well, the drivers and the hardware have never been fully understood (configured right in the first place) which leaves a misconfigured Print Server and unsatisfied people, so I thought I’d let you know

What’s new in Windows 2012 Print Services and Print management!
The old print driver is a Version 3 which can lead to x86/x64 conflicts, oversized drivers, unneeded services, incompatibility with applications to mention a few things.

Starting with Windows 8 and Server 2012 – here comes the Version 4 drivers (class driver or model specific driver) which changes a couple of things…

 

But if you look in the “What’s new in Windows Server 2012” list on Technet, Print Services is not one of the key points.
So three of the main key points of a Windows Server 2012 Print server are1. There is no v3 driver support for Windows on ARM
2. The print server is no longer a software distribution mechanism
3. Group Policy Preference TCP/IP printers do not support Type 4 print drivers
4. The LPR/LPD protocol is deprecated and will eventually be removed

So how do I deploy a print server?

Micke Nyström promised he will write a blogpost on how to deploy printer drivers to the clients (MDT, SCCM) so I’ll leave that subject for now, but in short:

1. Install and share a printer on the server and select “List in the directory” so users can search for the printer.
2. Configure your print queues, separator pages etc. 
3. Do not install additional printer drivers on the server for clients to install. The clients will use the Microsoft enhanced Point and Print compatibility driver if it’s a Vista or Windows 7 client, and yepp, you guessed it, Windows 8 will have the V4 drivers available.

The point of all this is that printers were made for printing, if you want to configure the size of the paper, type of color and so on you shouldn’t have to package that into a separate print driver which needs to remain on the print server.

IF, however, you do have an old printer that only has a Version 3 driver and lots of fancy stuff which can’t be configured with the Microsoft enhanced Point and Print compatibility driver you can install a version 3 driver for the printer on the client, either with Windows Update or imaging (pre staging drivers in deployment).

If I may try to act ahead of administrators out there Theoretically and Technically In the Future our hardware printers will support all operating systems and application configurations of printers on the client side, so the question is if we need a print server at all…? You walk nearby the hardware, automatically the printer shows up, you configure the printer settings for the document or picture in your Windows 8 application and print the document to network printer.
…So the print server becomes a distribution point where you manage permissions…? I have no idea, but it seems logical to me.

So what I did on Saturday was:
1. Install a Windows Server 2012 printer
2. Installed all of the “old” printers with their IP addresses and picked the V4 driver (class driver) for the printer. Here I noticed that if I searched for drivers with Windows Update it removed some of the printers from the list…?
3. Configured the printer settings and clicked List in the Directory
4…. That’s it…



More information/considerations on this subject

The best page to find out more is the
Print and Documents Services Overview page, below are some notes that I found extra interesting and copied from the TechNet page:

Print and Document Services Architecture
One new aspect of the v4 print driver model is a focus on providing print class drivers. These special v4 print drivers, which implement only functionality that is common across a broad class of devices, are shipped with Windows and are marked as generic. As a result, Windows can automatically replace the driver with a better option from Windows Update, providing the end user with a better experience as soon as it is available.

There are several things you must consider when managing migrations using v3 print drivers. The first is that a print queue cannot function without the native printer driver for the server architecture (x86 or x64) on which it exists. Since Windows Server 2012 is a 64-bit only operating system, it is important that you have 64-bit drivers installed for all of your printers if you are migrating from a 32-bit system.

The line printer daemon protocol (LPR/LPD) is deprecated.
When this feature is eventually removed, clients that print to a server using this protocol, such as UNIX clients, will not be able to connect or print. Instead, UNIX clients should use IPP. Windows clients can connect to UNIX shared printers using the Windows Standard Port Monitor (see http://support.microsoft.com/kb/246868for more information).

There is no v3 driver support for Windows on ARM.
Running Windows on an ARM processor changes the paradigm with regard to power utilization and driver behaviors. The v4 print driver model supports printers on ARM with print class drivers while still allowing rich end user experiences thanks to a decoupled UI development model.

Prior Windows 8 then?
Operating systems prior to Windows 8 do not support the v4 driver model but can print to a v4 queue shared from a Windows Server 2012 print server by using the enhanced Point and Print Compatibility Driver which is hosted by any print server running Windows Server 2012.

Customized User Interfaces
V4 print drivers support customized user interfaces in both the Windows desktop and in the new Windows user interface. Due to the very different nature of these experiences, these UIs must be implemented as two different applications.
Printer extensions support v4 print drivers in the desktop and work with all existing applications. They also work in printer sharing scenarios with the enhanced Point and Print driver. Support is planned for all operating systems from Windows Vista through Windows 8.

V3 Printer Driver history
The prior model relied on both the server and the client computers using identical drivers; given the different supported architectures for Windows (x86, x64, and SoC systems) getting the right matching driver can be a difficult proposition. Incompatibilities between driver versions can cause client connection errors, and establishing connections can take a significant amount of time.
The overall goal of both the new v4 driver model and the sharing implementation that supports it is to make the end-user and administrative experience as easy as possible.

Features that define the changes that were made to printer sharing in Windows 8.
Clients can use enhanced Point and Print to generate print jobs that the server can use without using a device specific driver.

Servers can encapsulate the configuration and capabilities of the printer and communicate that data to a client computer in a way that the client computers can use without needing a device specific driver.

 The print server is no longer a software distribution mechanism.
Previous versions of Windows provided a mechanism by which print clients could obtain a driver from the print server. For reasons of security, compatibility, serviceability, and reliability, this functionality has been removed from the v4 driver model and enhanced Point and Print. Downlevel client computers will still be able to receive the enhanced Point and Print Compatibility driver from Windows Server 2012 servers to enable compatibility with v4 print shares. Client computers running Windows 8 have enhanced Point and Print support built into the operating system, and they can use standard point and print mechanisms to obtain matching v3 drivers if the administrator wants to continue using older drivers. Device specific v4 drivers can also be deployed to Windows 8clients, or downloaded from Windows Update/WSUS in order to provide additional features or capabilities, such as client side rendering when connecting to enhanced Point and Print shares.