I’ve been trying to create a script to download a SuperDAT file from McAfee but the file name changes time to time.
Is there a way to do a “get-childitem” like command on http to get only the newest file?
No, unfortunately not. Web servers don’t allow you to enumerate what’s there that way, mainly for security reasons.
When you go to Index of /140410/products/licensed/superdat/nai/brazilian, what you’re getting is an actual HTML file that the server constructs. If you’re doing this from a client computer, you could use Invoke-WebRequest to get that HTML file. The response object will parse out hyperlinks for you, meaning you’ll have a set of objects that represent each hyperlink. You could then use that as a kind of “file list,” and figure out which one you want from there. That won’t work on a server, though; the parsing functionality depends on some IE bits that are client-side. So if you need this to run on a server, you’d have to request that HTML file via Invoke-WebRequest, and then probably use a regular expression to parse out the available hyperlinks yourself.