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

Hilfe run DSAdd group command mit Powershell

$
0
0

Hallo zusammen,

ich brauche mal eine Idee oder besser Lösung. Ich habe mir eine Funktion geschrieben die auch generell funktioniert mit 

New-QADGroup -name "$($loc.name)_All_Users" -SamAccountName "$($loc.name)_All_Users" -grouptype "Security" -GroupScope Universal -Description "C IN WP BB - AD - Updated $($timestamp) - collects all enabled User for $($loc.name)" -ParentContainer "OU=Services,OU=Groups,$Loc"

dies ist in meinem Enviroment aber zulangsam zumindestens für die spätere User maintance. ist nur ein beispiel hier der Inhalt aus einer Funktion die ich mir nun mit DSADD geändert habe.. dies funktioniert aber irgendwie nicht ganz.

Function CreateGroupLocation { Write-Host "proceed Group Maintaining $(DomName)" $Loc -ForegroundColor yellow -BackgroundColor DarkRed $MOBIrionGroup = Get-QADGroup -SamAccountName "$($loc.name)_All_Users" -SearchRoot "OU=Services,OU=Groups,$Loc" -SearchScope Subtree Write-Host $MOBIrionGroup if (!$MOBIrionGroup){ Write-Host "not exist will created now ", "$($loc.name)_All_Users" -ForegroundColor Blue -BackgroundColor DarkGray

#New-QADGroup -ParentContainer "OU=Services,OU=Groups,$Loc" -name "$($loc.name)_All_Users" -SamAccountName "$($loc.name)_All_Users" -grouptype "Security" -GroupScope Universal -Description "C IN WP BB - AD - automatic maintained - daily - collects all enabled User for $($loc.name)"

$EXEFile = "c:\Windows\System32\dsadd.exe group" $Cline1 = """OU=Services,OU=Groups,$Loc""" $CLine2 = "-scope U -secgrp yes -Desc ""C IN WP BB - AD - automatic maintained - daily - collects all enabled User for $($loc.name)""" Write-Host ($EXEFile, $CLine1, $CLine2) Invoke-expression "$EXEFile $Cline1 $CLine2" #Invoke-Command -ScriptBlock { # dsadd group "OU=Services,OU=Groups,$($Loc)" -samID $loc.name_All_Users -scope U -secgrp yes -Description "C IN WP BB - AD - automatic maintained - daily - collects all enabled User for $($loc.name)" #} } else{ Write-Host "$($loc.name)_All_Users exist allready " -ForegroundColor yellow -BackgroundColor DarkGreen #Start-Sleep -Seconds 5 } }

die anzeige mit write-host ist soweit ok und eigentlich sollte das doch auch so in invoke-expression ausgefürhrt werden oder bin ich da auf dem Holzweg?

DOM1\bdp1_All_Users
bdp1_All_Users exist allready 
OU=bln3,OU=de,OU=lda,DC=DOM1,DC=contoso,DC=com

proceed Group Maintaining  OU=bln3,OU=de,OU=lda,DC=DOM1,DC=contoso,DC=com

not exist will created now  bln3_All_Users
c:\Windows\System32\dsadd.exe group "OU=Services,OU=Groups,OU=bln3,OU=de,OU=lda,DC=DOM1,DC=contoso,DC=com" -scope U -secgrp yes -Desc "C IN WP BB - AD - automatic maintained - daily - collects all enabled User for bln3"

OU=bry1,OU=us,OU=lda,DC=DOM1,DC=contoso,DC=com

proceed Group Maintaining  OU=bry1,OU=us,OU=lda,DC=DOM1,DC=contoso,DC=com
DOM1\bry1_All_Users
bry1_All_Users exist allready 
OU=cgu1,OU=cn,OU=lda,DC=DOM1,DC=contoso,DC=com

kann mir da jemand einen Tip geben oder sagen was ich da falsch mache?

danke Michael


Michael


Viewing all articles
Browse latest Browse all 2314


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