What to do when the password contains special characters PS?
Invoke-Expression -Command "net use x: $Path /USER:domain1\user1 7Ui4RT,@T /persistent:no"
This doesn't match the syntax - because PS interprets 7Ui4RT,@T as an array
Invoke-Expression -Command "net use x: $Path /USER:domain1\user1 7Ui4RT`,@T /persistent:no"
This does not match the syntax - apparently because PS cannot interpret 7Ui4RT``,@T
Invoke-Expression -Command "net use x: $Path /USER:domain1\user1 "7Ui4RT,@T" /persistent:no"
This fails because PS interprets 7Ui4RT,@T as an object, not a string (error = "A positional parameter that takes the argument" System.Object [] "cannot be found.)
What to do?
source share