cancel
Showing results for 
Search instead for 
Did you mean: 
MichaelE1
Active Contributor

How-To auto-generate shared folder ACL spreadsheet

Second attempt to post this.

I wrote the following method using the LastPass API, PowerShell v7.x and the importExcel module.

 

First we retrieve the shared folder data

$lpURL = "https://lastpass.com/enterpriseapi.php"
$payload = @{}
$payload.add("Content-Type","application/JSON")
$payload.add("cid","<<useUrOwn>>")
$payload.add("provhash","<<useUrOwn>>")
$payload.add("apiuser","YourNameHere")
$payload.add("cmd","getsfdata")

$jsonPayload = $payload | convertto-json
$sfInfoResults = Invoke-WebRequest $lpURL -Body $jsonPayload -UseBasicParsing -Method Post

$temp = ($sfInfoResults.content | convertfrom-json -depth 4)

$sfIDs = $temp | Get-Member -MemberType NoteProperty | Select -ExpandProperty Name

$sFolderList = New-Object System.Collections.ArrayList($null)

foreach ($sfID in $sfIDs) {

$tempSFolder = $temp.$sfID
$tempSFolderUsers = ($temp.$sfID).users

$cFolder = [pscustomobject][ordered]@{sfid = $sfID
	sharedfoldername = $tempSFolder.sharedfoldername
	sfScore = $tempSFolder.score
	sfUsers = $tempSFolderUsers
	}

[void]$sFolderList.Add($cFolder)

}

Next we process the data and create the workbook. You should set the value for $cwd to something relevant for yourself.

$cwd = "C:\temp"
# Delete pre-exiting file
if (Test-Path "$cwd\lpSFACLs.xlsx"){
	Remove-Item "$cwd\lpSFACLs.xlsx" -force
}

$lpSFACLfile = "$cwd\lpSFACLs.xlsx"

$indexList = $sFolderList | Select sharedfoldername, sfid | Sort-Object sharedfoldername
$indexList | Export-Excel $lpSFACLfile -worksheetname "index" -AutoSize

$newIndex = @{}
foreach($folder in $sFolderList){

	$shName = $folder.sharedfoldername
	
	$msg = "Processing $shName" | timestamp
	Write-Host -foreground green $msg

	if (($shName.Length -lt 1) -OR ($shName.Length -gt 30)){
		$shName = "I$($folder.sfid)"
	}

	$xlHLtxt = "'" + $shName + "'!A1"
	$newIndexItem = New-Object -TypeName OfficeOpenXml.ExcelHyperLink -ArgumentList $xlHLtxt, $($folder.sfid)
	
	$msg = "Created new excel link: " + $newIndexItem.ReferenceAddress | timestamp
	Write-Host -foreground yellow $msg
	
	[void]$newIndex.add($folder.sfid,$newIndexItem)

	$shACL = ($sFolderList | ? {$_.sfid -eq $folder.sfid}).sfusers

	$shACL | Export-Excel $lpSFACLfile -worksheetname $shName -tableName $shName.replace("-","").replace(" ","") -autosize

}

foreach($line in $indexList){

	$msg = "Updating " + $line.sharedfoldername | timestamp
	Write-Host -foreground green $msg

	$line.sfid = $newIndex[$line.sfid]

}

$indexList | Export-Excel $lpSFACLfile -worksheetname "index" -AutoSize

After this, you should find the spreadsheet (lpSFACLs.xlsx) in the $cwd location.

One other recent observation, some of the shared folders are now showing the groups that the users are in. Older shared folders don't have this information.

 

Michael Eraña, CISA, CISSP

“Dance like no one’s watching. Encrypt like everyone is.”

 

Tags (3)
1 REPLY 1
avunbos
New Contributor

overkill 3 hack mod apk download

Overkill 3 MOD APK: Are you like to play the Overkill 3 game? but tried to complete some difficult stages? due to low Money Medals, and trying your best and best to complete all difficult stage but until yet not get success So guys don’t worry cause here I come with your Overkill 3 game solution.

overkill-3-mod-apk