AD OU Deployment Targeting

Topics: Archive - General
Jul 22, 2014 at 3:41 PM
Edited Jul 22, 2014 at 3: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))"
([adsisearcher]$filter).FindOne().Properties.distinguishedname
sintaxasn wrote:
Liquid_Venom,

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.

Dan
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?
Coordinator
Jul 24, 2014 at 11:47 AM
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 5: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
."$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
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 3:52 PM
I've tabled this issue, but am circling back around, as I dive back into it. Is this part
Param (
    [ValidateSet("Install","Uninstall")] 
    [string] $DeploymentType = "Install",
    [ValidateSet("Interactive","Silent","NonInteractive")]
    [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.
Coordinator
Aug 19, 2014 at 6: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"