New in Windows 10: Changing home to Pro w/ no reinstall!

August 03, 2015 FoxDeploy

One of the hotly anticipated features of Windows 10 is the ability to change your Windows version on the fly, without even needing to reinstall the OS!

This means that if you’re a Home user and want to start using advanced features like Hyper-V, which is only available on Pro, or to begin using your computer with BranchCache and other technologies only found on Enterprise, you don’t need to reinstall anymore.

WalkThrough

You decide one day that Hyper-V sounds awesome and you want to be able to run Virtual Machines on your laptop/desktop. You go to ‘Turn Windows Features on or off’ and

…you don’t see Hyper-V listed

Hyper-V is a Pro and Enterprise only feature, sorry!

As we know now, Hyper-V is a pro and enterprise feature only.  Double checking the version (using Windows+X, System) confirms that we’re running Windows 10 Home.

However, we now have the option to buy an upgrade and apply it at any time.  Assume you’ve paid to upgrade and now have a valid Windows 10 Pro license.  You can go back to System, and on the bottom, click Change product key.

This will prompt for Admin rights, so provide them, and you’ll see this screen.

No, this is not a valid license key.

If the key is valid, you’ll be prompted that your system needs to reboot.NoHyperV4

I hope you saved your files, as the upgrade waits for no man.

After a reboot, you’ll see the following. NoHyperV6

And just to confirm…

Pretty cool that we can now do this at any time without having to reinstall windows. The same works to go back to Home as well, just provide your license key and away you go!

Continue Reading...

Using PowerShell to find drivers for Device Manager

July 31, 2015 FoxDeploy

One of the most arduous tasks for a ConfigMgr admin is to build images to support new models of hardware for Operating System Distribution. As a SCCM Engineer, I’ve done this process for probably more than a hundred models now, and here’s how it normally goes.

How I solve missing drivers

• Connect my new device to the network • Do a fresh install off of a thumb drive or PXE of my current image and see what breaks • Boot into Windows and then look at Device Manager.

At this point, I’ll either jump up and down or I start crying, based on how many of my devices have an Exclamation point.

unhappy_device_manager

The process to figure out the device is to look at the device, in device manager->Properties->Details->Hardware IDs

How to find devices

I then lookup the info in an online repository. Like the PCI Database or Windows Update to find the actual driver from the vendor.

How to search

This works…but it could be better.

Using PowerShell

Johan Arwidmark is a well-respected SCCM God. He’s pretty much the best, period. He had a great blog post about the method he uses to find drivers, centered around a Walkthrough on a newer Lenovo system.

If you look into that post you’ll find a PowerShell one-liner that gives you a listing like this:

Johan

Which you can then use to step through your hardware reference site of choice.

Taking it one step further

I’ve been wanting to write something like this for a while, and a conversation with my friend Julie Andreacola over at CBfive prompted me to start coding. Why look up item by item, when you can use PowerShell to search through all of the listings and resolve all the names at once? Full download link on the text below.

Get-UnknownDevices

Using Johan’s code as a starting point, I’ve expanded it out, to now locate missing devices, grab the hardware and vendor IDs and then search the database for the device name using PowerShell!

Standard output looks like this

Get-UnknownDevices Standalone

When used in conjunction with an offline machin, simply Export the file

Export

Then Import on another system with Internet Access using the -Import switch to resolve those drivers issues

Import

I hope you like it! Full code will live on GitHub here : https://github.com/1RedOne/Get-UnknownDevices

Continue Reading...

Recovering your Dedeuped Files on Windows 10

July 31, 2015 FoxDeploy

Were you one of those who installed the server 2012 binaries into your Windows 8.1 to enable Disk Deduplication? Did you turn on dedupe on all of your drives, saving hundreds of gigs of storage space, then upgrade to Windows 10?

Upon boot, were you greeted with frequent ‘the machine cannot access the file’ errors? If so, then this is the guide for you!

This fixes the error 0x80070780: The file cannot be accessed by the system

What happened to my stuff? Did I lose it all?

NO!  You did not lose your files.  What happened when you ran deduplication on your files, is that Windows gradually scrubbed all of the common elements out of many files in order to compress them, much like what happens when you put files into a .zip or .rar archive.

All of your files still live on that disk or volume, happily compressed in their Optimized state and sitting snuggled up to their brethren.  However, until you ‘Unoptimize’ them, or connect the disk to a system with Windows Server Deduplication enabled, you cannot access any items bigger than 32KB (the minimum size for block level dedupe).

You have two methods to recover your files

These are both very similar, in the outcome, only the beginning differs.

Method 1 - Move the disk to another computer

Physically take the disks that are hosed and attach them to another system with ‘Data Deduplication’ enabled, could be any OS which supports it, even 8.1.  Once you’ve done this, proceed.

Method 2 - use Hyper-V to virtually move the disk

This is the method I used.

  1. Stand up another VM (in my case Server 2016 Tech Preview, though you could use 2012, 2012 R2, or even Windows 8.1) and installed the Storage -> Data Deduplication role on it.  Make sure to add one or more SCSI Hard Drive Controllers, one for each drive you need to ‘redupe’.Dedupe/redupe is incredibly IO and memory intensive.  Bump up the VMs stats to super level if you want this to be done quickly.
  2. Take the disks you need to ‘redupe’ offline.  I then went to my affected volumes in Disk Manager on my local machine and took the disks offline.  This is necessary in order to make this physical drive a ‘Passthru’ disk, which essentially connects the spinning disk to your VM.

    Once the disk is offline, we can attach it to a VM.  Do NOT accidentally format your drive here. Once the disk is offline, we can attach it to a VM. Do NOT accidentally format your drive here.

  3. In Hyper-V, attach the disk to your VM, by attaching it as a physical disk.[redupe2]
  4. Go into your VM and run Disk Management, and bring the disk online.  Do NOT accidentally format your disk here either.

    If you format your drive here, you'll now have even more problems.If you format your drive here, you’ll now have even more problems.

  5. Once the disks are all online in your VM, launch PowerShell as an admin and then run Get-DedupStatus to verify that all of your drives are listed.

    redupe4 Say goodbye to all of this optimized space…

  6. For each drive, run the following Cmdlet.
     Start-DedupJob -Volume "D:" -Type Unoptimization

If you only have one drive, run the cmdlet with -Wait so you can see how incredibly long this is going to take.

  1. Wait forever.  It takes a REALLY, REALLY REALLY really super long time to ‘redupe’ your files.

    It's been stuck at 0% for ten minutes! It’s been stuck at 0% for ten minutes!

    If you want to know how long it will take if you didn’t run this in -Wait mode, you can run

    Get-DedupJob
to see how long it will take, but don't sit around.  It will take forever. 8. Send Microsoft an e-mail or [vote for this issue on User Voice](https://windows.uservoice.com/forums/265757-windows-feature-suggestions/suggestions/6530781-put-data-deduplication-dedup-into-windows-client).   Seriously, Windows Desktop Enterprise and Pro could use some more distinguishing features.  Vote this up and hopefully we'll get Dedupe as a standard feature with Threshold in October.

Big thanks to fellow Microsoft MVP Mike F Robbins for his tweets and post on the matter, and to Microsoft Storage Program Manager Ran Kalanch for helping me to understand exactly what I’d done to my drives at midnight of the Windows 10 release.

Continue Reading...

PowerShell Hyper-V Configuration Backup report

July 19, 2015 FoxDeploy

In preparing my home lab to upgrade to Windows 10 (I’ll be leaving server 2012 R2 w/ Desktop experience behind, after years as my daily driver).

I realized that I’d essentially need to rebuild my Hyper-V setup (which really isn’t so bad, just reimporting my VM .xml files and then setting the VHDs the right way again) when I got to Windows 10, so I wanted a quick reference of which VM files were where and how my switches were laid out.

This is what I came up with!

VMConfig

It gives us first the configuration of all of our switches, whether they’re bound to a physical adapter and whether the management OS shares the NIC, if so. It then breaks down by VM, where the .xml file lives for it, which drives it has mounted, which NICs, whether Dynamic RAM is turned on and finally the startup memory.

Pretty much everything you’ll need to know when rebuilding VMs and you still have access to the source files!

This depends on the ZenGarden Css Theme from Css Garden.

$Switches = Get-VMSwitch | Select Name,SwitchType,AllowManagementOS,NetAdapterInterfaceDescription
 
 
$VMs = get-vm | % {
       $VMXML = gci $_.Path -Recurse -Include *xml | ? baseName -like "$($_.VMId)*"
       $VMDisk = Get-VMHardDiskDrive -VMName $_.Name | Select -expand Path 
       $VMNics = Get-VMNetworkAdapter -VMName $_.Name | select -expand SwitchName
       [pscustomobject]@{VMName=$_.Name;
            VMPath=$VMXML;
            Drives = $VMDisk -join "`n"
            NICs = $VMNics -join ";"
            DynamicMemory = $_.DynamicMemoryEnabled;
            StartupMemory = $_.MemoryStartup/1mb
            }
        
       } | ConvertTo-Html -Fragment
 
$base = $switches
 
 
$companyLogo = '
<div align=left><img src="C:\Users\Stephen\Dropbox\Speaking\Demos\logo.png"></div>
 
'
$header = @"
  
 $companyLogo
 
<h1>Hyper-V Configuration Report</h1>
 
 
 
The following report was generated at $(Get-Date) and contains the needed information to recreate the Hyper-V environment which existed before on $($Env:Computername)
 
 
 
 
 
<hr>
 
 
<h3>Switch Configuration</h3>
 
"@
 
$post = @"
 
<h3>VM Configuration</h3>
 
$VMs
 
 
<h3>These VMs were found on the L: and V: drives</h3>
 
"@
 
$HTMLbase = $base | ConvertTo-Html -Head $header -CssUri "C:\Users\Stephen\Dropbox\Speaking\Demos\style.css" `
                            -Title ("VM Configuration Report for $((Get-Date -UFormat "%Y-%m-%d"))") `
                            -PostContent $post
                                             
                                             
$HTMLbase | out-file l:\VMBackup_$((Get-Date -UFormat "%Y-%m-%d"))_Log.html 
Continue Reading...

Upcoming Events: PowerShell Training, by me!

June 22, 2015 FoxDeploy

If you’ve been following my blog, chances are that you enjoy PowerShell, and hopefully like my take on presenting information and the like! I’m happy to announce that we’ve got open registration now for two exciting upcoming PowerShell training events!

Here’s the ad for the classes! **

The South-Eastern PowerShell Bootcamp Tour

download

Come with no command line, DOS, VBScripting or other experience and leave writing powerful one-liners and scripts.  

You’ll receive poignant tips from the field in a custom course designed and taught by Microsoft MVP, Stephen Owen.

Bring your laptop and appetite, as Breakfast and Lunch are included!

Agenda

  • Intro to PowerShell - learn about what it is, who made it, why it’s different, and why some are saying ‘Learn PowerShell or get used to saying ‘…would you like fries with that?’
  • Diving into the Shell - starting with command line basics, we’ll build up through demo after demo and hands-on lab work to see just a few of the unique and productivity enhancing tools that PowerShell provides.
  • Enter the Pipeline - picking up speed, we’ll cover pipelining fundamentals, and by the end of this module, you’ll be able to perform very complex operations with only a handful of characters.
  • We’ll Do it Remote - we’ll explore the incredibly powerful built-in remote capabilities PowerShell offers, to let you scale from one-on-one to one-to-many and one-to-environment with your commands.  We’ll cover all the safety basics too!
  • Data Processing - able to natively process numerous datatypes, we’ll explore in-depth the data capabilities PowerShell provides, and end with a powerful section on report building sure to impress your colleagues and peers!
  • Advanced Scripting Techniques - We’ve done one-liners, now it’s time to scale and we’ll cover all of the tools you’ll need to quickly get started with enterprise ready scripting, including best practices for roll-back, code review and logging.
  • Spelunking with WMI - inevitably you’ll run into a situation for which a pre-made PowerShell cmdlet doesn’t exist yet, and at that point, it’s time to make our own!  We’ll go on a guided tour through the WMI Management Repository, and learn the few commands needed to extract anything from Windows with one or two lines of code.
  • Functions and Toolmaking - we’ll finish strong by expanding our scripts into reusable code and functions you can distribute to your peers.  By popular demand, the toolmaking module is being expanded into multiple units, now also covering the fundamentals of Easy Graphical User Interface tool creation using Visual Studio.  You don’t need to be a developer, as we’ll cover everything you need to know to start making GUIs in minutes.  You should leave this module with branded tools you can take back and put into use at the office!

Course Prerequisites

Time: Come ready to learn, as this is an all-day course.  Attendees will have access to the internet, but it is recommended that they have the full three days allocated to learn.  Because this is a boot camp style course, we will be moving swiftly as a group.

Laptop : Bring a capable laptop, PowerShell v4 capable.  You’ll need a minimum of Windows 7 and DotNet FrameWork 4.5.

Experience: So long as you have a basic understanding of Windows concepts like the Control Panel and Registry, we’ll build from the ground level up.  We’ll talk about a number of common services like Exchange and Active Directory, and the basics of their management.

This is intended as a Level 100 course, meaning you do not need to be an expert to attend.


 Registration

The first four stops of our Bootcamp tour are now completed, but registration is now open for our Summer stops, in Atlanta and Birmingham!

Continue Reading...

Check your US Postal Service Package Status with PowerShell!

June 19, 2015 FoxDeploy

Hey guys!

Been a while since I wrote up a fun little PowerShell REST API tool, so here we go! I taught a four day PowerShell boot camp for a Fortune 50 company, and during the event, one of my students called out the need to track his package delivery online.

The discussion quickly turned high-dork, as we dug in to see if there was a convenient way to get this information.

It turns out that the United States Postal Service has a REST API we can use to check for the status of package delivery.

You’ll need to sign up here for REST Api access first : https://www.usps.com/business/web-tools-apis/welcome.htm

To make a request, you need to query the following URL:

http://production.shippingapis.com/ShippingAPI.dll?API=TrackV2&XML=$xml 

You’ll notice the $XML, this is a special XML payload that needs to contain data in a certain format, here’s the template for a package delivery status page:

<?xml version="1.0" encoding="UTF-8" ?> 
  <TrackFieldRequest SERID="$userID">
    <TrackID ID="$pkgID"> 
    </TrackID> 
  </TrackFieldRequest> 

$pkgID will be a long package tracking number you’ll get in your e-mail when something is mailed to you, it’s about 22 characters long.

When you’ve signed up, you’ll get an e-mail like this one, this is your userId

SignUpInfo

From here on, it is pretty straightforward, all we have to do is use Invoke-WebRequest to query the URL and then check for some errors (I’ve planned for you to forget to provide your UserID, or to not provide a PKgID. If you leave these out…I’m not sure what you expect this to do :) ). If no errors are there, your package information will be contained within $Response.Content.TrackResponse.TrackInfo.TrackDetail.

Here’s an image of what it looks like!

ItWorks

Here’s the code!

<#
.Synopsis
   Use this tool to query the US Postal Service to find out where your packages are!
.DESCRIPTION
   Use this tool to query the US Postal Service to find out where your packages are!
.EXAMPLE
    Get-USPSPackageStatus -UserID 578FOXDEPLOY -pkgID 94HAMHAMHAMHAM95621412407
 
EventTime EventDate     Event                                 EventCity EventState EventZIPCode EventCountry FirmName Name AuthorizedAgent
--------- ---------     -----                                 --------- ---------- ------------ ------------ -------- ---- ---------------
8:45 am   June 15, 2015 Out for Delivery                      MARIETTA  GA         30066                                   false          
8:35 am   June 15, 2015 Sorting Complete                      MARIETTA  GA         30066                                   false          
6:00 am   June 15, 2015 Arrived at Post Office                MARIETTA  GA         30066                                   false          
1:28 am   June 15, 2015 Departed USPS Facility                ATLANTA   GA         30320                                   false          
2:43 pm   June 14, 2015 Arrived at USPS Facility              ATLANTA   GA         30320                                   false          
4:44 am   June 13, 2015 Departed USPS Facility                ANAHEIM   CA         92899                                   false          
9:31 pm   June 12, 2015 Arrived at USPS Origin Facility       ANAHEIM   CA         92899                                   false          
8:16 pm   June 12, 2015 Accepted at USPS Origin Sort Facility SANTA ANA CA         92704                                   false          
 
 
.EXAMPLE
   Get-USPSPackageStatus -UserID 578FOXDE2122 -pkgID 94HAMHAMHAMHAM9562141240
The most recent event we can track is below
 
EventDate                                                                     EventTime                                                                     Event                                                                        
---------                                                                     ---------                                                                     -----                                                                        
June 15, 2015                                                                 1:43 pm                                                                       Delivered, In/At Mailbox                                                     
Here is the summary of what we know about the package
 
 
 
EventTime               EventDate               Event                   EventCity               EventState             EventZIPCode           EventCountry           FirmName               Name                   AuthorizedAgent       
---------               ---------               -----                   ---------               ----------             ------------           ------------           --------               ----                   ---------------       
8:45 am                 June 15, 2015           Out for Delivery        MARIETTA                GA                     30066                                                                                       false                 
8:35 am                 June 15, 2015           Sorting Complete        MARIETTA                GA                     30066                                                                                       false                 
6:00 am                 June 15, 2015           Arrived at Post Office  MARIETTA                GA                     30066                                                                                       false                 
1:28 am                 June 15, 2015           Departed USPS Facility  ATLANTA                 GA                     30320                                                                                       false                 
2:43 pm                 June 14, 2015           Arrived at USPS Faci... ATLANTA                 GA                     30320                                                                                       false                 
4:44 am                 June 13, 2015           Departed USPS Facility  ANAHEIM                 CA                     92899                                                                                       false                 
9:31 pm                 June 12, 2015           Arrived at USPS Orig... ANAHEIM                 CA                     92899                                                                                       false                 
8:16 pm                 June 12, 2015           Accepted at USPS Ori... SANTA ANA               CA                     92704                                                                                       false                 
 
 
Your package was delivered!
#>
function Get-USPSPackageStatus {
param($UserID="Something",
$pkgID='9400111899562141240724',[switch]$Passthru)
 
$xml = @"
<?xml version="1.0" encoding="UTF-8" ?>
<TrackFieldRequest USERID="$userID">
    <TrackID ID="$pkgID">
   </TrackID>
</TrackFieldRequest>
"@
 
$url = @"
http://production.shippingapis.com/ShippingAPI.dll?API=TrackV2&XML=$xml
"@
 
#Get the response and save in a variable $Response
$response = Invoke-WebRequest $url
     
    #Check for an error
 
        if ((([xml]$response.Content | select -ExpandProperty Error -ErrorAction SilentlyContinue) -ne $null) -or ([xml]$response.Content | select -ExpandProperty TrackResponse | select -Expand TrackInfo  | select -ExpandProperty Error -ErrorAction SilentlyContinue) -ne $null){
     
            if (([xml]$response.Content | select -expand Error -ErrorAction SilentlyContinue).Number -eq "80040B1A")  {
                Write-Warning "We hit an error: Check your user credentials, specifically the value for `$userID :$UserID"
                BREAK
                }
 
            if (([xml]$response.Content | select -ExpandProperty TrackResponse | select -Expand TrackInfo  | select -ExpandProperty Error -ErrorAction SilentlyContinue) -ne $null){'ham'
                Write-Warning "We hit an error: Check the package ID you specified, `$pkgID :$pkgID"
                BREAK
            }
                 
        }
 
    #Show the most recent event
 
    $status = [xml]$Response.Content  | select -expand TrackResponse | select -ExpandProperty TrackInfo | select -expand TrackSummary | select EventDate,EventTime,Event
     
    Write-output "The most recent event we can track is below"
     
        if ($Passthru){$status}
            else{
                $status | select EventDate,EventTime,Event | Format-Table -AutoSize
            }
 
    Write-output "Here is the summary of what we know about the package"
    #take the response which is XML and Cast it to make PowerShell parse it better
    $details = [xml]$Response.Content  | select -expand TrackResponse | select -ExpandProperty TrackInfo | select -expand TrackDetail 
 
        if ($Passthru){$details}
            else{
                $details | Format-Table -AutoSize
            }
 
    if ($status.Event -like "Delivered*"){
        Write-Host -ForegroundColor Green "Your package was delivered!"
    }
 
} 
Continue Reading...

Microsoft MVP

Five time Microsoft MVP, and now I work for the mothership


Need Help?

Get help much faster on our new dedicated Subreddit!

depicts a crowd of people in a night club with colored lights and says 'join the foxdeploy subrreddit today'


Blog Series
series_sml_IntroToDsc
series_sml_PowerShellGUI series_sml_IntroToRaspberryPi Programming series_sml_IntroToWindows Remote Management Series The Logo for System Center Configuration Manager is displayed here Depicts a road sign saying 'Learning PowerShell Autocomplete'




Blog Stats