Author Posts

October 4, 2017 at 4:05 pm

Can someone please explain to me why this doesn't work?

Get-Item "'\\$(Read-Host 'Specify Computer')\c$\Program Files (x86)\Microsoft Office\root\Office16\winword.exe'"
"'\\$(Read-Host 'Specify Computer')\c$\Program Files (x86)\Microsoft Office\root\Office16\winword.exe'" | Get-Item

Write-Host behaves exactly as I would expect...

Write-Host "'\\$(Read-Host 'Specify Computer')\c$\Program Files (x86)\Microsoft Office\root\Office16\winword.exe'"
"'\\$(Read-Host 'Specify Computer')\c$\Program Files (x86)\Microsoft Office\root\Office16\winword.exe'" | Write-Host

Also, if I manually provide string it works fine.

Get-Item "'\\computer\c$\Program Files (x86)\Microsoft Office\root\Office16\winword.exe'"
"'\\computer\c$\Program Files (x86)\Microsoft Office\root\Office16\winword.exe'" | Get-Item

Any idea as to why Get-Item wants to append the target location to the current location in this circumstance?

Thanks in Advance

October 4, 2017 at 4:25 pm

The C$ should probably be C`$ to escape the dollar sign. I'm also not sure what the embedded single quotes are doing for you.

What's this not doing that you expected it to?

October 4, 2017 at 4:41 pm

Removing extra set of quotes resolved issue. I swear initially had a single pair of quotations and it didn't like that because there were spaces in the path so that's why I added the second pair. In any case, it does what I want it to do now so I'm happy 🙂 Thank you sir!