I need help here with powershell, as im not that good in, im only starting, but i need already to make a powershell script but will run thru all collaborative spaces and modify 4 groups by setting different group owners.
Here is what i have:
function RetrieveSites()
{
$cs = Get-CsWebAppUrl
Get-SPSite -WebApplication $cs -Limit All | % {
Write-host "Retrieving $($Site.Url)"
ModifyGroupOwners -Site $_
}
}
function ModifyGroupOwners([Microsoft.SharePoint.SPSite] $Site)
{
$spgroup = Get-SPGroup -Site $site -Limit All | % {
if((spgroup.name -eq "Approver") -or ($spgroup.name -eq "Designer") -or ($spgroup.name -eq "Hierarchy Managers") -or ($spgroup.name -eq "Style Resource Readers") -or ($spgroup.name -eq "Restricted readers"))
{
$owner=$spgroup.name + " Managers"
$spgroup.owner=$spgroup[$owner]
$spgroup.update
Write-host "$($spgroup.name) was updated"
}
}
}
function Get-CsWebAppUrl()
{
$Farm = (Get-SPFarm)
$CsWebAppUrl = $farm.Properties[$global:CsKey]
if ([string]::IsNullOrEmpty($CsWebAppUrl))
{
write-error "Unable to find group Url, please check the portal map configuration"
exit 1
}
return $CsWebAppUrl
}
So the big problem is for retrieving the groups and modifying them, i wrote some ps code but im not sure and i want to have some help and guidance.
Thanks alot for help in advance.