# ------------------------------------------------------------------ # AUTHOR: [LucidLink Support] # NAME: permissions_script.ps1 # VERSION: 2.0 # DESCRIPTION: Lists permissions/shares from Filespace instance 1 # and imports into Filespace instance 2 # # THE SCRIPT IS PROVIDED “AS IS” AND “AS AVAILABLE” AND IS WITHOUT # WARRANTY OF ANY KIND. PLEASE REVIEW ALL TERMS AND CONDITIONS. # https://www.lucidlink.com/legal-documents # ------------------------------------------------------------------ Param( [string]$FS1ROOTPWD, [string]$FS2ROOTPWD ) # --- Ensure password --- if ([string]::IsNullOrEmpty($FS1ROOTPWD) -or [string]::IsNullOrEmpty($FS2ROOTPWD)) { Write-Host "Usage: .\permissions_script.ps1 `r`nRequest failed with: Bad Request `r`nEmpty required parameter 'password' is not allowed!" exit 1; } # --- Identify Filespace format --- $PERMISSIONVER="2.2" $INSTANCE1STATUS = lucid --instance 1 status $FSFORMAT1 = $INSTANCE1STATUS -match "Filespace format:" -replace "[^0-9-.]" , '' if ($PERMISSIONVER -gt $FSFORMAT1) { $COMMAND1="share" $COLUMNS="`$SHAREDPATH, `$USERGROUP, `$TYPE, `$SHAREDAS, `$PERMISSIONS = `$LINES -split ';'" } else { $COMMAND1="permission" $COLUMNS="`$SHAREDPATH, `$USERGROUP, `$TYPE, `$PERMISSIONS = `$LINES -split ';'" } $INSTANCE2STATUS = lucid --instance 2 status $FSFORMAT2 = $INSTANCE2STATUS -match "Filespace format:" -replace "[^0-9-.]" , '' if ($PERMISSIONVER -gt $FSFORMAT2) { $COMMAND2="share" $OPTION2="--permissions" } else { $COMMAND2="permission" $OPTION2="--access" } # --- List and filter instance 1 share user and group assingments --- $SOURCESHARES = lucid --instance 1 $COMMAND1 --configured --password ""$FS1ROOTPWD"" $SHARES = $SOURCESHARES.replace('read, write','read,write').replace('[user]',';user').replace('[group]',';group') -match "lucid\\" -replace '\s{2,}', ';' -replace ' ;', ';' # --- Loop through permissions/shares assigning users and groups within instance 2 --- foreach ($LINES in $SHARES) { Invoke-Expression $COLUMNS Start-Process -WindowStyle hidden -FilePath "C:\Program Files\Lucid\Resources\Lucid.exe" -ArgumentList "--instance 2 $COMMAND2 --set ""$SHAREDPATH"" --$TYPE ""$USERGROUP"" $OPTION2 $PERMISSIONS --password ""$FS2ROOTPWD""" -Wait -RedirectStandardOutput lucid_permissions_output.txt -RedirectStandardError lucid_permissions_error_output.txt Get-Content lucid_permissions_output.txt, lucid_permissions_error_output.txt Get-Content lucid_permissions_output.txt, lucid_permissions_error_output.txt | Out-File lucid_permissions_log.txt -Append } exit