I am slowly learning the ropes of writing my own PowerShell modules containing business specific cmdlets to interact with an ERP.
A prerequisite for accessing data in the ERP is successfully logging in through the provided SDK/API.
So I have made a Connect-ERP cmdlet for that purpose where logon credentials and various other information is provided. This works fine.
Next, I have a New-Customer cmdlet for - well - creating a new customer in the ERP, but as this cannot be completed without logging in first, I find I have two options.
- Check if there is an active, successful connection object available. If not, then write a message telling the user to first run the Connect-ERP cmdlet.
- This is the one I would like to accomplish: Add code to the Connect-ERP cmdlet which enables the subset of cmdlets for working with ERP components; only if the connection is successful. (3. There is also a Disconnect-ERP cmdlet, where I would then like to hide said subset of cmdlets)
Is this at all possible?