Basically the title. Is it possible to pass a Hash Table to a function then go through each of its properties and validate a pattern? If so, how would you do it?
E.g. you have the hash table with Device names which follow a common naming prefix and device ObjectID’s from AzureAD;
ObjectId DisplayName -------- ----------- ObjectId Prefix-Serial
And the parameter:
[Parameter(Mandatory = $True, Position = 0, HelpMessage = "A Hash Table of device ObjectId's and device names.")] [ValidatePattern("????????")] [System.Collection.Hashtable]$Devices
Individually, I have no worries with the regex rules, but I can’t see how to validate both properties of the Hash table?
Additionally, is it possible to validate that the collection only has 2 properties and that they are named ObjectId and DisplayName?
This isn’t necessarily needed for functionality as the input has already been sanitized, but my team wants to add it to Automation account’s as a shared module so i’d rather ensure it works correctly or at least gives proper errors if it’s not used properly.
Any help is greatly appreciated 🙂.