Return a object or list of objects from Powershell to VBScript

63 Views Asked by At

I'm working on a script in VBScript (inside Sparx EA) to validate the users and groups of an Azure Entra ID (aka Azure AD)

Now since it seems to be much easier to use Powershell to get that information from Azure, I wrote a powershell script and execute that from VBScript like this:

dim shell
set shell = CreateObject("Wscript.shell")
shell.run "powershell -file " & script.FullPath

My powershell script creates a number of CSV files containing the info I need. When the powershell script is finished, I read those files in VBScript.

dim groups
set groups = getGroupsFromFile(script.FullPathWithoutExtension & "_AzureADGroups.csv")
dim users
set users = getUsersFromFile(script.FullPathWithoutExtension & "_AzureADUsers.csv")
'link users with groups
readMembershipsFromFile script.FullPathWithoutExtension & "_AzureADUserGroups.csv", users, groups

Then I cleanup by deleting the CSV files created by my Powershell script.

Instead of this workaround with the CSV files, I would much rather get a list of user objects in VBScript, but I haven't found a way to do that.

I know it's possible to return an integer using the exit command, or a string using the StdOut from this question: How to return PowerShell variable to VBScript

But I haven't found a way to return objects or lists of objects from Powershell to VBScript.

0

There are 0 best solutions below