The Deployment Bunny

OS Deployment, Virtualization, Microsoft based Infrastructure…

  • about.me

    Mikael Nystrom

    Mikael Nystrom

    OS Deployment Geek, Virtualization and System Center

    Mikael Nystrom is a Microsoft MVP and Principal Architect at TrueSec

  • Archives

  • Meta

PowerShell Is King – Run a EXE inside with style and exit code control

Posted by Mikael Nystrom on June 15, 2015

So, in reality there is many ways to do this, but this is the method I have found to be the most reliable and it gives me the functions I need. It runs it, it waits, returns the return code and if the does not match it fails. The script is based on bits and pieces found in different location on the Internet, thinking and working.

image

It is created as a function, that way you can drop it directly into your script and just it.

Example: Ping 127.0.0.1 with the expected exit code of 0 should returned.

image

Example: ping 127.0.0.1 with the expected exit code of 10 which will NOT be returned

image

I use this module in basically every new script I create, there is always an exe that needs to run…

You can download the snippet here. http://1drv.ms/1bwlwXm

/mike

Posted in PowerShell | Tagged: | 1 Comment »

PowerShell is King – Compress, Compact, Optimize VHD and VHDX files

Posted by Mikael Nystrom on June 15, 2015

I was reading a thread at Facebook in our user group, someone was trying to compress/compact/optimize a VHD(VHDX files but the result was depressing, the amount of reclaimed space was zero and that is kind of low… Now there is a good explanation for that, when using the UI there is no way to configure it and the UI also don’t inform you that the ONLY way to get it small is to mount it in Read Only mode. It really has to be mounted, otherwise there is now way to see “inside” the disk and to get rid of all the Zero blocks. It does not hurt if you also run defrag and cleanup inside the VM before, but the most important thing is that it needs to be mounted.

The documentation for the PowerShell command says:

image

The Script:

So, to make things easy for my friends in the User Group I created a simple script that will find the disks for the VM, check if the VM is running and if not mount each file in read only mode with no drive letter, optimize the VDH and dismount it. So the output of the script looks like this when running using –verbose

image

and here is how the script looks like:

image

and you can download the script here…http://1drv.ms/1IES3pB

/mike

Posted in Hyper-V, PowerShell | Tagged: , , | 1 Comment »

Back to Basic – CustomSettings.ini – Converting Desktop and Laptop computer types into Roles

Posted by Mikael Nystrom on May 22, 2015

So, someone asked me(you know who you are) if it is possible to convert something like a computer types into a role, and yes that is possible and some times a pretty smart thing to do. If you have basically to kind of roles in your org and they are based on the fact that the computer is a Laptop (like a field engineer) or a Desktop (like a standard office user), well then it should work.

Converting Computer types into Roles:

In the Priorityline we have ByDesktop,ByLaptop,Role and Default

We use [ByDesktop] to return a value of yes/no and we store that in IsDesktop-Yes if it is a desktop and then we send it to a section with the name of IsDesktop-Yes. In the section [IsDesktop-True] we assign it the Property Role001 to ComputerIsDesktop. Now we can create a role in customsettings.ini, or we could create a Role in the MDTdatabase if you would like that instead and then assign all settings to that. In this case we will create a Role section called [ComputerIsDesktop] and in that role we will define all settings for that role, in this case it will be an application and then we repeat that story for a laptop.

image
Sample CustomSettings.ini file

image
Output from testing the customsettings.ini file and as you can see it has been assigned the role correctly and since it is a laptop it will get the laptop app.

You can download the sample ini files here: http://1drv.ms/1LiIw7H

The UserAlias Userexit script is here: http://1drv.ms/1LiIVHh

Instructions on how to test customsettings.ini is here:https://anothermike2.wordpress.com/2011/04/27/quick-and-dirty-testing-customsettings-ini-variables-in-mdt/

Posted in ConfigMgr, MDT, OSD | Tagged: , , , | 1 Comment »

Back to Basic – CustomSettings.ini – Converting Model and ModelAlias into Roles

Posted by Mikael Nystrom on May 22, 2015

So, someone asked me(you know who you are) if it is possible to convert something like a computer model into a role, and yes that is possible and some times a pretty smart thing to do. It becomes really great if you are using the ModelAlias Userexit script and you would like to use the database to define settings. The database has support for make and model, but since you are using modelalias instead of make and model, well then you can define settings as a role instead. The only thing you need to do is to convert the ModelAlias value into a Role and you are done. In this post I will describe two scenarios, one when you convert model into a role and the other is when you turn the modelalias into a role.

Converting Model into a Role:

In the customsettings.ini file we have three sections in the priority line: ConvertModelToRole,Role,Default and one customproperty just for fun

  1. ConvertModelToRole – will set the Role001 into RoMo-“the return of the model”
  2. Role – will search for a section with the name of RoMo-“the return of the model”
  3. Default – set default values

image
Sample CustomSettings.ini file

image
The output when running ZTIGather.wsf to test the inifile.

Converting ModelAlias into a role:

In the customsettings.ini file we have four sections in the priority line: HardwareInfo,ConvertModelToRole,Role,Default

  1. HardwareInfo – will execute the modelalias userexit script and return a value from that script
  2. ConvertModelToRole – will set the Role001 into RoMo-“the return of the model alias user exit script result”
  3. Role – will search for a section with the name of RoMo-“the return of the model alias user exit script result”
  4. Default – set default values

image
Sample CustomSettings.ini file

image
The output when running ZTIGather.wsf to test the inifile.

You can download the sample ini files here: http://1drv.ms/1LiIw7H

The UserAlias Userexit script is here: http://1drv.ms/1LiIVHh

Instructions on how to test customsettings.ini is here:https://anothermike2.wordpress.com/2011/04/27/quick-and-dirty-testing-customsettings-ini-variables-in-mdt/

/mike

Posted in ConfigMgr, MDT, OSD | Tagged: , , , | Leave a Comment »

Speaking at SCUG.no – 2015-06-05

Posted by Mikael Nystrom on May 10, 2015

I’m proud to announcing that I will be one of the speakers at SCUG.no

My session is at 13:30 to 14:30 and will 100% focusing on Windows Server 2016 in the Modern Datacenter!

Session 4: “Windows Server vNext in the Modern Datacenter”

Windows Server has changed over the last few years, it has now become the main engine regarding Software Defined Compute, Storage and Network. In the demo intense session you will learn how to design, build and take advantage over the new features in Windows Server vNext.
(Speaker: Mikael Nystrom, MVP)

image

For more information http://www.scug.no/events/system-center-user-group-meeting-june-2015/

/Mike

Posted in Event, SCUG.no, Windows Server vNext | Tagged: , | Leave a Comment »

Microsoft Virtual Academy (MVA) – Storage Spaces Deep Dive

Posted by Mikael Nystrom on May 8, 2015

I have been working with Windows Server Storage Spaces since it was invented. It is great technology and I love it! Recently I was asked to be a part a MVA session on Storage Spaces and I just could not resist. My idea was to do something that is based on our real experience building storage spaces solutions.

So, together with Markus Lassfolk and Ola Skoog we did a Microsoft Virtual Academy class with four parts,

  • Storage Spaces: Architecture

  • Storage Spaces: Design

  • Storage Spaces: Performance

  • Storage Spaces: Lessons From The Field

If you are into Storage Spaces and you would like to know from experienced MVP’s building Storage Spaces, this is for you, Enjoy!

http://www.microsoftvirtualacademy.com/training-courses/storage-spaces-deep-dive

image

Posted in MVA, Storage Spaces, Training, Windows Server 2012 R2 | Tagged: , , , | Leave a Comment »

Windows Server vNext – Hyper-V in Hyper-V

Posted by Mikael Nystrom on May 1, 2015

Yes, it is true

image

Continue reading the story at the source for much more information!!!

http://www.hyper-v.nu/archives/hvredevoort/2015/05/nested-hypervisor-in-windows-server-vnext/

Posted in Hyper-V, Windows Server vNext | Tagged: , | Leave a Comment »

Nice to Know – Deploying Windows 10 IoT to a Raspberry PI 2

Posted by Mikael Nystrom on May 1, 2015

So, just for the fun of it I got 2 Raspberry PI 2 a while back, someone said to me that they could run Windows 10 and therefore they can be deployed, and therefore I must try. So far I have no idea what to do with them, but I’ll find out eventually.

Note: My friend Johan Arwidmark has done a great Video, you will find it here: https://www.youtube.com/watch?v=Q5SfPTykM6A

Step One:

image

Go to https://dev.windows.com/en-US/iot

Step Two:

image

Select the Raspberry Pi 2 (or if you have something else, select that device)

Step 3:

This is what you need:

  • A PC running Windows 10 (it can be a VM “if” you have a VM platform that can write to a Micro SD card) build 10069 or higher
  • A Raspberry Pi 2
  • A Micro USB power supply, go for one with 2A or better, that way you will have enough power when you start connecting stuff to your USB ports
  • A Micro SD Class 10 device, I’m running the Samsung Evo 16GB Micro SD’s, works great!
  • A HDMI cable and a monitor, just for the fun to see when things happens, but not needed
  • An Ethernet cable connect to your network with DHCP
  • The “image” that you get from connect http://connect.microsoft.com/windowsembeddedIoT/Downloads/DownloadDetails.aspx?DownloadID=57782

WP_20150501_001

This is how you do:

  • Download and unzip the image from connect and store in a folder
  • Insert the Micro SD in your computer
  • Find the disk number that SD card is using (take a pick)
    • Using Disk part
      Diskpart.exe
      List Disk
      image
    • Using WMIC
      wmic diskdrive list brief
      image
    • Using PowerShell
      Get-PhysicalDisk | Select-Object FriendlyName,DeviceId
      image
  • Apply the Image to the Micro SD using an elevated prompt usin g this command. Note Replace “N” with your number for the drive:

    dism.exe /Apply-Image /ImageFile:flash.ffu /ApplyDrive:\\.\PhysicalDriveN /SkipPlatformCheck
  • Wait until it is done and use the safe remove feature in Windows to remove the Micro SD

Step 4:

  • Insert the Micro SD in the Raspberry PI
  • Connect Network
  • Connect HDMI
  • Connect Power
  • It will now boot and configure it self, when its done you should see this:

WP_20150501_003

Step 5:

So, the PI is up and running and you need to connect to it and to do that you need an IP address, and that’s when the HDMO monitor comes very “handy” since the IP address will be on that screen…

image

#Bug fix for StackOverFlow
remove-module psreadline -force

#Setting Vars
$ThePIIP = ‘192.168.133.125’
$ThePIPassword = ‘p@ssw0rd’
$ThePIUserName = ‘Administrator’
Set-Item WSMan:\localhost\Client\TrustedHosts -Value $ThePI -Force

$SecurePassword = $ThePIPassword | ConvertTo-SecureString -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $ThePIUserName, $SecurePassword

Enter-PsSession -ComputerName $ThePIIP -Credential $Credentials

After that you should have a remote PowerShell prompt up and running and if you do it in ISE, you will also see that the command windows on the right side will get updated with all the commands that does exist in the OS:

Step 6:

Time to configure:

Here is a nice link of commands that are available

http://ms-iot.github.io/content/win10/tools/CommandLineUtils.htm

You should change the password and if you want you can also change the name of the device…

Step 7:

Just for the fun of it:

You can access the device using FTP:

image

If you browse to ftp://192.168.133.125/Windows/ImageUpdate/OEMInput.xml you can see that you are actually running a Windows Phone…

image

You can access the device using the web:

image

When accessing using the web you will see a bunch of different functions you can perform, you can even upload your appx applications and install them…

Links that you will find handy:

https://www.youtube.com/watch?v=Q5SfPTykM6A

http://www.element14.com/community/docs/DOC-76402/l/windows-10-iot-core-on-the-raspberry-pi-2

http://www.element14.com/community/docs/DOC-76415/l/running-windows-10-iot-core-and-code-on-the-raspberry-pi-2

http://microsoft.hackster.io/

https://www.youtube.com/watch?v=Hkm4THS3Rf8

/mike

 

 

 

 

 

Posted in IOT, Windows 10 | Tagged: , | 2 Comments »

Speaker at Windows Management User Group Netherlands (WMUG NL) on 2015-05-13

Posted by Mikael Nystrom on May 1, 2015

I’m proud to be invited to speak at WMUG in May. This time my session is all about Windows Server vNext. The Session will be in English, mostly because my Dutch is not really that good, in fact its horrible…

image

To sign up:

http://wmug.nl/2015/05/01/wmug-webinar-3-13-05-2015-windows-server-vnext-get-ready-hosted-by-mikael-nystrm-microsoft-mvp-and-principal-architect-at-truesec/

/mike

Posted in Event, Windows Server vNext | Tagged: , | Leave a Comment »

Nice to Know – Windows 10 OS Deployment links

Posted by Mikael Nystrom on May 1, 2015

Here are the basic media you need to start Windows 10 OSD.

Windows ADK RC for Windows 10

image

https://msdn.microsoft.com/en-us/windows/hardware/dn913721(v=vs8.5).aspx

(Note: it will be located at the last part of the page)

Windows 10 Insider Preview ISO April Update

image

http://windows.microsoft.com/en-us/windows/preview-iso-update-1504

Windows 10 Enterprise Insider Preview

image

https://www.microsoft.com/en-us/evalcenter/evaluate-windows-enterprise-insider-preview

MDT 2013 Update 1 Preview

image

https://connect.microsoft.com/ConfigurationManagervnext/Downloads/DownloadDetails.aspx?DownloadID=57061

/mike

Posted in MDT, OSD, Windows 10 | Tagged: , , | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.

Join 5,295 other followers