Dynamic Collection form PowerShell scanner
Over the last week, I have been playing with the PowerShell scanner to bring our WSUS data into inventory. During my testing, this is how my data was in Inventory:
Which allowed me to create a dynamic collection like so:
Now that my testing has completed, my data in inventory is like this:
When I try to create a collection like before, I don't get the same options:
Any ideas on how I can get Inventory to recognise the data as a date?
0
Comments
Inventory uses the datatype that PowerShell returns. In this case, it looks like it's returning a String for some reason. You should be able to cast it to [DateTime]. Here's an example: https://github.com/pdq/PowerShell-Scanners/blob/d312a4825e79bcc534541f099e32a10111782550/PowerShell%20Scanners/Google%20Chrome%20Extensions/Google%20Chrome%20Extensions.ps1#L74
Thank you! That has worked for the most part. I've got a couple of issues now.
Powershell believes that the data it receives is in MM/dd/yyyy format when it is really in dd/MM/yyyy format. The problem with this is that because Powershell thinks it's MM/dd it can't convert 18/01 into a DateTime.
I've also got PCs with records of 02/01/2021 which I know is 2nd Jan, but Inventory thinks it's Feb 1st.
Not overly fussed if the data displays in Inventory in MM/dd/yyyy format as long as I can make collections based off of it!
Try using [DateTime]::Parse() instead. https://stackoverflow.com/questions/14359053/why-does-powershell-always-use-us-culture-when-casting-to-datetime