Reputation: 11728
How do I properly invoke the Subst command from my powershell profile?
Here is what I have tried:
I have the following function in my powershell profile:
function aa1 {
Subst "q:" /D
Subst "q:" $tjb.mypath
}
It works when I call it from the command line, but if I call it from my powershell profile, with the line:
aa1
It gives me the following error upon the start of a new powershell function:
Invalid parameter -q:
However, I know that the first line of the function works correctly because the q: drive disappears.
Here is an example of the output from the above commands:
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.
Invalid parameter - Q:
Invalid parameter - q:
** snip Other unrelated stuff**
> aa1
Invalid parameter - Q:
>
Upvotes: 1
Views: 2358
Reputation: 109
I recommend testing if the drive already exists before running subst /D
if(Test-Path -Path "q:" -IsValid) {
# Unsubst the existing q: to make space for a new one
subst "q:" /D
}
Subst "q:" $tjb.mypath
Upvotes: 1
Reputation: 6191
If you do subst q: /d
when q: is not already a substituted drive, you will get this error
Upvotes: 3