This project is read-only.

AD OU Deployment Targeting

Topics: Archive - General
Jul 22, 2014 at 4:41 PM
Edited Jul 22, 2014 at 4:44 PM
This has already been brought up in a previous post, but it was not the primary topic:

Previous Topic

So I wanted to start a new one to continue this topic without disrupting the other subject.

Lipid_Venom wrote:
We use a special AD OU for Machines that cannot have the "Interactive" installation and must go silently. At this time I am using 2 separate installations, would it be possible to add a query in this script, that if that machine resides in the AD OU to do the silent installation? Not all machines would have the AD Module running, but I did manage to find a way to fun it without.
$filter = "(&(objectCategory=computer)(objectClass=computer)(cn=$env:COMPUTERNAME))"
sintaxasn wrote:

Using the beta v4, I would suggest you implement as follows - modify the default Deploy-Application.ps1 template and just before the Variables: Environmnent section, add
$filter = "(&(objectCategory=computer)(objectClass=computer)(cn=$env:COMPUTERNAME))"
$dn = ([adsisearcher]$filter).FindOne().Properties.distinguishedname
If ($dn -match "<Insert your OU name here>") { $deployMode = "NonInteractive" )
This must be done before the main App Deploy Toolkit is dotSourced.

Hope this helps.

When attempting to run this, I receive the following errors:
Exception calling "FindOne" with "0" argument(s): "An operations error occurred.
At line:1 char:38
+$dn = ([adsisearcher]$filter).FindOne <<<< ().Properties.distinguishedname
+CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+FullyQualifiedErrorId : DotNetMethodException
Correct me if I’m wrong, but I’m quite sure the Filter for .FindOne was properly defined?
Jul 24, 2014 at 12:47 PM
Can you try with the following line change?
$filter = "(&(objectCategory=computer)(objectClass=computer)(cn=$($env:COMPUTERNAME)))"
I suspect using the ComputerName variable needs to be encapsulated
Jul 24, 2014 at 6:40 PM
Excellent! That was indeed the fix, however, this does not seem to be working as I have tested it on multiple machines with a simple test Application - the new release of Java. I followed your advise on the line placement and it is as follows.
# Variables: Script - Do not modify this section

$deployAppScriptFriendlyName = "Deploy Application"
$deployAppScriptVersion = [version]"3.1.4"
$deployAppScriptDate = "06/10/2014"
$deployAppScriptParameters = $psBoundParameters

#Variables: Critical OU
$filter = "(&(objectCategory=computer)(objectClass=computer)(cn=$($env:COMPUTERNAME)))"
$dn = ([adsisearcher]$filter).FindOne().Properties.distinguishedname
If ($dn -match "CN=$env:COMPUTERNAME,OU=Critical,OU=-Devices,DC=###,DC=###,DC=com") { $deployMode -eq "Silent" }

# Variables: Environment
$scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Definition
# Dot source the App Deploy Toolkit Functions
It is still installing as Interactive on the machines that I have verified as in that particular OU. Below is what I've copied from the Install.log
[24-07-2014 10:55:47] [Initialization] Oracle_Java_7.0.650_EN_01 setup started.
[24-07-2014 10:55:47] [Initialization] Script [C:\Windows\ccmcache\21\AppDeployToolkit\AppDeployToolkitExtensions.ps1] dot-source invoked by [C:\Windows\ccmcache\21\AppDeployToolkit\AppDeployToolkitMain.ps1]
[24-07-2014 10:55:47] [Initialization] Script [C:\Windows\ccmcache\21\AppDeployToolkit\AppDeployToolkitMain.ps1] dot-source invoked by [C:\Windows\ccmcache\21\Deploy-Application.ps1]
[24-07-2014 10:55:47] [Initialization] Oracle_Java_7.0.650_EN_01 script version is [1.0.0]
[24-07-2014 10:55:47] [Initialization] Deploy Application script version is [3.1.4]
[24-07-2014 10:55:47] [Initialization] The following non-default parameters were passed to [Deploy Application]: [-DeploymentType Install]
[24-07-2014 10:55:47] [Initialization] App Deploy Toolkit Main script version is [3.1.4]
[24-07-2014 10:55:47] [Initialization] App Deploy Toolkit Extensions version is [1.0.0]
[24-07-2014 10:55:47] [Initialization] PowerShell version is [2.0 x64]
[24-07-2014 10:55:47] [Initialization] PowerShell host is [ConsoleHost version 2.0]
[24-07-2014 10:55:48] [Initialization] OS version is [Microsoft Windows 7 Enterprise  64-bit 6.1.7601]
[24-07-2014 10:55:48] [Initialization] Hardware platform is [Physical]
[24-07-2014 10:55:48] [Initialization] Computer name is [###]
[24-07-2014 10:55:48] [Initialization] Current user is [###\###$]
[24-07-2014 10:55:48] [Initialization] Current Culture is [en-US] and UI language is [EN]
[24-07-2014 10:55:48] [Initialization] Deployment type is [Installation]
[24-07-2014 10:55:48] [Initialization] Installation is running in [Interactive] mode.
Aug 19, 2014 at 4:52 PM
I've tabled this issue, but am circling back around, as I dive back into it. Is this part
Param (
    [string] $DeploymentType = "Install",
    [string] $DeployMode = "Interactive",
    [switch] $AllowRebootPassThru = $true,
    [switch] $TerminalServerMode = $false
Trumping this? Even though it is placed before the .Source
If ($dn -match "CN=$env:COMPUTERNAME,OU=Critical,OU=-Devices,DC=###,DC=###,DC=com") { $deployMode -eq "Silent" }
Is it possible that I need to put [string] in front of it? I know I am overlooking something that is preventing this from working and I assume it must be small.
Aug 19, 2014 at 7:11 PM
Nope it's not trumping it, "-eq" is for testing if a value is equal and "=" is for assigning a value, so your line above should be $deployMode = "Silent"