System Center 2016 VMM Place template VM in Custom OU #sysctr #Cloud #Deploy #VM

when using VMM and deploying templates you not always want to place them in the default OU computers

image

But instead you want the Template Server 2016 places in OU TP5 and Hyper-V server directly placed in the OU Hyper-v.

Default there is no Gui item in the VMM console to do this. Say on the domain join tab place this VM in the Hyper-V OU

 image

Instead of this you need to fill in the Value in Powershell. and Make a custom OU field.

image

You can Add Custom Properties as you like.

But first we are creating a Custom Guest OS profile this profile is the basis for the new build template and the Custom OU Placement.

image

Now that the Custom OS profile is in place we can check it there is a domain OU field

Get-SCGuestOSProfile

image

this shows us the field that we must fill in to get the right OU placement.

Get-SCGuestOSProfile |select Name

image

Get-SCGuestOSProfile -name "Guest OS 2016TP5"

Setting this in the OS profile

Get-SCGuestOSProfile -name "Guest OS 2016TP5" |Set-SCGuestOSProfile -DomainJoinOrganizationalUnit "OU=SCVMM16,DC=MVP,DC=local"

image

Now when I create a new template with this OS profile the VM is place in the SCVMM16 OU but it is not anywhere visible in the GUI.

and what if I have already build templates how to place them in Custom OU.

Yes you can do this. First I select all the templates to pick the right one

Get-SCVMTemplate |select name

image

 

$template = Get-SCVMTemplate | where {$_.Name -eq "ws2016G2"}
$template |select name

image

As I made the OU a variable :

$ou = "OU=SCVMM16,DC=MVP,DC=local"

Set-SCVMTemplate -VMTemplate $template -DomainJoinOrganizationalUnit $ou

 

image

So now the Template has a custom OU also.

But still there is no GUI property to show this. therefore go to the Template and create a Custom Property

image

go to the Manage custom Properties

image

Select Virtual Machine Template Properties give it a name “ custom OU “ and assign this to the template

image

Now that tis is assigned we can enable this in the GUI

imageimage

But before we get any value in this field we need match this with the PowerShell Value DomainJoinOrganizationalUnit

 

Get-SCVMTemplate | %{ Set-SCCustomPropertyValue -InputObject $_ -CustomProperty $(Get-SCCustomProperty -Name "Custom OU") -Value $_.DomainJoinOrganizationalUnit }

 

image

As you can see there is an error this is because one template has no value.

image image

 

Now With new deployments the VM’s will be places in the Custom OU

image

 

 

Follow Me on Twitter @ClusterMVP

Follow My blog https://robertsmit.wordpress.com

Linkedin Profile Http://nl.linkedin.com/in/robertsmit

Google Me : https://www.google.nl

Bing Me : http://tinyurl.com/j6ny39w

LMGTFY : http://lmgtfy.com/?q=robert+smit+mvp+blog

Author: Robert Smit [MVP]

Robert Smit is Senior Technical Evangelist and is a current Microsoft MVP in Clustering as of 2009. Robert has over 20 years experience in IT with experience in the educational, health-care and finance industries. Robert’s past IT experience in the trenches of IT gives him the knowledge and insight that allows him to communicate effectively with IT professionals who are trying to address real concerns around business continuity, disaster recovery and regulatory compliance issues. Robert holds the following certifications: MCT - Microsoft Certified Trainer, MCTS - Windows Server Virtualization, MCSE, MCSA and MCPS. He is an active participant in the Microsoft newsgroup community and is currently focused on Hyper-V, Failover Clustering, SQL Server, Azure and all things related to Cloud Computing and Infrastructure Optimalization. Follow Robert on Twitter @ClusterMVP Or follow his blog https://robertsmit.wordpress.com Linkedin Profile Http://nl.linkedin.com/in/robertsmit Robert is also capable of transferring his knowledge to others which is a rare feature in the field of IT. He makes a point of not only solving issues but also of giving on the job training of his colleagues. A customer says " Robert has been a big influence on our technical staff and I have to come to know him as a brilliant specialist concerning Microsoft Products. He was Capable with his in-depth knowledge of Microsoft products to troubleshoot problems and develop our infrastructure to a higher level. I would certainly hire him again in the future. " Details of the Recommendation: "I have been coordinating with Robert implementing a very complex system. Although he was primarily a Microsoft infrastructure specialist; he was able to understand and debug .Net based complext Windows applications and websites. His input to improve performance of applications proved very helpful for the success of our project

2 thoughts on “System Center 2016 VMM Place template VM in Custom OU #sysctr #Cloud #Deploy #VM”

  1. Thank you for this! However is it possible to allow it to use a variable? This seems to statically set it once but what if you wanted to change that value when actually deploying a VM template?

  2. when you deploy the VM with powershell then you must set the OU first before the deployment and you can do this in a variable but it’s not that flexible but how many OU’s are use for placement the deployed template in powershell is easy and fast.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: