I am trying to optimise a login script to make it as robust and quick to execute as possible.
The script logs a number of drives, and I can see I can use either:
(New-Object -ComObject WScript.Network).MapNetworkDrive("X:", \\myserver\myshare))
or
net use x: \\myserver\myshare
To map the drives.
Which is the "better" way? The "traditional" way seems more robust, but is slower than the newer method.
I'm also getting some oddities when I test to see if the drives exist. Even though they show in Explorer, sometimes when I test with:
if (test-path x:) { write "Drive mapped already" }
it does not output any result. This seems to only happen some of the time, but I haven't worked out the pattern.
Thanks,
Ben