You have a CSV file that has data that needs to be added to Active Directory you say?

You aren't going to believe this, but today's your lucky day. Funnel that CSV file into this script, and you're on your way to happiness.

But seriously, this is something I assembled and cleaned up from the remnants of another script. Simple, easy to understand, and quick. I processed records for just over 300 users in 42 seconds. That'll do.

# Update AD User Data
# Source data in CSV format
# 2018 - Joel Spangler
# Bell and Evans

# Get script Start Time
$startTime = (Get-Date)

# set path to input file
$csvfile = "C:\scripts\ADImport\adexport.csv"

# Specify Domain
$ADServer = 'farmerspride.com'

# Import the AD Module
Import-Module ActiveDirectory


# Create Function to import data from CSV and perform corresponding AD Updates

Function Update-ADUsers {

    Import-Csv -path $csvfile | `
    ForEach-Object {
        # Each of the following corresponds to the Fields defined in the CSV file
        $DisplayName = $_.Name
        $Description = $_.Description
        $Department = $_.Department
        $Title = $_.'Job Title'
        $Office = $_.Office
        $Mobile = $_.'Mobile Phone Number'
        $Phone = $_.Telephone
        $sam = $_.Username
        $Address = $_.StreetAddress
        $State = $_.State
        $Company = $_.Company
        $Country = $_.Country
        $City = $_.City

        # Manager Field takes some extra work.
        $Manager = $_.Manager
        if ($Manager -ne $null){$Manager = Get-ADUser -Filter {Name -like $Manager} | select -Expand DistinguishedName}

        # Verify AD Account
        Try { $SAMinAD = Get-ADUser -server $ADServer -LDAPFilter "(sAMAccountName=$sam)"} 
        Catch { }

        # If statement - Valid If AD user exists
            If($SAMinAD -ne $null -and $sam -ne '') {

            # evaluate each field - if data us present - update corresponding field - match each field to ADSI attribute name
            If ($DisplayName -ne '') { Set-ADUser -server $ADServer -Identity $sam -Replace @{displayName=$DisplayName} }
            If ($DisplayName -ne '') { Set-ADUser -server $ADServer -Identity $sam -Replace @{cn=$DisplayName} }
            If ($Description -ne '') { Set-ADUser -server $ADServer -Identity $sam -Replace @{description=$Description} }
            If ($Department -ne '') { Set-ADUser -server $ADServer -Identity $sam -Replace @{department=$Department} }
            If ($Title -ne '') { Set-ADUser -server $ADServer -Identity $sam -Replace @{title=$Title} }
            If ($Manager -ne '') { Set-ADUser -server $ADServer -Identity $sam -Replace @{manager=$Manager} }
            If ($Office -ne '') { Set-ADUser -server $ADServer -Identity $sam -Replace @{physicalDeliveryOfficeName=$Office} }
            If ($Mobile -ne '') { Set-ADUser -server $ADServer -Identity $sam -Replace @{mobile=$Mobile} }
            If ($Phone -ne '') { Set-ADUser -server $ADServer -Identity $sam -Replace @{telephoneNumber=$Phone} }
            If ($Address -ne '') { Set-ADUser -server $ADServer -Identity $sam -Replace @{streetAddress=$Address} }
            If ($State -ne '') { Set-ADUser -server $ADServer -Identity $sam -Replace @{st=$State} }
            If ($Company -ne '') { Set-ADUser -server $ADServer -Identity $sam -Replace @{company=$Company} }
            If ($Country -ne '') { Set-ADUser -server $ADServer -Identity $sam -Replace @{co=$Country} }
            If ($City -ne '') { Set-ADUser -server $ADServer -Identity $sam -Replace @{l=$City} }


            }

            Else { 
            
            #Error - AD User does not exist
            " User $sam not found in AD "
            
            }
         

        }

}
#End Function


#Run Function
Update-ADUsers

# Set End Time
$endTime = (Get-Date)

# Calcualate total time to run. Unnecessary, but fun.
"Elapsed Time: $(($endTime-$startTime).totalseconds) seconds"
"Elapsed Time: $(($endTime-$startTime).totalminutes) minutes"

Did a Microsoft patch break Hyper-v For You? Me too! Luckily there's a fix.

A while back there was quite the buzz about the Meltdown/Spectre vulnerabilities related to x86 code on AMD and Intel processors. There were firmware updates, patches, and general hysteria for about a week. Well, as it turns out, windows server patch kb4056898 decided to break one of my hyper-v hosts. The patch prevented any VMs from starting. The only immediate fix was to remove the patch. 

Well, as it turns out, that patch got rolled into newer patches. Basically any Security rollup after January 2018 contains the patch. So removing the patch every month wasn't really an option. But without fail, the VMs on this isolated host would just go down every time the server was patched. Well, after much reading, and searching, it turns out that this security update had Registry Keys that had to be modified, manually.... Microsoft strikes again. 

Well, I finally stumbled upon a thread that covers the whole thing rather in depth:

https://community.spiceworks.com/topic/2104499-jan-2018-windows-updates-kb4056898-causing-hyper-v-guests-crash

And just in case anyone else has run into this buzzsaw, keep in mind this would also effect Docker as well, here are the steps to get things back to normal:

Do all of this from and elevated command prompt:

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v FeatureSettingsOverride /t REG_DWORD /d 3 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v FeatureSettingsOverrideMask /t REG_DWORD /d 3 /f

Restart the server for the changes to take effect.

Enable the fix

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v FeatureSettingsOverride /t REG_DWORD /d 0 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v FeatureSettingsOverrideMask /t REG_DWORD /d 3 /f
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v MinVmVersionForCpuBasedMitigations /t REG_SZ /d "1.0" /f

Restart the server for the changes to take effect.

And voila! Your VMs will start right up. Also keep in mind that I had the issue on Server 2016, while in the article, he has the issue on 2012 R2. So this isn't specific to the OS version it seems.

The Good 'ole Days, Apple Edition.

Let me start by saying that I am of the generation that grew up along side the personal computer. Apple IIe's and IBM PC's were not unlike an adopted sibling in my childhood. I saw the release of the 386, 486, Pentium Series on the PC side. I saw the Mac go from 68k to PowerPC, and then to Intel. I started using computers when you had to insert a floppy disk to do anything at all. I was all of 5 years old when Color Monitors became a thing. Let that sink in.

It's no secret that I am, and always have been, an Apple guy. I loved Macs back when it wasn't cool to love Macs. I read the magazines, I played with the Shareware from the MacAddict CD included with every issue on the family Performa. I was there when Apple had approximately 16 different product lines, all of which barely differed, except for price. I remember the clone wars, and frankly, miss the clone wars. I was there in 98 when the iMac came out, and a year later when the Power Mac G4 changed the game. The rise of Jobs, the iPod, and on and on. 

By now of course Apple is mostly known for two products, the iPhone and the iPad. Both products were transformative in the tech world, and have created an entire new ecosystem of products. The rise of Android immediately followed, even Microsoft tried and later conceded an attempt at a mobile OS. The world has changed, what was once sci-fi fantasy, is now reality. I can check an email, watch a movie, video chat, take pictures that rival any consumer camera, make a movie, and do so many other things, on a device that fits in my pocket. 

It's been a crazy 20 years in the tech world, and particularly if you are an Apple fan. Apple was creating new products every year, and we all waited in anticipation at what the new Powerbook, MacBook Pro, iMac, Power Mac, or iPod would bring. It was exciting. I would follow live blogs, several at once when possible to make sure I knew what was coming. Going to an Apple store and witnessing these products in person was an experience not possible with a Dell Laptop, or some other generic PC. 

I remember when I bought a MacBook Pro, my first Mac that I bought with my own hard earned money. It was an incredible machine, and lasted me for nearly 8 years. It never slowed down, and if it wasn't for the video card finally giving out, I would probably still be using it. It was an elegant and powerful machine, it almost gave you purpose using it. This sounds silly I know, I'm gushing about a laptop. But to me, it was an awesome thing. I learned how to make a website, do graphic design, and all kinds of fun stuff on that laptop. 

That was in 2006. At the time, there were still regular product updates, spec increases, the Mac world was thriving. Us desktop computing types were in hog heaven. The iPhone was going to come onto the scene the following year, though no one knew that at the time. On the forums there was still talk of a touch screen iPod, with countless different concepts created by fans. Apple was still largely considered a Pro Desktop brand. Things were good.

Despite the iPhone dominating the Apple world in the following years, we would still see mac updates fairly regularly, new iMacs, Retina displays, SSDs, all of these things would come into play over the next 7 or so years. I got a Retina MacBook Pro in 2014 when my 2007 version finally bit the bullet. It was like hopping into a Formula 1 car after your 98 Camry finally died. This laptop seems to be the last remnant of the Mac days gone by. And Apple's overall neglect of their MacOS environment has proven as much since then.

The Mac Mini, a great machine, and perfect for the everyday user hasn't been updated since 2014. Even after the 2014 update somehow made it worse than it's predecessor. You can build your own Mac nowadays (if so inclined) that will rival this in size, and perform at the level of a much more expensive machine, for the same price.

The Mac Pro remains untouched since 2013. We are nearing five years without a hardware update for a desktop that is meant to be used by professionals. It's not surprising that most movie houses have reported abandoning these machines, especially when you consider that recent year iMacs are out-benchmarking them. Yikes.

The MacBook Pro is still being updated, although in a somewhat uninspired fashion. Apple seems to be maintaining these mainly because they still sell well, not to mention they see a lot of air time on cable TV. But their pension for ruining peripheral support continues. How many USB-C products do you see nowadays? (not many) Although this will certianly change I'm sure. For now it's dongle land for new MBP users. 

The iMac is also being maintained to an extent. This is the sweet spot desktop machine for Apple. It can be purchased with a 4k display for a shockingly competitive price. And it packs a punch. (again, it can outperform the current Mac Pro)

This brings me to why I wrote this rambling agitated Mac User mess of a blog post. 

The iMac Pro. What a joke. 

Mac users have been begging for an updated Mac Pro for years. The last design was cool in concept, but severely lacking in real world usage. So they release a $5000 all-in one some five years later. Huh? Apple continues to claim that they have a fantastic Mac Roadmap. Not seeing it.

Pro Users do not want, or need, a souped up consumer all in one. Hmm, lets upgrade that hard drive, oh, it's soldered to the motherboard. Hmm. Oh, we should bump up the RAM for this new project. Oh, can't. Ok. None of this is desirable. It's like Apple said, "we hear your criticisms, and we ignored all of them and went the opposite way. Give us $5,000."

I want to see Apple release something exciting again. The iPhone and iPad were cool. The iPhone X is neat. But what makes the iOS world cool is isn't the hardware, it's the apps within. iOS is a software defined world, and we are all living in it. The only competitive hardware feature left is the camera, everything else washes out. All of the phones have OLED screens, and high powered processors. It's a level playing field. the OS and the Apps are what draws you to one or the other. Regardless, the feeling is gone. Nothing is Apple like anymore, and Think Different no longer applies. Apple seems to be, albeit slowly, distancing themselves from what got them to that fateful day in 2007 when they changed the world.

I have come to the realization that I'm the old guy on the lawn of technology, yelling at Apple to come back to their senses, and keep the Mac alive. Call me crazy, but I still think desktop computers are important. Apple has had every chance to evolve the Mac with the times, and has seemed to ignore it instead. I guess I can accept that Apple will never truly be "Apple as I remember it" again. It kind of sucks in a way. I just haven't wrapped my head around the world where we all just use tablets yet. 

I am probably looking way too far in the future, but my history with Apple is what leads me to believe what the future holds. 
On the other hand, they are charging 5 grand for an all in one desktop (yes, it is quite powerful, I get it), so I guess things haven't changed that much. Yet.

Maybe 2018 will be the year that they come to their senses. That would be awesome. At least I know it would be for a bunch of 30-somethings like me.