Question Aide pour script

Plus d'informations
il y a 4 ans 5 mois #29388 par Laurent Dardenne
Réponse de Laurent Dardenne sur le sujet Re:Aide pour script
Et changer aussi ceci :
[code:1]
$OU = GetComputerOU

if ((gwmi win32_operatingsystem | select osarchitecture).osarchitecture -eq \"64 bits\"«»)
{
msiexec /i \\test.local\netlogon\BOMGAR-Client\bomgar-scc-win64.msi KEY_INFO=$Association
[/code:1]
en
[code:1]
...
msiexec /i \\test.local\netlogon\BOMGAR-Client\bomgar-scc-win64.msi KEY_INFO=$Association.$OU
[/code:1]

Tutoriels PowerShell

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 5 mois #29414 par David
Réponse de David sur le sujet Re:Aide pour script
Bonjour à tous,

Merci de vos réponses.

Je suis resté bloqué sur ce problème et n'arrivant pas à utiliser vos retours, je suis passé à une solution avec un niveau de finition moins fin.

C'est à dire que avant j'utilisais la dernière OU de ma structure AD.

Je simplifie la chose en essayant de trouver comment remonter 2 niveaux au dessus. Je m'explique :

Avant j'utilisais l'encadré en rouge, je suis remonté à l'OU encadrée en vert.
Mais je bute encore

Fichier attaché :



Voici le script modifié :

[code:1]function GetComputerOU
{
$SysInfo = New-Object -ComObject \"ADSystemInfo\"
$Computer = [ADSI](\"LDAP://{0}\" -f $SysInfo.GetType().InvokeMember(\"ComputerName\", [System.Reflection.BindingFlags]::GetProperty, $null, $SysInfo, $null))
return ([ADSI]$Computer.Parent).OU
}

$OU = GetComputerOU

if ((gwmi win32_operatingsystem | select osarchitecture).osarchitecture -eq \"64 bits\"«»){
if ($OU -eq \"XXXX\"«»){
msiexec /i \\test.local\netlogon\BOMGAR-Client\bomgar-scc-win64.msi KEY_INFO=123456
}
elseif ($OU -eq \"XXXX\"«»){
msiexec /i \\test.local\netlogon\BOMGAR-Client\bomgar-scc-win64.msi KEY_INFO=123457
}
else{
msiexec /i \\test.local\netlogon\BOMGAR-Client\bomgar-scc-win64.msi KEY_INFO=123458
}
}

else{
if ($OU -eq \"XXXX\"«»){
msiexec /i \\test.local\netlogon\BOMGAR-Client\bomgar-scc-win32.msi KEY_INFO=123456
}
elseif ($OU -eq \"XXXX\"«»){
msiexec /i \\test.local\netlogon\BOMGAR-Client\bomgar-scc-win32.msi KEY_INFO=123457
}
else{
msiexec /i \\test.local\netlogon\BOMGAR-Client\bomgar-scc-win32.msi KEY_INFO=123458
}
}
}[/code:1]

Du coup il me retourne le nom de L'OU en rouge et n'attribue pas correctement la clé
Une idée ?

Merci d'avance
DAvid

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 5 mois #29444 par David
Réponse de David sur le sujet Aide pour script
Voici ma réponse qui fonctionne chez moi (trouvée par un collègue):

[code:1]
$Association = @{
'Nancy' = '123456789'
'Metz' = '987654321'
'Troyes' = '147258369'
'Default' = '369258147'
}

function GetComputerOU
{
$SysInfo = New-Object -ComObject \"ADSystemInfo\"
$Computer = [ADSI](\"LDAP://{0}\" -f $SysInfo.GetType().InvokeMember(\"ComputerName\", [System.Reflection.BindingFlags]::GetProperty, $null, $SysInfo, $null))
$temp = ([ADSI]$Computer.Parent)
while (($temp.OU -ne \"Nancy\"«») -and ($temp.OU -ne \"Metz\"«») -and ($temp.OU -ne \"Troyes\"«») -and ($temp.OU -ne $null)) {
$temp = ([ADSI]$temp.Parent)
}
if($temp.OU -eq $null) {
return \"Default\"
}else {
return $temp.OU
}
}

$OU = GetComputerOU

if (!(Get-Service | Where-Object {$_.DisplayName -like \"Beyond*\"})) {
if ((gwmi win32_operatingsystem | select osarchitecture).osarchitecture -eq \"64 bits\"«»)
{
msiexec /i \\test.local\netlogon\BOMGAR-Client\bomgar-scc-win64.msi KEY_INFO=$($Association.$OU)
}
else
{
msiexec /i \\test.local\netlogon\BOMGAR-Client\bomgar-scc-win32.msi KEY_INFO=$($Association.$OU)
}
}
[/code:1]

Des fois que ça puisse aider quelqu'un !
Merci en tout cas pour vos réponses et votre aide
Bon week end
Goro

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.066 secondes
Propulsé par Kunena