198 lines
3.7 KiB
Markdown
198 lines
3.7 KiB
Markdown
![]() |
create default Groups
|
|||
|
|
|||
|
Mittwoch, 16. Januar 2019
|
|||
|
|
|||
|
16:00
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<https://www.hezser.de/blog/2015/04/30/create-the-default-groups-via-powershell/>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
\$web = Get-SPWeb <https://your.site.url>
|
|||
|
|
|||
|
if (\$web.AssociatedVisitorGroup -eq \$null) {
|
|||
|
|
|||
|
Write-Host \'The Visitor Group does not exist. It will be created\...\' -ForegroundColor DarkYellow
|
|||
|
|
|||
|
\$currentLogin = \$web.CurrentUser.LoginName
|
|||
|
|
|||
|
|
|||
|
|
|||
|
if (\$web.CurrentUser.IsSiteAdmin -eq \$false){
|
|||
|
|
|||
|
Write-Host (\'The user \'+\$currentLogin+\' needs to be a SiteCollection administrator, to create the default groups.\') -ForegroundColor Red
|
|||
|
|
|||
|
return
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
\$web.CreateDefaultAssociatedGroups(\$currentLogin, \$currentLogin, \[System.String\].Empty)
|
|||
|
|
|||
|
Write-Host \'The default Groups have been created.\' -ForegroundColor Green
|
|||
|
|
|||
|
} else {
|
|||
|
|
|||
|
Write-Host \'The Visitor Group already exists.\' -ForegroundColor Green
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
Aus \<<https://www.hezser.de/blog/2015/04/30/create-the-default-groups-via-powershell/>\>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
Auf uns angepasst :
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
\$web = get-spweb \$SiteCollURL
|
|||
|
|
|||
|
if (\$web.AssociatedVisitorGroup -eq \$null) {
|
|||
|
|
|||
|
Write-Host \'The Default Groups does not exist. It will be created\...\' -ForegroundColor DarkYellow
|
|||
|
|
|||
|
\$currentLogin = \$web.CurrentUser.LoginName
|
|||
|
|
|||
|
|
|||
|
|
|||
|
if (\$web.CurrentUser.IsSiteAdmin -eq \$false){
|
|||
|
|
|||
|
Write-Host (\'The user \'+\$currentLogin+\' needs to be a SiteCollection administrator, to create the default groups.\') -ForegroundColor Red
|
|||
|
|
|||
|
return
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
\$web.CreateDefaultAssociatedGroups(\$SiteOwner1,\$SiteOwner2, \[System.String\].Empty)
|
|||
|
|
|||
|
Write-Host \'The Default Groups have been created.\' -ForegroundColor Green
|
|||
|
|
|||
|
} else {
|
|||
|
|
|||
|
Write-Host \'The Default Groups already exists.\' -ForegroundColor Green
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
\$SPGroup = \$Site.SiteGroups\[\"S-C-B-5 Visitors\"\]
|
|||
|
|
|||
|
\$adgroup = \"bkk-mobiloil\\SG-SPT-SC-PTL-S-C-B-5-Besucher\"
|
|||
|
|
|||
|
\$sitecoll = <https://portal-spt.bkk-mobiloil.de/sites/scb5>
|
|||
|
|
|||
|
\$spfriendlyAdname = \$sitecoll \|Get-SPUser \|where {\$\_.name -like \$adgroup}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
Set-SPUser -Identity \$spfriendlyAdname -Web \$sitecoll -Group \$SPGroup
|
|||
|
|
|||
|
Ist schon im Script vorhanden :
|
|||
|
|
|||
|
\$url = \"scb6\"
|
|||
|
|
|||
|
\$Name = \"S-C-B-6\"
|
|||
|
|
|||
|
\$stage = \"SPT\"
|
|||
|
|
|||
|
\$SiteCollURL = \"<https://portal->\"+\$stage+\".bkk-mobiloil.de/sites/\$url\"
|
|||
|
|
|||
|
\$preName = \"SG-\"+\$stage+\"-SC-PTL-\"
|
|||
|
|
|||
|
\$postName = \"-Besitzer\"
|
|||
|
|
|||
|
\$SiteName = \"\$Name\"
|
|||
|
|
|||
|
\$adgroup1 = \$preName + \$sitename + \$postName
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
Muss neu :
|
|||
|
|
|||
|
\$sitecoll = Get-SPWeb \$SiteCollURL #Erzeugen des WebObjektes
|
|||
|
|
|||
|
|
|||
|
|
|||
|
\# Für Owners (Besitzer)
|
|||
|
|
|||
|
|
|||
|
|
|||
|
\$adgroup = \"bkk-mobiloil\\\"+\$adgroup1
|
|||
|
|
|||
|
\$sitecoll.EnsureUser(\$adgroup)
|
|||
|
|
|||
|
\$spfriendlyAdname = \$sitecoll \|Get-SPUser \|where {\$\_.name -like \$adgroup}
|
|||
|
|
|||
|
\$SPGroup = \$sitecoll.SiteGroups \|where {\$\_.Name -match \"\$name+ Owners\"}
|
|||
|
|
|||
|
Set-SPUser -Identity \$spfriendlyAdname -Web \$sitecoll -Group \$SPGroup
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
\# Für Visitors (Besucher)
|
|||
|
|
|||
|
|
|||
|
|
|||
|
\$adgroup = \"bkk-mobiloil\\\"+\$adgroup2
|
|||
|
|
|||
|
\$sitecoll.EnsureUser(\$adgroup)
|
|||
|
|
|||
|
\$spfriendlyAdname = \$sitecoll \|Get-SPUser \|where {\$\_.name -like \$adgroup}
|
|||
|
|
|||
|
\$SPGroup = \$sitecoll.SiteGroups \|where {\$\_.Name -match \"\$name+ Visitors\"}
|
|||
|
|
|||
|
Set-SPUser -Identity \$spfriendlyAdname -Web \$sitecoll -Group \$SPGroup
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#Für Members (Mitglieder
|
|||
|
|
|||
|
|
|||
|
|
|||
|
\$adgroup = \"bkk-mobiloil\\\"+\$adgroup3
|
|||
|
|
|||
|
\$sitecoll.EnsureUser(\$adgroup)
|
|||
|
|
|||
|
\$spfriendlyAdname = \$sitecoll \|Get-SPUser \|where {\$\_.name -like \$adgroup}
|
|||
|
|
|||
|
\$SPGroup = \$sitecoll.SiteGroups \|where {\$\_.Name -match \"\$name+ Members\"}
|
|||
|
|
|||
|
Set-SPUser -Identity \$spfriendlyAdname -Web \$sitecoll -Group \$SPGroup
|
|||
|
|
|||
|
|
|||
|
|
|||
|
\$sitecoll.EnsureUser(\$adgroup)
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
\$SPGroup = \$sitecoll.SiteGroups \|where {\$\_.Name -match \"\$name+ Visitors\"}
|