<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Muthu's blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/muthus_blog/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/muthus_blog/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 04:10:42 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Simplifying WinRM pre-requisites in Azure VMs as part of Release and Build workflows</title>
      <link>https://docs.microsoft.com/archive/blogs/muthus_blog/simplifying-winrm-pre-requisites-in-azure-vms-as-part-of-release-and-build-workflows</link>
      <pubDate>Thu, 24 Mar 2016 12:51:03 GMT</pubDate>
      <dc:creator><![CDATA[Muthukumaran [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/muthus_blog/?p=43</guid>
      <description><![CDATA[Deployment to Azure IaaS VM as part of Release and Build workflow is possible using "Azure Resource...]]></description>
      <content:encoded><![CDATA[Deployment to Azure IaaS VM as part of Release and Build workflow is possible using "Azure Resource Group Deployment" for dynamically provisioning and with "Azure File Copy", "PowerShell on Target Machines" tasks for copy and remote script execution. "Azure File Copy" and "PowerShell on Target Machines" tasks depend on PowerShell WinRM remoting to meet the deployment needs. This brings in requirement for target Azure VM to have all required WinRM pre-requisites to be in place before the deployment.

<strong>Simplified Configuration</strong>

In my previous <a href="https://blogs.msdn.microsoft.com/muthus_blog/2015/11/04/pre-requisites-for-using-azure-vms-in-winrm-based-tasks-in-build-and-release-management-workflows/">post</a>, I called out how a user can manually configure WinRM pre-requisites in Azure VM to make it ready for Build and Release workflows. Latest "Azure Resource Group Deployment" task and "Azure File Copy" task has simplified this experience and have eliminated the need for user to make such configurations manually.

In "Azure Resource Group Deployment" task user can take advantage of the option "Enable Deployment Prerequisites". This now allows user to create resource groups out of any CSM template and still enable WinRM configuration as part of Build and Release workflows to meet their deployment needs.

<a href="https://msdnshared.blob.core.windows.net/media/2016/03/ARGEnablePrerequisites.png"><img class="alignnone size-medium wp-image-53" src="https://msdnshared.blob.core.windows.net/media/2016/03/ARGEnablePrerequisites-300x224.png" alt="ARGEnablePrerequisites" width="300" height="224" /></a>

If you are interested in a CSM template that does WinRM by default you can refer this <a href="https://github.com/Azure/azure-quickstart-templates/tree/master/undefined">quick start template</a>.

Azure file copy task exposes this capability as "Enable Copy Prerequisites" option. User can either copy to dynamically created resource group or to a pre-created resource group that user created via portal. In both cases Azure file copy task will enable WinRM configuration if the configuration is not already enabled in target VM.

<a href="https://msdnshared.blob.core.windows.net/media/2016/03/AFCEnablePrerequisites.png"><img class="alignnone size-medium wp-image-63" src="https://msdnshared.blob.core.windows.net/media/2016/03/AFCEnablePrerequisites-300x211.png" alt="AFCEnablePrerequisites" width="300" height="211" /></a>

&nbsp;

<strong>What happens behind the scenes</strong>

When this option is enabled, internally the Task makes use of Azure Custom script extension to prepare the VMs ready for WinRM configuration. Here is a snip from Azure portal for a VM created using above task. The custom script used for execution is available in <a href="https://github.com/Azure/azure-quickstart-templates/blob/master/201-vm-winrm-windows/ConfigureWinRM.ps1">github</a>.

<a href="https://msdnshared.blob.core.windows.net/media/2016/03/IbizaCustomExtension.png"><img class="alignnone size-medium wp-image-71" src="https://msdnshared.blob.core.windows.net/media/2016/03/IbizaCustomExtension-300x198.png" alt="IbizaCustomExtension" width="300" height="198" /></a>

The custom script extension does following:

a) Prepare the VM internally
<ul>
	<li>Removes if there is any existing WinRM listener for HTTPS.</li>
	<li>Creates a self-signed certificate</li>
	<li>Creates the WinRM HTTPS listener with above self-signed certificate</li>
	<li>Configure firewall</li>
</ul>
Since the certificate is self-signed certificate, user should use the "Test certificate" option in the "Azure file copy" and "PowerShell on target machine" tasks.

<a href="https://msdnshared.blob.core.windows.net/media/2016/03/EnableTestCertificate1.png"><img class="alignnone size-medium wp-image-73" src="https://msdnshared.blob.core.windows.net/media/2016/03/EnableTestCertificate1-300x95.png" alt="EnableTestCertificate" width="300" height="95" /></a>

b) Prepare the Resource group

The task in addition to executing above custom script extension updates Network security group if present in user's resource group.  It adds Inbound security rule to allow TCP/5986 for WinRM inbound connections.

This should significantly reduce the complexity involved in preparing VMs ready for Build and release workflows.

<strong>Few points to note:</strong>

The option configures "self-signed" certificate and removes if there are any existing WinRM HTTPS listener. This should meet most of the dev/test deployment needs but may not in few cases. Use it appropriately.

Few gaps:
<ul>
	<li>Azure today does not allow more than one custom script extension for a given VM. Hence if user has already taken advantage of this, the Task will not be able to add its own script extension.</li>
	<li>If the resource group has Load balancer, then the Task will not be able to configure appropriate In bound rules. User will have to configure the same.</li>
	<li>If Azure VM has remote UAC enabled, then this would still prevent remote PowerShell execution during deployment. The custom script extension does not disable the remote UAC. User will have to modify the same.</li>
</ul>
&nbsp;

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Managing AzureRM module versions for Build and Release Management workflows</title>
      <link>https://docs.microsoft.com/archive/blogs/muthus_blog/managing-azurerm-module-versions-for-build-and-release-management-workflows</link>
      <pubDate>Mon, 16 Nov 2015 20:30:00 GMT</pubDate>
      <dc:creator><![CDATA[Muthukumaran [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/muthus_blog/2015/11/16/managing-azurerm-module-versions-for-build-and-release-management-workflows/</guid>
      <description><![CDATA[Azure Resource group deployment task&nbsp;and Azure File Copy task&nbsp;that are part of Build and...]]></description>
      <content:encoded><![CDATA[<p><a href="https://github.com/Microsoft/vso-agent-tasks/tree/master/Tasks/DeployAzureResourceGroup">Azure Resource group deployment task</a>&nbsp;and <a href="https://github.com/Microsoft/vso-agent-tasks/tree/master/Tasks/AzureFileCopy">Azure File Copy task</a>&nbsp;that are part of Build and Release Management workflow task catalogue take dependency on Azure RM&nbsp;modules&nbsp;and the command-lets. Azure has&nbsp;started publishing the Azure modules at a more faster cadence through <a href="https://www.powershellgallery.com/packages/AzureRM/">PowerShell gallery</a>. Hence there can be instances when you would need your Build or Release automation agent to have specific version of Azure RM modules to meet your needs or to maintain compat with the Azure resource group and Azure file copy tasks. If you need a specific version of module then follow below steps&nbsp;to install right version of the module in your Build or Release Automation agent. The best way to find out supported Azure RM module version for these Azure tasks is to look at their ReadMe in github. You can also reach out to <a href="mailto:RM_Customer_Queries@Microsoft.com">RM_Customer_Queries@Microsoft.com</a></p>
<p>&nbsp;</p>
<p>Pre-requisite:</p>
<p>I am assuming you have the PowerShellGet Module installed in your automation agent. If not follow the instructions in <a href="https://www.powershellgallery.com/">PowerShellGallery</a> page to install the module. This provides the Install-module command-let that you would need to install AzureRM.</p>
<p>&nbsp;</p>
<p>a) To check/verify the version of AzureRM module that is present in your machine</p>
<p>Get-Module -Name AzureRM -ListAvailable</p>
<p>&nbsp;</p>
<p>b) To install a specific module execute below commands</p>
<p>Install-Module -Name AzureRM -RequiredVersion &lt;ver&gt;. You can find the versions available from <a href="https://www.powershellgallery.com/packages/AzureRM/">PowerShell gallery</a>&nbsp;page.</p>
<p>Install-AzureRM</p>
<p>Refer <a href="https://msdn.microsoft.com/en-us/library/mt125356.aspx">MSDN</a> for more details on the command.</p>
<p>&nbsp;</p>
<p>c) To uninstall existing versions execute below commands</p>
<p>Uninstall-AzureRM</p>
<p>Uninstall-Module -Name AzureRM</p>
<p>Post uninstall you should not have any modules present in the modules install path. This is typically in C:\Program Files\WindowsPowerShell\Modules. But you can find the actual path in your machine using Get-Module command.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Pre-requisites for using Azure VMs in WinRM based Tasks in Build and Release management workflows</title>
      <link>https://docs.microsoft.com/archive/blogs/muthus_blog/pre-requisites-for-using-azure-vms-in-winrm-based-tasks-in-build-and-release-management-workflows</link>
      <pubDate>Wed, 04 Nov 2015 04:14:00 GMT</pubDate>
      <dc:creator><![CDATA[Muthukumaran [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/muthus_blog/2015/11/04/pre-requisites-for-using-azure-vms-in-winrm-based-tasks-in-build-and-release-management-workflows/</guid>
      <description><![CDATA[Azure VM pre-requisites

&nbsp;

If you are using a pre-provisioned Azure machine as part of...]]></description>
      <content:encoded><![CDATA[<div>
<h2>Azure VM pre-requisites</h2>
</div>
&nbsp;

If you are using a pre-provisioned Azure machine as part of Build or Release Management workflow and if you would like to use workflow Tasks that are based on WinRM remote PowerShell for deployment (Example – <a href="https://github.com/Microsoft/vso-agent-tasks/tree/master/Tasks/PowerShellOnTargetMachines">PowerShell on Target machines</a>, <a href="https://github.com/Microsoft/vso-agent-tasks/tree/master/Tasks/WindowsMachineFileCopy">Windows File Copy</a>) ensure all your pre-requisites in Azure VM is in place before using it for deployment.

NOTE: If you would like WinRM configurations to be automatically handled by Task, then refer to the <a href="https://blogs.msdn.microsoft.com/muthus_blog/2016/03/24/simplifying-winrm-pre-requisites-in-azure-vms-as-part-of-release-and-build-workflows/">post</a>.

<strong><em>a)    </em></strong><strong><em>Ensure you have WinRM firewall ports opened for your resource group</em></strong>

In Azure portal you should create an inbound security rule to allow TCP/5986 for WinRM.

<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/68/33/0312.WinrmSecurityRule.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/68/33/0312.WinrmSecurityRule.png" alt="" border="0" /></a>

&nbsp;

<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/68/33/3660.WinrmSecurityStep.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/68/33/3660.WinrmSecurityStep.png" alt="" border="0" /></a>

&nbsp;

<strong><em>b)    </em></strong><strong><em>Ensure you have WinRM listener configured for https</em></strong>
<ul>
	<li>From within Azure VM run below command to check if you have winrm listener for HTTPS.</li>
</ul>
<p style="padding-left: 60px">‘WinRM e winrm/config/listener’</p>
&nbsp;
<ul>
	<li>If winrm listener is not already configured, configure winrm for HTTPS</li>
</ul>
<p style="padding-left: 60px"><em>winrm create winrm/config/Listener?Address=*+Transport=HTTPS  @{Hostname="<strong>&lt;*.westus.cloudapp.azure.com&gt;</strong>";CertificateThumbprint="<strong>&lt;thumbprint&gt;</strong>"}</em></p>
<p style="padding-left: 60px">You can create a self-signed certificate (using makecert.exe) for server authentication and use it.</p>
<p style="padding-left: 60px">Example:</p>
<p style="padding-left: 60px"><em>makecert -sk "</em><em>mydomain.com</em><em>" -ss My -sr localMachine -r -n "CN=</em><em>mydomain.com</em><em>" -a sha1 -eku "1.3.6.1.5.5.7.3.1"</em></p>
&nbsp;
<ul>
	<li>Verify if winrm lister is proper</li>
</ul>
<p style="padding-left: 60px">‘WinRM e winrm/config/listener’</p>
&nbsp;

<strong><em>c)     </em></strong><strong><em>Ensure your Azure VM is not in public network location. </em></strong>

PowerShell Remoting has limitation on working with machines in public network location. Refer this <a href="https://blogs.msdn.com/b/powershell/archive/2009/04/03/setting-network-location-to-private.aspx.">blog</a> for details.

You can verify and change the network location using secpol.msc. Refer <a href="https://www.online-tech-tips.com/windows-8/change-from-public-to-private-network-in-windows-8/">this</a> for guidance.
<div>
<h2>Verification</h2>
</div>
&nbsp;

A quick way to verify if the PS remoting is proper before you start using the machine in workflow is to execute below script. It is preferable to try this from the automation agent box to eliminate any possible failures during execution.

$soptions = New-PSSessionOption -SkipCACheck

$cred = Get-Credential

$computername = &lt;EnterComputerName&gt;

$computerport = &lt;EnterPort&gt;

Enter-PSSession -ComputerName $computername -Port $computerport -Credential $cred -SessionOption $soptions -UseSSL

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Manage Lab management permission through scripts</title>
      <link>https://docs.microsoft.com/archive/blogs/muthus_blog/manage-lab-management-permission-through-scripts</link>
      <pubDate>Fri, 14 Nov 2014 02:24:00 GMT</pubDate>
      <dc:creator><![CDATA[Muthukumaran [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/muthus_blog/2014/11/14/manage-lab-management-permission-through-scripts/</guid>
      <description><![CDATA[Lab Management has TfsLabConfig.exe command with which the Lab permissions can be managed. At times,...]]></description>
      <content:encoded><![CDATA[<p>Lab Management has TfsLabConfig.exe command with which the Lab permissions can be managed. At times, there might be need for script to iterate through objects and set permissions. In the following blog, I would like to share how we can make use of Lab Management client and author PowerShell script for accomplishing the same. This script should be run as collection admin if you would like to manage permissions at collection level. The script should be run from a machine with VS 2012&nbsp;where the TFS and Lab client dlls are available.</p>
<p>Please note that, using TfsLabConfig.exe would still be the recommended way, wherever possible.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>#######################################################################################<br />#/// &lt;Valid permissions that can be set&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Permission to query properties or status of Lab Management artifacts<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Read = 1,<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Permission to import virtual machine images into Lab Management<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Create = 2,<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Permission to create new Lab Management artifacts eg. creating LabEnvironment or creating LabTemplate from LabSystem.<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Write = 4,<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Permission to update properties of existing Lab Management artifacts<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Edit = 8,<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Permission to delete existing Lab Management artifacts<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Delete = 16,<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Permission to start machines<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start = 32,<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Permission to stop machines<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Stop = 64,<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Permission to pause machines<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Pause = 128,<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Permission to create, apply and delete virtual machine snapshots <br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ManageSnapshots = 256,<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Permissions to create, query or change properties of Lab Locations<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;remarks&gt;Lab Locations are places that contain virtual machines, such as Host Groups and Library Shares&lt;/remarks&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ManageLocation = 512,<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Permission to delete Lab Locations<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DeleteLocation = 1024,<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Permission to change permissions on any Lab Management artifact<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ManagePermissions = 2048,<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Permission to change permissions on children (in security hierarchy) of any Lab Management artifact<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ManageChildPermissions = 4096,<br />#<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ManageTestMachines = 8192<br />###########################################################################</p>
<p>#Function to deny permission for a user on an object<br />function Deny-LabPermissions <br />{<br />&nbsp;&nbsp;&nbsp; param (<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Parameter(Mandatory = $true)]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $objecturi, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Parameter(Mandatory = $true)]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $useridentity, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Parameter(Mandatory = $true)]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $labinheritancechange,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Parameter(Mandatory = $true)]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $denymask<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )</p>
<p>&nbsp;&nbsp;&nbsp; process<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $permlist = New-Object System.Collections.Generic.List``1[Microsoft.TeamFoundation.Lab.Client.LabPermissionChange];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $labpermissionchange = New-Object Microsoft.TeamFoundation.Lab.Client.LabPermissionChange;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $labpermissionchange.Denymask = $denymask; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $labpermissionchange.IdentityName = $useridentity;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $permlist.Add($labpermissionchange);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $labsecuritydesc = New-Object Microsoft.TeamFoundation.Lab.Client.LabSecurityDescriptor;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $labsecuritydesc.LabInheritanceChange = $labinheritancechange;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $labsecuritydesc.LabPermissionChanges = $permlist;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $labService.UpdateObjectSecurity($labsecuritydesc, $objecturi);<br />&nbsp;&nbsp;&nbsp; }<br />}</p>
<p>#Function to allow permission for a user on an object<br />function Allow-LabPermissions <br />{<br />&nbsp;&nbsp;&nbsp; param (<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Parameter(Mandatory = $true)]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $objecturi, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Parameter(Mandatory = $true)]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $useridentity, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Parameter(Mandatory = $true)]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $labinheritancechange,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Parameter(Mandatory = $true)]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $allowmask<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )</p>
<p>&nbsp;&nbsp;&nbsp; process<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $permlist = New-Object System.Collections.Generic.List``1[Microsoft.TeamFoundation.Lab.Client.LabPermissionChange];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $labpermissionchange = New-Object Microsoft.TeamFoundation.Lab.Client.LabPermissionChange;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $labpermissionchange.Allowmask = $allowmask; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $labpermissionchange.IdentityName = $useridentity;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $permlist.Add($labpermissionchange);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $labsecuritydesc = New-Object Microsoft.TeamFoundation.Lab.Client.LabSecurityDescriptor;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $labsecuritydesc.LabInheritanceChange = $labinheritancechange;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $labsecuritydesc.LabPermissionChanges = $permlist;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $labService.UpdateObjectSecurity($labsecuritydesc, $objecturi);<br />&nbsp;&nbsp;&nbsp; }<br />}</p>
<p>&nbsp;</p>
<p># Specify the tfs collection url, projectName and test controllerName <br />$tfsCollectionUrl = New-Object System.URI("<a href="https://vstlm-at1:8080/tfs/defaultcollection">&lt;collectionURL</a>&gt;"); <br />$projectName = "&lt;ProjectName&gt;";</p>
<p># Load Client Assembly <br />[Reflection.Assembly]::Load(&ldquo;Microsoft.TeamFoundation.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&rdquo;); <br />[Reflection.Assembly]::Load(&ldquo;Microsoft.TeamFoundation.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&rdquo;); <br />[Reflection.Assembly]::Load(&ldquo;Microsoft.TeamFoundation.Lab.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&rdquo;); <br />[Reflection.Assembly]::Load(&ldquo;Microsoft.TeamFoundation.Lab.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&rdquo;); <br />&nbsp; <br /># Connect to tfs <br />$tfsCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($tfsCollectionUrl); <br />$labService = $tfsCollection.GetService([Microsoft.TeamFoundation.Lab.Client.LabService]);</p>
<p>#To find valid permission for each object type. Not all objects have all permission types.<br />$labService.GetValidPermissionsForObject([Microsoft.TeamFoundation.Lab.Client.TeamProjectCollectionHostGroup]);<br />$labService.GetValidPermissionsForObject([Microsoft.TeamFoundation.Lab.Client.TeamProjectCollectionLibraryShare]);<br />$labService.GetValidPermissionsForObject([Microsoft.TeamFoundation.Lab.Client.TeamProjectHostGroup]);<br />$labService.GetValidPermissionsForObject([Microsoft.TeamFoundation.Lab.Client.TeamProjectLibraryShare]);</p>
<p>#you can also specify TFS groups - $identitylist.Add("[DefaultCollection]\Project Collection Administrators");<br />$useridentity = "&lt;domain\user&gt;;<br />$identitylist = New-Object System.Collections.Generic.List``1[String];<br />$identitylist.Add($useridentity);</p>
<p>#A sample to list and modify permissions for user(s) on Host group<br />$hglist = New-Object System.Collections.Generic.List``1[String];<br />$hglist.Add("All Hosts"); #Sample Host group name<br />$hglist.Add("All Hosts_HG1"); #Sample Host group name<br />$hgsecurity = $null;<br />$hglist |&nbsp; ForEach-Object -Process {<br />&nbsp;&nbsp;&nbsp; #Find the corresponding URI<br />&nbsp;&nbsp;&nbsp; $tpchgqueryspec = New-Object Microsoft.TeamFoundation.Lab.Client.TeamProjectCollectionHostGroupQuerySpec;<br />&nbsp;&nbsp;&nbsp; $tpchgqueryspec.Name = $_;<br />&nbsp;&nbsp;&nbsp; $hg = $labService.QueryTeamProjectCollectionHostGroups($tpchgqueryspec);<br />&nbsp;&nbsp;&nbsp; $hguri = $hg[0].Uri.AbsoluteUri;</p>
<p>&nbsp;&nbsp;&nbsp; #List Current permission<br />&nbsp;&nbsp;&nbsp; $hgsecurity = $labService.GetObjectSecurity($identitylist, $hguri);<br />&nbsp;&nbsp;&nbsp; $hgsecurity;</p>
<p>&nbsp;&nbsp;&nbsp; #Update permission<br />&nbsp;&nbsp;&nbsp; $allowmask = 2048; # Manage permissions. Refer list above.<br />&nbsp;&nbsp;&nbsp; $denymask = 1023; # delete location. Refer list above.</p>
<p>&nbsp;&nbsp;&nbsp; "Changing permission for " + $useridentity + " on object " + $hguri;<br />&nbsp;&nbsp;&nbsp; Allow-LabPermissions -objecturi $hguri -useridentity $useridentity -labinheritancechange $true -allowmask $allowmask;<br />&nbsp;&nbsp;&nbsp; Deny-LabPermissions -objecturi $hguri -useridentity $useridentity -labinheritancechange $true -denymask $denymask;&nbsp;&nbsp;&nbsp; <br />}</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
  </channel>
</rss>