The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

markrgunn (9) [Avatar] Offline
#1
Hello,

I'm attempting to create a file system share and I'm getting an error. I'm wondering if it's due to the use of a hidden share with the use of $ as syntax. Here's my command:

New-PSDrive -name T -psprovider FileSystem -root "\$serverc$Program FilesApplication"

Note, $server is a valid server name and Application is a valid directory on $server. I don't have any problems if I use a public share - no hidden shares.

If this is the case, is there a ways to have $ not interpreted as a string substitution?

Thanks,
Mark
jhammer (5) [Avatar] Offline
#2
Re: Hidden shares and variable substitution
Hi Mark,

If you look at section 2.2.2 of the book, it explains the differences for using different quotes. Variables are expanded in double quotes. However, this is not the case for single quotes.

If you need to have variables expand, yet need to print something with a '$' you can escape it with the backtick.

Good luck!

- Joey
markrgunn (9) [Avatar] Offline
#3
Re: Hidden shares and variable substitution
Thanks for the reference in the book. That should do the trick.

Thanks,
Mark