Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2314

AD Attribute eintragen

$
0
0

Hallo, 

ich möchte mit Powershell folgendes json File einlesen: 

[
    {"OU":  "ABC","OUDN":  "OU=x,OU=x,DC=x,DC=x,DC=x"
    },
    {"OU":  "XYZ","OUDN":  "OU=x,OU=x,DC=x,DC=x,DC=x"
]

"OU" = Name einer AD Organizational Unit 

"OUDN" = der passende DistinguishedName zur OU 

Ich möchte überprüfen, ob das AD Attribut "description" dieser OUs "*Test*" enthält. Wenn nicht, möchte ich für dieses Attribut eintragen "Test_$OU". 

Ich weiß nur nicht, wie ich den OUs den richtigen DistinguishedName zuordne im Skript: 

$OUs = Get-Content -Raw -Path "C:\file.json" | Out-String | ConvertFrom-JSON
$OUDN= Get-Content -Raw -Path "C:\file.json" | Out-String |ConvertFrom-JSON


foreach ($OU in $OUs) {

   if (Get-ADOrganizationalUnit -Identity $OUDN -Filter {description -notlike "*TEST*"})
    {Set-ADObject $-Add @{description="TEST_$OU"}}
}

DANKE für eure Tipps und LG! 



Viewing all articles
Browse latest Browse all 2314


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>