Thursday, 14 July 2016

7 to C Local Groups Creator

Sometimes one has to ignore transitioning local users and groups when doing a 7MTT assisted 7 to C transition, using the ignore-local-users-groups-transition 7MTT CLI switch, but there might still be some requirement for local users and groups.

In this following scenario, we’re only interested in the domain members of essentially the built-in local groups on the 7-Mode system, and we’re provided with a list of SIDs to Domain User/Group*, as lines of -

SID;DOMAIN\USERorGROUP

- and we also have the lug.txt file that was generated by 7MTT.

*Don’t have domain access, but would be quite simple to add SID translation to the script.

The following simple script will output the required Clustershell commands to create the local groups memberships. Copy and paste into notepad as say local_groups_creator.ps1 and run like>


.\local_groups_creator.ps1 -SIDsFile sids.txt -LUGfile lug.txt -Vserver VSERVERNAME


The Script


Param(
  [Parameter(Mandatory=$true)][String]$SIDsFile,
  [Parameter(Mandatory=$true)][String]$LUGfile,
  [Parameter(Mandatory=$true)][String]$Vserver
)

$SIDtoUser = @{}
[System.Array]$SIDs = Get-Content $SIDsFile
$SIDs | Foreach {
  [System.Array]$S = $_.Split(";")
  If($S.count -eq 2){
    $SIDtoUser.($S[0]) = $S[1]
  }
}

$Output = @()
$SIDtoGroup = @{}
[System.Array]$LUGs = Get-Content $LUGfile
$LUGs | Foreach {
  [System.Array]$S = $_.Split(",")
  If($S.count -eq 9){
    $SIDtoGroup.($S[3]) = $S[5]
  }
  If($S.count -eq 7){
    If($SIDtoGroup.($S[3]) -and $SIDtoUser.($S[5])){
      $Output += ('local-group add-members -group-name "' + $SIDtoGroup.($S[3]) + '" -vserver ' + $Vserver + ' -member-names "' + $SIDtoUser.($S[5]) + '"')
    }
  }
}

$Output


Note: This only creates ”local-group add-members” commands for adding members to local groups that already exist on the SVM (the BUILTIN groups.)

No comments:

Post a Comment