Question:
I found numerous threads and went through them but none of them really adressed my issue. I try to keep it short.
1 2 |
New-PSDrive –Name "G" –PSProvider FileSystem –Root "\\dom\dfs\dom-loc-Share" –Persist |
It works perfectly fine if I run it from the ISE.
It works fine when I copy paste it to the console.
It does not work if I try running the ps1 in the console.
- I restarted the ISE
- I checked and both run in Single Threaded Apartment
- Executionpolicy is unrestricted
- I run both as administrator
Can you please help me?
Answer:
Use -Scope Global
, for more information visit this technet article:
about_Scopes https://technet.microsoft.com/en-us/library/hh847849.aspx
[…]
Windows PowerShell protects access to variables, aliases, functions,
and Windows PowerShell drives (PSDrives) by limiting where they can be
read and changed. By enforcing a few simple rules for scope, Windows
PowerShell helps to ensure that you do not inadvertently change an
item that should not be changed. […]
1 2 |
New-PSDrive –Name "G" –PSProvider FileSystem –Root "\\dom\dfs\dom-loc-Share" –Persist -Scope Global |